gnucash stable: [utest-Transaction.cpp] add test_xaccTransGetDateDue tests
Christopher Lam
clam at code.gnucash.org
Sat Jun 28 05:54:00 EDT 2025
Updated via https://github.com/Gnucash/gnucash/commit/7f82098c (commit)
from https://github.com/Gnucash/gnucash/commit/584bc611 (commit)
commit 7f82098c11ceb92df0347746ac9eb410c1c62afa
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Jun 28 17:51:27 2025 +0800
[utest-Transaction.cpp] add test_xaccTransGetDateDue tests
including currently (arguably) buggy behaviour if kvp time64 is 0...
diff --git a/libgnucash/engine/test/utest-Transaction.cpp b/libgnucash/engine/test/utest-Transaction.cpp
index bd72584d8e..6117052ef5 100644
--- a/libgnucash/engine/test/utest-Transaction.cpp
+++ b/libgnucash/engine/test/utest-Transaction.cpp
@@ -1816,6 +1816,27 @@ test_xaccTransGetTxnType (Fixture *fixture, gconstpointer pData)
g_assert_cmpint (TXN_TYPE_NONE, ==, xaccTransGetTxnType(txn));
}
+
+static void
+test_xaccTransGetDateDue (Fixture *fixture, gconstpointer pData)
+{
+ auto txn = fixture->txn;
+ auto frame = txn->inst.kvp_data;
+
+ // if there's no date_due kvp, return posted_date
+ g_assert_cmpint (xaccTransRetDateDue(txn), ==, xaccTransRetDatePosted(txn));
+ g_assert_null (frame->get_slot({TRANS_DATE_DUE_KVP}));
+
+ xaccTransSetDateDue (txn, 100);
+ g_assert_cmpint (xaccTransRetDateDue(txn), ==, 100);
+ g_assert_cmpint (frame->get_slot({TRANS_DATE_DUE_KVP})->get_ptr<Time64>()->t, ==, 100);
+
+ xaccTransSetDateDue (txn, 0);
+ g_assert_cmpint (frame->get_slot({TRANS_DATE_DUE_KVP})->get_ptr<Time64>()->t, ==, 0);
+ // the next line is arguably buggy; shouldn't it return 0 as per kvp value?
+ g_assert_cmpint (xaccTransRetDateDue(txn), ==, xaccTransRetDatePosted(txn));
+}
+
/* xaccTransGetReadOnly C: 7 in 5 Local: 1:0:0
* xaccTransIsReadonlyByPostedDate C: 2 in 2 Local: 0:0:0
* xaccTransHasReconciledSplitsByAccount Local: 1:0:0
@@ -2094,6 +2115,7 @@ test_suite_transaction (void)
GNC_TEST_ADD (suitename, "xaccTransRollbackEdit - Backend Errors", Fixture, NULL, setup, test_xaccTransRollbackEdit_BackendErrors, teardown);
GNC_TEST_ADD (suitename, "xaccTransOrder_num_action", Fixture, NULL, setup, test_xaccTransOrder_num_action, teardown);
GNC_TEST_ADD (suitename, "xaccTransGetTxnType", Fixture, NULL, setup, test_xaccTransGetTxnType, teardown);
+ GNC_TEST_ADD (suitename, "xaccTransGetDateDue", Fixture, NULL, setup, test_xaccTransGetDateDue, teardown);
GNC_TEST_ADD (suitename, "xaccTransGetreadOnly", Fixture, NULL, setup, test_xaccTransGetReadOnly, teardown);
GNC_TEST_ADD (suitename, "xaccTransSetDocLink", Fixture, NULL, setup, test_xaccTransSetDocLink, teardown);
GNC_TEST_ADD (suitename, "xaccTransSetNotes", Fixture, NULL, setup, test_xaccTransSetNotes, teardown);
Summary of changes:
libgnucash/engine/test/utest-Transaction.cpp | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
More information about the gnucash-changes
mailing list