gnucash maint: [utest-Transaction] add tests for xaccTransGetReadOnly

Christopher Lam clam at code.gnucash.org
Sat Sep 25 01:32:17 EDT 2021


Updated	 via  https://github.com/Gnucash/gnucash/commit/128c8d6f (commit)
	from  https://github.com/Gnucash/gnucash/commit/e123d1be (commit)



commit 128c8d6f8864790ffe4bba9be2349d991fda4c8c
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Sep 25 00:01:56 2021 +0800

    [utest-Transaction] add tests for xaccTransGetReadOnly

diff --git a/libgnucash/engine/test/utest-Transaction.cpp b/libgnucash/engine/test/utest-Transaction.cpp
index 8e7ab027f..54069d15e 100644
--- a/libgnucash/engine/test/utest-Transaction.cpp
+++ b/libgnucash/engine/test/utest-Transaction.cpp
@@ -1779,6 +1779,29 @@ test_xaccTransOrder_num_action (Fixture *fixture, gconstpointer pData)
 
     fixture->func->xaccFreeTransaction (txnB);
 }
+
+static void
+test_xaccTransGetReadOnly (Fixture *fixture, gconstpointer pData)
+{
+    auto txn = fixture->txn;
+    g_assert_cmpstr (xaccTransGetReadOnly (txn), ==, nullptr);
+
+    xaccTransSetReadOnly (txn, "RO");
+    g_assert_cmpstr (xaccTransGetReadOnly (txn), ==, "RO");
+
+    xaccTransSetReadOnly (txn, nullptr); // reason being nullptr is a NOP
+    g_assert_cmpstr (xaccTransGetReadOnly (txn), ==, "RO");
+
+    xaccTransClearReadOnly (txn);
+    g_assert_cmpstr (xaccTransGetReadOnly (txn), ==, nullptr);
+
+    xaccTransSetReadOnly (txn, "");
+    g_assert_cmpstr (xaccTransGetReadOnly (txn), ==, "");
+
+    xaccTransClearReadOnly (txn);
+}
+
+
 /* xaccTransSetDateInternal Local: 7:0:0
  * set_gains_date_dirty Local: 4:0:0
  * xaccTransSetDatePostedSecs C: 17 in 13  Local: 0:0:0
@@ -2067,6 +2090,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, "xaccTransGetreadOnly", Fixture, NULL, setup, test_xaccTransGetReadOnly, teardown);
     GNC_TEST_ADD (suitename, "xaccTransSetDocLink", Fixture, NULL, setup, test_xaccTransSetDocLink, teardown);
     GNC_TEST_ADD (suitename, "xaccTransVoid", Fixture, NULL, setup, test_xaccTransVoid, teardown);
     GNC_TEST_ADD (suitename, "xaccTransReverse", Fixture, NULL, setup, test_xaccTransReverse, teardown);



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



More information about the gnucash-changes mailing list