diff --git a/gnucash/report/standard-reports/test/test-charts.scm b/gnucash/report/standard-reports/test/test-charts.scm index 2094f285ba..edd4b88fa6 100644 --- a/gnucash/report/standard-reports/test/test-charts.scm +++ b/gnucash/report/standard-reports/test/test-charts.scm @@ -116,7 +116,33 @@ (let* ((options (default-testing-options))) (test-assert (format #f "basic report exists: ~a" variant) - (options->render uuid options (format #f "net-charts-test ~a default options" variant)))) + (options->render uuid options (format #f "test-null ~a default options" variant)))) + + ;; test net worth barchart amounts + (when (eq? variant 'net-worth-barchart) + ;; create 100 daily transactions from 1/1/70. this is meant to + ;; test chart date ranges. day 0 = $0, day 1 = $1, etc + (let loop ((date (gnc-dmy2time64 1 1 1970)) (idx 0)) + (when (<= idx 100) + (env-create-transaction env date bank income idx) + (loop (incdate date DayDelta) (1+ idx)))) + (let* ((options (default-testing-options))) + (set-option! options "General" "Start Date" (cons 'absolute (gnc-dmy2time64 15 1 1970))) + (set-option! options "General" "End Date" (cons 'absolute (gnc-dmy2time64 15 3 1970))) + (set-option! options "General" "Step Size" 'DayDelta) + (set-option! options "Display" "Show table" #t) + (let ((sxml (gnc:options->sxml uuid options (format #f "test-net-charts ~a 2 months" variant) + "test-table" #:strip-tag "script"))) + (test-equal "net-worth-barchart: first row" + '("Date" "Assets" "Liabilities" "Net Worth") + (sxml->table-row-col sxml 1 0 #f)) + (test-equal "net-worth-barchart: first data row" + '("01/15/70" "$105.00" "$0.00" "$105.00") + (sxml->table-row-col sxml 1 1 #f)) + (test-equal "net-worth-barchart: last data row" + '("03/15/70" "$2,701.00" "$0.00" "$2,701.00") + (sxml->table-row-col sxml 1 -1 #f)) + ))) (case variant ((liability-piechart stock-piechart asset-piechart expense-piechart income-piechart)