gnucash stable: [test-autoclear] add some more tests

Christopher Lam clam at code.gnucash.org
Mon Nov 17 06:19:17 EST 2025


Updated	 via  https://github.com/Gnucash/gnucash/commit/e4d61b30 (commit)
	from  https://github.com/Gnucash/gnucash/commit/43561ded (commit)



commit e4d61b3073dfcaf736c275d8cbaf8d9c45d24b69
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Nov 16 22:23:57 2025 +0800

    [test-autoclear] add some more tests
    
    - worst case scenario 2^N amounts with 2^N theoretical paths
    - amounts with mixed signs
    - off-by-1 target amounts
    - amounts include zero

diff --git a/libgnucash/app-utils/test/test-autoclear.cpp b/libgnucash/app-utils/test/test-autoclear.cpp
index 5ba76ccd25..b9ee6d9a85 100644
--- a/libgnucash/app-utils/test/test-autoclear.cpp
+++ b/libgnucash/app-utils/test/test-autoclear.cpp
@@ -180,6 +180,72 @@ TestCase sequentialTestCase4 =
     },
 };
 
+TestCase slowTestCase =
+{
+    .splits = {
+        { "Memo 01", 1, false },
+        { "Memo 02", 2, false },
+        { "Memo 03", 4, false },
+        { "Memo 03", 8, false },
+        { "Memo 03", 16, false },
+        { "Memo 03", 32, false },
+        { "Memo 03", 64, false },
+        { "Memo 03", 128, false },
+        { "Memo 03", 256, false },
+        { "Memo 03", 512, false },
+        { "Memo 03", 1024, false },
+        { "Memo 03", 2048, false },
+        { "Memo 03", 4096, false },
+        { "Memo 03", 8192, false },
+        { "Memo 03", 16384, false },
+        { "Memo 03", 32768, false },
+        { "Memo 03", 65536, false },
+        { "Memo 03", 131072, false },
+        { "Memo 03", 262144, false },
+        { "Memo 03", 524288, false },
+        { "Memo 03", 1048576, false },
+    },
+    .tests = {
+        { 6000000, "The selected amount cannot be cleared." },
+        { 5000000, "The selected amount cannot be cleared." },
+        { 4000000, "The selected amount cannot be cleared." },
+        { 3000000, "The selected amount cannot be cleared." },
+        { 2000000, nullptr },
+    },
+};
+
+TestCase mixedSignsTestCase =
+{
+    .splits = {
+
+        { "memo 01", 30000 },
+        { "memo 01", -20000 },
+        { "memo 01", 10000 },
+        { "memo 01", 500 },
+        { "memo 01", -400 },
+        { "memo 01", 300 }
+    },
+    .tests = {
+        { 30300, nullptr },
+    },
+};
+
+TestCase testwithzerosTestCase =
+{
+    .splits = {
+        { "memo 01", 10000 },
+        { "memo 01", 0 },
+        { "memo 01", 10000 },
+        { "memo 01", 5000 },
+    },
+    .tests = {
+        { 19999, "The selected amount cannot be cleared." },
+        { 20001, "The selected amount cannot be cleared." },
+        { 20000, nullptr },
+    },
+};
+
+
 class AutoClearTest : public ::testing::TestWithParam<TestCase *> {
 protected:
     std::shared_ptr<QofBook> m_book;
@@ -260,6 +326,9 @@ INSTANTIATE_TEST_SUITE_P(
         &sequentialTestCase2,
         &sequentialTestCase3,
         &sequentialTestCase4,
+        &slowTestCase,
+        &mixedSignsTestCase,
+        &testwithzerosTestCase,
         &ambiguousTestCase
     )
 );



Summary of changes:
 libgnucash/app-utils/test/test-autoclear.cpp | 69 ++++++++++++++++++++++++++++
 1 file changed, 69 insertions(+)



More information about the gnucash-changes mailing list