gnucash maint: [test-transaction] add tests for gnc:lists->csv

Christopher Lam clam at code.gnucash.org
Mon Feb 28 08:09:18 EST 2022


Updated	 via  https://github.com/Gnucash/gnucash/commit/c6429804 (commit)
	from  https://github.com/Gnucash/gnucash/commit/c02e23bd (commit)



commit c64298045662a29b65f239a9206fc061b621964b
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Feb 28 09:42:56 2022 +0800

    [test-transaction] add tests for gnc:lists->csv

diff --git a/gnucash/report/reports/standard/test/test-transaction.scm b/gnucash/report/reports/standard/test/test-transaction.scm
index 2aca4d91e..4a0ffc43c 100644
--- a/gnucash/report/reports/standard/test/test-transaction.scm
+++ b/gnucash/report/reports/standard/test/test-transaction.scm
@@ -67,6 +67,7 @@
   (test-begin "transaction.scm")
   (null-test)
   (trep-tests)
+  (csv-tests)
   (reconcile-tests)
   ;; (test-end) must be run as the last function, it will
   ;; return #f if any of the tests have failed.
@@ -928,6 +929,30 @@
           (gnc:html-document-export-string document))))
     (test-end "csv-export")))
 
+(define (csv-tests)
+  (test-begin "csv tests")
+  (test-equal "gnc:lists->csv empty"
+    ""
+    (gnc:lists->csv '(())))
+  (test-equal "gnc:lists->csv simple"
+    "\"from\",\"01/01/2010\""
+    (gnc:lists->csv
+     '(("from" "01/01/2010"))))
+  (test-equal "gnc:lists->csv complex"
+    "\"from\",\"01/01/2010\",,,
+\"to\",\"31/12/2010\",,,
+\"total\",23500.0,30000.0,3.5714285714285716,sym"
+    (gnc:lists->csv
+     '(("from" "01/01/2010")
+       ("to" "31/12/2010")
+       ("total" 23500 30000 25/7 sym))))
+  (test-error "gnc:lists->csv improper list"
+    (gnc:lists->csv
+     '(("from" "01/01/2010")
+       ("to" "31/12/2010")
+       ("total" 23500 30000 25/7 . sym))))
+  (test-end "csv tests"))
+
 (define (reconcile-tests)
   (let* ((env (create-test-env))
          (account-alist (env-create-account-structure-alist env structure))



Summary of changes:
 .../reports/standard/test/test-transaction.scm     | 25 ++++++++++++++++++++++
 1 file changed, 25 insertions(+)



More information about the gnucash-changes mailing list