From 9c7ba5231526914d922bcaf944fbe379a202e054 Mon Sep 17 00:00:00 2001 From: Jose Marino Date: Tue, 17 Oct 2017 15:09:20 -0600 Subject: [PATCH] report/net-barchart: fix unit test to work with gnc-monetary The unit test for net-barchart did not initialize html stylesheets. Without any stylesheets available, the renderer defaults to a trivial renderer. This works fine if the table in the net-barchart report is populated by doubles. However, now it is populated by gnc-monetary and they need a stylesheet to be properly formatted. Using doubles and the trivial renderer, a table cell looks like: 6.0 Using gnc-monetary and the trivial renderer, a table cell looks like: #[unknown] Initializing the html stylesheets, the table cell looks like: $6.00 This commit makes sure to initialize the html stylesheet code in the unit test and adapts the parsing code to the new formatting. --- .../test/test-generic-net-barchart.scm | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/gnucash/report/standard-reports/test/test-generic-net-barchart.scm b/gnucash/report/standard-reports/test/test-generic-net-barchart.scm index 91a1a48074..ac475e6c60 100644 --- a/gnucash/report/standard-reports/test/test-generic-net-barchart.scm +++ b/gnucash/report/standard-reports/test/test-generic-net-barchart.scm @@ -25,6 +25,7 @@ (use-modules (gnucash gnc-module)) (gnc:module-load "gnucash/report/report-system" 0) +(use-modules (gnucash report stylesheets)) (use-modules (gnucash engine test test-extras)) (use-modules (gnucash report report-system test test-extras)) @@ -99,11 +100,11 @@ (let* ((result (gnc:html-document-render doc #f)) (tbl (stream->list (pattern-streamer "" - (list (list " ([0-9][0-9])/([0-9][0-9])/([0-9][0-9])" + (list (list "([0-9][0-9])/([0-9][0-9])/([0-9][0-9])" 1 2 3) - (list " ([^<]*)" 1) - (list " ([^<]*)" 1) - (list " ([^<]*)" 1)) + (list "[^0-9]*([^<]*)" 1) + (list "[^0-9]*([^<]*)" 1) + (list "[^0-9]*([^<]*)" 1)) result)))) (and (= 1 (tbl-ref->number tbl 0 1)) (= 0 (tbl-ref->number tbl 0 2)) @@ -153,11 +154,11 @@ (let* ((result (gnc:html-document-render doc #f)) (tbl (stream->list (pattern-streamer "" - (list (list " ([0-9][0-9])/([0-9][0-9])/([0-9][0-9])" + (list (list "([0-9][0-9])/([0-9][0-9])/([0-9][0-9])" 1 2 3) - (list " ([^<]*)" 1) - (list " ([^<]*)" 1) - (list " ([^<]*)" 1)) + (list "[^0-9]*([^<]*)" 1) + (list "[^0-9]*([^<]*)" 1) + (list "[^0-9]*([^<]*)" 1)) result)))) (and (every (lambda (row) (and (equal? (second row) (fourth row)) @@ -207,11 +208,11 @@ (let* ((result (gnc:html-document-render doc #f)) (tbl (stream->list (pattern-streamer "" - (list (list " ([0-9][0-9])/([0-9][0-9])/([0-9][0-9])" + (list (list "([0-9][0-9])/([0-9][0-9])/([0-9][0-9])" 1 2 3) - (list " ([^<]*)" 1) - (list " ([^<]*)" 1) - (list " ([^<]*)" 1)) + (list "[^0-9]*([^<]*)" 1) + (list "[^0-9]*([^<]*)" 1) + (list "[^0-9]*([^<]*)" 1)) result)))) (and (every (lambda (row) (and (= (string->number (car (fourth row))) @@ -263,11 +264,11 @@ (let* ((result (gnc:html-document-render doc #f)) (tbl (stream->list (pattern-streamer "" - (list (list " ([0-9][0-9])/([0-9][0-9])/([0-9][0-9])" + (list (list "([0-9][0-9])/([0-9][0-9])/([0-9][0-9])" 1 2 3) - (list " ([^<]*)" 1) - (list " ([^<]*)" 1) - (list " ([^<]*)" 1)) + (list "[^0-9]*([^<]*)" 1) + (list "[^0-9]*([^<]*)" 1) + (list "[^0-9]*([^<]*)" 1)) result)))) (and (every (lambda (row) (and (= (string->number (car (fourth row))) @@ -328,11 +329,11 @@ (let* ((result (gnc:html-document-render doc #f)) (tbl (stream->list (pattern-streamer "" - (list (list " ([0-9][0-9])/([0-9][0-9])/([0-9][0-9])" + (list (list "([0-9][0-9])/([0-9][0-9])/([0-9][0-9])" 1 2 3) - (list " ([^<]*)" 1) - (list " ([^<]*)" 1) - (list " ([^<]*)" 1)) + (list "[^0-9]*([^<]*)" 1) + (list "[^0-9]*([^<]*)" 1) + (list "[^0-9]*([^<]*)" 1)) result)))) (and (every (lambda (row) (and (= (string->number (car (fourth row)))