gnucash stable: [utest-Transaction.cpp] test actual kvp slots
Christopher Lam
clam at code.gnucash.org
Sat Jun 28 02:12:54 EDT 2025
Updated via https://github.com/Gnucash/gnucash/commit/584bc611 (commit)
from https://github.com/Gnucash/gnucash/commit/c5a6341a (commit)
commit 584bc611921e71c1cab84995d19ff683c96305d1
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Jun 28 14:09:23 2025 +0800
[utest-Transaction.cpp] test actual kvp slots
diff --git a/libgnucash/engine/test/utest-Transaction.cpp b/libgnucash/engine/test/utest-Transaction.cpp
index 873c3251aa..bd72584d8e 100644
--- a/libgnucash/engine/test/utest-Transaction.cpp
+++ b/libgnucash/engine/test/utest-Transaction.cpp
@@ -52,6 +52,7 @@ static const char *trans_notes_str = "notes";
static const char *void_reason_str = "void-reason";
static const char *void_time_str = "void-time";
static const char *void_former_notes_str = "void-former-notes";
+static const char *doclink_uri_str = "assoc_uri";
const char *trans_is_closing_str = "book_closing";
#define TRANS_DATE_DUE_KVP "trans-date-due"
#define TRANS_TXN_TYPE_KVP "trans-txn-type"
@@ -1745,21 +1746,29 @@ static void
test_xaccTransGetReadOnly (Fixture *fixture, gconstpointer pData)
{
auto txn = fixture->txn;
+ auto frame = fixture->txn->inst.kvp_data;
+
g_assert_cmpstr (xaccTransGetReadOnly (txn), ==, nullptr);
+ g_assert_null (frame->get_slot({TRANS_READ_ONLY_REASON}));
xaccTransSetReadOnly (txn, "RO");
g_assert_cmpstr (xaccTransGetReadOnly (txn), ==, "RO");
+ g_assert_cmpstr (frame->get_slot({TRANS_READ_ONLY_REASON})->get<const char*>(), ==, "RO");
xaccTransSetReadOnly (txn, nullptr); // reason being nullptr is a NOP
g_assert_cmpstr (xaccTransGetReadOnly (txn), ==, "RO");
+ g_assert_cmpstr (frame->get_slot({TRANS_READ_ONLY_REASON})->get<const char*>(), ==, "RO");
xaccTransClearReadOnly (txn);
g_assert_cmpstr (xaccTransGetReadOnly (txn), ==, nullptr);
+ g_assert_null (frame->get_slot({TRANS_READ_ONLY_REASON}));
xaccTransSetReadOnly (txn, "");
g_assert_cmpstr (xaccTransGetReadOnly (txn), ==, "");
+ g_assert_cmpstr (frame->get_slot({TRANS_READ_ONLY_REASON})->get<const char*>(), ==, "");
xaccTransClearReadOnly (txn);
+ g_assert_null (frame->get_slot({TRANS_READ_ONLY_REASON}));
}
@@ -1833,43 +1842,55 @@ static void
test_xaccTransSetNotes (Fixture *fixture, gconstpointer pData)
{
auto trans = fixture->txn;
+ auto frame = fixture->txn->inst.kvp_data;
xaccTransSetNotes (trans, "set");
g_assert_cmpstr (xaccTransGetNotes (trans), ==, "set");
+ g_assert_cmpstr (frame->get_slot({trans_notes_str})->get<const char*>(), ==, "set");
xaccTransSetNotes (trans, "");
g_assert_cmpstr (xaccTransGetNotes (trans), ==, "");
+ g_assert_cmpstr (frame->get_slot({trans_notes_str})->get<const char*>(), ==, "");
xaccTransSetNotes (trans, "reset");
g_assert_cmpstr (xaccTransGetNotes (trans), ==, "reset");
+ g_assert_cmpstr (frame->get_slot({trans_notes_str})->get<const char*>(), ==, "reset");
// calling xaccTransSetNotes with notes==null is currently NOP
xaccTransSetNotes (trans, NULL);
g_assert_cmpstr (xaccTransGetNotes (trans), ==, "reset");
+ g_assert_cmpstr (frame->get_slot({trans_notes_str})->get<const char*>(), ==, "reset");
}
static void
test_xaccTransSetDocLink (Fixture *fixture, gconstpointer pData)
{
auto trans = fixture->txn;
+ auto frame = fixture->txn->inst.kvp_data;
g_assert_cmpstr (xaccTransGetDocLink (trans), ==, NULL);
+ g_assert_null (frame->get_slot({doclink_uri_str}));
xaccTransSetDocLink (trans, "doclink");
g_assert_cmpstr (xaccTransGetDocLink (trans), ==, "doclink");
+ g_assert_cmpstr (frame->get_slot({doclink_uri_str})->get<const char*>(), ==, "doclink");
xaccTransSetDocLink (trans, "unset");
g_assert_cmpstr (xaccTransGetDocLink (trans), ==, "unset");
+ g_assert_cmpstr (frame->get_slot({doclink_uri_str})->get<const char*>(), ==, "unset");
xaccTransSetDocLink (trans, "");
g_assert_cmpstr (xaccTransGetDocLink (trans), ==, NULL);
+ g_assert_null (frame->get_slot({doclink_uri_str}));
xaccTransSetDocLink (trans, "reset");
g_assert_cmpstr (xaccTransGetDocLink (trans), ==, "reset");
+ g_assert_cmpstr (frame->get_slot({doclink_uri_str})->get<const char*>(), ==, "reset");
// calling xaccTransSetDocLink with doclink==null is currently NOP
xaccTransSetDocLink (trans, NULL);
g_assert_cmpstr (xaccTransGetDocLink (trans), ==, "reset");
+ g_assert_cmpstr (frame->get_slot({doclink_uri_str})->get<const char*>(), ==, "reset");
}
static void
Summary of changes:
libgnucash/engine/test/utest-Transaction.cpp | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
More information about the gnucash-changes
mailing list