gnucash maint: [test-qofbook] basic features test
Christopher Lam
clam at code.gnucash.org
Thu Oct 27 08:18:51 EDT 2022
Updated via https://github.com/Gnucash/gnucash/commit/6f6d2fef (commit)
from https://github.com/Gnucash/gnucash/commit/82cc08f9 (commit)
commit 6f6d2fef488b971ad76f163395cc206b585175b3
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Wed Oct 26 22:25:35 2022 +0800
[test-qofbook] basic features test
sets a feature and tests it's set. it's impossible to design a book
with unknown features using the API.
diff --git a/libgnucash/engine/test/test-qofbook.c b/libgnucash/engine/test/test-qofbook.c
index 794dc5274..a771c3d5e 100644
--- a/libgnucash/engine/test/test-qofbook.c
+++ b/libgnucash/engine/test/test-qofbook.c
@@ -34,6 +34,7 @@ extern "C"
#endif
#include "../qof.h"
+#include "../gnc-features.h"
#include "../qofbook-p.h"
#include "../qofbookslots.h"
/* For gnc_account_create_root() */
@@ -768,6 +769,25 @@ test_book_get_collection( Fixture *fixture, gconstpointer pData )
g_assert( m_col == m_col2 );
}
+
+static void
+test_book_features (Fixture *fixture, gconstpointer pData)
+{
+ g_test_message ("Testing book features");
+
+ g_assert_null (gnc_features_test_unknown (fixture->book));
+ g_assert_false (gnc_features_check_used (fixture->book, "Credit Notes"));
+
+ gnc_features_set_used (fixture->book, "Credit Notes");
+ g_assert_null (gnc_features_test_unknown (fixture->book));
+ g_assert_true (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"));
+}
+
static void
test_book_foreach_collection( Fixture *fixture, gconstpointer pData )
{
@@ -940,6 +960,7 @@ test_suite_qofbook ( void )
GNC_TEST_ADD( suitename, "shutting down", Fixture, NULL, setup, test_book_shutting_down, teardown );
GNC_TEST_ADD( suitename, "set get data", Fixture, NULL, setup, test_book_set_get_data, teardown );
GNC_TEST_ADD( suitename, "get collection", Fixture, NULL, setup, test_book_get_collection, teardown );
+ GNC_TEST_ADD( suitename, "features", Fixture, NULL, setup, test_book_features, teardown );
GNC_TEST_ADD( suitename, "foreach collection", Fixture, NULL, setup, test_book_foreach_collection, teardown );
GNC_TEST_ADD_FUNC( suitename, "set data finalizers", test_book_set_data_fin );
GNC_TEST_ADD( suitename, "mark closed", Fixture, NULL, setup, test_book_mark_closed, teardown );
Summary of changes:
libgnucash/engine/test/test-qofbook.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
More information about the gnucash-changes
mailing list