From bd0cbbf9311d7dbc79a3361d50c89d052a2dbe5e Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Sun, 28 Jul 2019 11:45:34 +0800 Subject: [PATCH] [test-options] initial commit * test lookup option changed section/name --- libgnucash/app-utils/test/CMakeLists.txt | 1 + libgnucash/app-utils/test/test-options.scm | 28 ++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 libgnucash/app-utils/test/test-options.scm diff --git a/libgnucash/app-utils/test/CMakeLists.txt b/libgnucash/app-utils/test/CMakeLists.txt index d3a55cc416..dd9e259a14 100644 --- a/libgnucash/app-utils/test/CMakeLists.txt +++ b/libgnucash/app-utils/test/CMakeLists.txt @@ -47,6 +47,7 @@ set(test_app_utils_scheme_SOURCES set (test_app_utils_scheme_SRFI64_SOURCES test-date-utilities.scm + test-options.scm ) gnc_add_scheme_targets(scm-test-load-app-utils-module diff --git a/libgnucash/app-utils/test/test-options.scm b/libgnucash/app-utils/test/test-options.scm new file mode 100644 index 0000000000..94c2880891 --- /dev/null +++ b/libgnucash/app-utils/test/test-options.scm @@ -0,0 +1,28 @@ +(use-modules (gnucash gnc-module)) +(gnc:module-begin-syntax (gnc:module-load "gnucash/app-utils" 0)) +(use-modules (srfi srfi-64)) +(use-modules (gnucash engine test srfi64-extras)) + +(define (run-test) + (test-runner-factory gnc:test-runner) + (test-begin "test-options") + (test-lookup-option) + (test-end "test-options")) + +(define (test-lookup-option) + (let ((options (gnc:new-options))) + (gnc:register-option + options + (gnc:make-simple-boolean-option + "Section" "Start Date" "sort-tag" "docstring" 'default-val)) + + (gnc:register-option + options + (gnc:make-simple-boolean-option + "Filter" "Void Transactions" "sort-tag" "docstring" 'default-val)) + + (test-assert "lookup-option changed name" + (gnc:lookup-option options "Section" "From")) + + (test-assert "lookup-option changed section and name" + (gnc:lookup-option options "Section" "Void Transactions?"))))