From c5a6341ab29f4ecfa4c3352f1c4db7be2560a4bb Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Fri, 27 Jun 2025 21:07:23 +0800 Subject: [PATCH] [utest-Transaction] add trans->notes tests --- libgnucash/engine/test/utest-Transaction.cpp | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) 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);