diff --git a/gnucash/report/test/test-commodity-utils.scm b/gnucash/report/test/test-commodity-utils.scm index a680fd861eb..76e12ed2daa 100644 --- a/gnucash/report/test/test-commodity-utils.scm +++ b/gnucash/report/test/test-commodity-utils.scm @@ -761,6 +761,7 @@ (test-group-with-cleanup "test-get-match-commodity-splits-sorted" (let* ((account-alist (setup #f)) (book (gnc-get-current-book)) + (iso-date (qof-date-format-get-string QOF-DATE-FORMAT-ISO)) (comm-table (gnc-commodity-table-get-table book)) (MSFT (gnc-commodity-table-lookup comm-table "NASDAQ" "MSFT")) (AAPL (gnc-commodity-table-lookup comm-table "NASDAQ" "AAPL"))) @@ -770,62 +771,53 @@ (gnc-account-get-descendants-sorted (gnc-get-current-root-account)) date commodity)) + (define (split->date split) + (gnc-print-time64 (xaccTransGetDate (xaccSplitGetParent split)) iso-date)) + (let ((AAPL-splits (get-splits (gnc-dmy2time64-neutral 5 12 2014) AAPL))) (test-equal "2 AAPL splits up to 05/12/14" - '("Fri Aug 09 18:59:00 2013" "Fri Jul 11 18:59:00 2014") - (map (compose gnc-ctime xaccTransGetDate xaccSplitGetParent) AAPL-splits))) + '("2013-08-09" "2014-07-11") + (map split->date AAPL-splits))) (let ((AAPL-splits (get-splits #f AAPL))) - (test-equal "2 AAPL splits undated" - '("Fri Aug 09 18:59:00 2013" "Fri Jul 11 18:59:00 2014" - "Fri Oct 23 18:59:00 2015" "Fri Oct 23 18:59:00 2015") - (map (compose gnc-ctime xaccTransGetDate xaccSplitGetParent) AAPL-splits))) + (test-equal "4 AAPL splits undated" + '("2013-08-09" "2014-07-11" "2015-10-23" "2015-10-23") + (map split->date AAPL-splits))) (let ((MSFT-splits (get-splits (gnc-dmy2time64-neutral 5 12 2014) MSFT))) (test-equal "3 MSFT splits up to 05/12/14" - '("Sun Jan 15 18:59:00 2012" "Fri Dec 05 18:59:00 2014" - "Fri Dec 05 18:59:00 2014") - (map (compose gnc-ctime xaccTransGetDate xaccSplitGetParent) MSFT-splits))) + '("2012-01-15" "2014-12-05" "2014-12-05") + (map split->date MSFT-splits))) (let ((MSFT-splits (get-splits #f MSFT))) - (test-equal "3 MSFT splits undated" - '("Sun Jan 15 18:59:00 2012" "Fri Dec 05 18:59:00 2014" - "Fri Dec 05 18:59:00 2014" "Thu Apr 02 18:59:00 2015" - "Fri Mar 11 18:59:00 2016" "Fri Mar 11 18:59:00 2016") - (map (compose gnc-ctime xaccTransGetDate xaccSplitGetParent) MSFT-splits))) + (test-equal "6 MSFT splits undated" + '("2012-01-15" "2014-12-05" "2014-12-05" "2015-04-02" + "2016-03-11" "2016-03-11") + (map split->date MSFT-splits))) (let ((AAPL-splits (get-splits (gnc-dmy2time64-neutral 20 02 2016) AAPL))) (test-equal "4 AAPL splits up to 20/02/16" - '("Fri Aug 09 18:59:00 2013" "Fri Jul 11 18:59:00 2014" - "Fri Oct 23 18:59:00 2015" "Fri Oct 23 18:59:00 2015") - (map (compose gnc-ctime xaccTransGetDate xaccSplitGetParent) AAPL-splits))) + '("2013-08-09" "2014-07-11" "2015-10-23" "2015-10-23") + (map split->date AAPL-splits))) (let ((MSFT-splits (get-splits (gnc-dmy2time64-neutral 20 02 2016) MSFT))) (test-equal "4 MSFT splits up to 20/02/16" - '("Sun Jan 15 18:59:00 2012" "Fri Dec 05 18:59:00 2014" - "Fri Dec 05 18:59:00 2014" "Thu Apr 02 18:59:00 2015") - (map (compose gnc-ctime xaccTransGetDate xaccSplitGetParent) MSFT-splits))) + '("2012-01-15" "2014-12-05" "2014-12-05" "2015-04-02") + (map split->date MSFT-splits))) (let ((any-splits (get-splits (gnc-dmy2time64-neutral 5 12 2014) #f))) (test-equal "11 ANY splits up to 05/12/14" - '("Sun Jan 15 18:59:00 2012" "Sun Jan 15 18:59:00 2012" - "Fri Jan 20 18:59:00 2012" "Mon Feb 20 18:59:00 2012" - "Mon Feb 20 18:59:00 2012" "Fri Aug 09 18:59:00 2013" - "Fri Jul 11 18:59:00 2014" "Fri Aug 08 18:59:00 2014" - "Fri Aug 08 18:59:00 2014" "Fri Dec 05 18:59:00 2014" - "Fri Dec 05 18:59:00 2014") - (map (compose gnc-ctime xaccTransGetDate xaccSplitGetParent) any-splits))) + '("2012-01-15" "2012-01-15" "2012-01-20" "2012-02-20" + "2012-02-20" "2013-08-09" "2014-07-11" "2014-08-08" + "2014-08-08" "2014-12-05" "2014-12-05") + (map split->date any-splits))) (let ((all-splits (get-splits #f #f))) (test-equal "16 ALL splits undated" - '("Sun Jan 15 18:59:00 2012" "Sun Jan 15 18:59:00 2012" - "Fri Jan 20 18:59:00 2012" "Mon Feb 20 18:59:00 2012" - "Mon Feb 20 18:59:00 2012" "Fri Aug 09 18:59:00 2013" - "Fri Jul 11 18:59:00 2014" "Fri Aug 08 18:59:00 2014" - "Fri Aug 08 18:59:00 2014" "Fri Dec 05 18:59:00 2014" - "Fri Dec 05 18:59:00 2014" "Thu Apr 02 18:59:00 2015" - "Fri Oct 23 18:59:00 2015" "Fri Oct 23 18:59:00 2015" - "Fri Mar 11 18:59:00 2016" "Fri Mar 11 18:59:00 2016") - (map (compose gnc-ctime xaccTransGetDate xaccSplitGetParent) all-splits))) + '("2012-01-15" "2012-01-15" "2012-01-20" "2012-02-20" + "2012-02-20" "2013-08-09" "2014-07-11" "2014-08-08" + "2014-08-08" "2014-12-05" "2014-12-05" "2015-04-02" + "2015-10-23" "2015-10-23" "2016-03-11" "2016-03-11") + (map split->date all-splits))) (teardown))))