gnucash stable: [utest-Transaction] add trans->notes tests

Christopher Lam clam at code.gnucash.org
Fri Jun 27 09:10:04 EDT 2025


Updated	 via  https://github.com/Gnucash/gnucash/commit/c5a6341a (commit)
	from  https://github.com/Gnucash/gnucash/commit/4e2189db (commit)



commit c5a6341ab29f4ecfa4c3352f1c4db7be2560a4bb
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri Jun 27 21:07:23 2025 +0800

    [utest-Transaction] add trans->notes tests

diff --git a/libgnucash/engine/test/utest-Transaction.cpp b/libgnucash/engine/test/utest-Transaction.cpp
index f6917e517c..873c3251aa 100644
--- a/libgnucash/engine/test/utest-Transaction.cpp
+++ b/libgnucash/engine/test/utest-Transaction.cpp
@@ -1828,6 +1828,26 @@ void
 xaccTransUnvoid (Transaction *trans)// C: 1  Local: 0:0:0
 */
 
+
+static void
+test_xaccTransSetNotes (Fixture *fixture, gconstpointer pData)
+{
+    auto trans = fixture->txn;
+
+    xaccTransSetNotes (trans, "set");
+    g_assert_cmpstr (xaccTransGetNotes (trans), ==, "set");
+
+    xaccTransSetNotes (trans, "");
+    g_assert_cmpstr (xaccTransGetNotes (trans), ==, "");
+
+    xaccTransSetNotes (trans, "reset");
+    g_assert_cmpstr (xaccTransGetNotes (trans), ==, "reset");
+
+    // calling xaccTransSetNotes with notes==null is currently NOP
+    xaccTransSetNotes (trans, NULL);
+    g_assert_cmpstr (xaccTransGetNotes (trans), ==, "reset");
+}
+
 static void
 test_xaccTransSetDocLink (Fixture *fixture, gconstpointer pData)
 {
@@ -2055,6 +2075,7 @@ test_suite_transaction (void)
     GNC_TEST_ADD (suitename, "xaccTransGetTxnType", Fixture, NULL, setup, test_xaccTransGetTxnType, 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);
     GNC_TEST_ADD (suitename, "xaccTransVoid", Fixture, NULL, setup, test_xaccTransVoid, teardown);
     GNC_TEST_ADD (suitename, "xaccTransReverse", Fixture, NULL, setup, test_xaccTransReverse, teardown);
     GNC_TEST_ADD (suitename, "xaccTransScrubGainsDate_no_dirty", GainsFixture, NULL, setup_with_gains, test_xaccTransScrubGainsDate_no_dirty, teardown_with_gains);



Summary of changes:
 libgnucash/engine/test/utest-Transaction.cpp | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)



More information about the gnucash-changes mailing list