gnucash maint: [test-qofbook] add tests for unknown features
Christopher Lam
clam at code.gnucash.org
Sun Oct 30 22:41:01 EDT 2022
Updated via https://github.com/Gnucash/gnucash/commit/b87aa004 (commit)
from https://github.com/Gnucash/gnucash/commit/b9077bcc (commit)
commit b87aa004f9f70b0025bb475b5fc67b2c28e7e9d2
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Oct 31 10:15:04 2022 +0800
[test-qofbook] add tests for unknown features
tests that gnc_features_test_unknown returns a suitable error message
diff --git a/libgnucash/engine/test/test-qofbook.c b/libgnucash/engine/test/test-qofbook.c
index 4c6fe444e..e7799ac8f 100644
--- a/libgnucash/engine/test/test-qofbook.c
+++ b/libgnucash/engine/test/test-qofbook.c
@@ -773,6 +773,7 @@ test_book_get_collection( Fixture *fixture, gconstpointer pData )
static void
test_book_features (Fixture *fixture, gconstpointer pData)
{
+ char* msg;
g_test_message ("Testing book features");
g_assert_null (gnc_features_test_unknown (fixture->book));
@@ -786,10 +787,18 @@ test_book_features (Fixture *fixture, gconstpointer pData)
g_assert_null (gnc_features_test_unknown (fixture->book));
g_assert_false (gnc_features_check_used (fixture->book, "Credit Notes"));
- /* cannot set an unknown feature: it bails out. */
- /* gnc_features_set_used (fixture->book, "Nanotech"); */
- /* g_assert_nonnull (gnc_features_test_unknown (fixture->book)); */
- g_assert_false (gnc_features_check_used (fixture->book, "Nanotech"));
+ /* cannot use gnc_features_set_used to set an unknown feature: it bails out.
+ * use qof_book_set_feature instead. */
+ qof_book_set_feature (fixture->book, "Nanotech", "With Quantum Computing");
+ g_assert_true (gnc_features_check_used (fixture->book, "Nanotech"));
+ msg = gnc_features_test_unknown (fixture->book);
+ g_assert_cmpstr (msg, ==, "This Dataset contains features not \
+supported by this version of GnuCash. You must use a newer version \
+of GnuCash in order to support the following features:\n* With Quantum Computing");
+ g_free (msg);
+
+ qof_book_unset_feature (fixture->book, "Nanotech");
+ g_assert_null (gnc_features_test_unknown (fixture->book));
}
static void
Summary of changes:
libgnucash/engine/test/test-qofbook.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
More information about the gnucash-changes
mailing list