gnucash stable: [gtest-gnc-numeric] add operator comparisons

Christopher Lam clam at code.gnucash.org
Sun Jan 28 19:57:45 EST 2024


Updated	 via  https://github.com/Gnucash/gnucash/commit/928f9245 (commit)
	from  https://github.com/Gnucash/gnucash/commit/a3015443 (commit)



commit 928f9245e6f2d9cf5588a21e8e37a713ea665573
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Jan 28 10:26:52 2024 +0800

    [gtest-gnc-numeric] add operator comparisons
    
    with example int64 numbers

diff --git a/libgnucash/engine/test/gtest-gnc-numeric.cpp b/libgnucash/engine/test/gtest-gnc-numeric.cpp
index ac6b1fe964..7690933be2 100644
--- a/libgnucash/engine/test/gtest-gnc-numeric.cpp
+++ b/libgnucash/engine/test/gtest-gnc-numeric.cpp
@@ -427,6 +427,28 @@ TEST(gncnumeric_functions, test_cmp)
     EXPECT_EQ(1, a.cmp(INT64_C(12500)));
 }
 
+TEST(gncnumeric_functions, test_operators)
+{
+    GncNumeric a(123456789, 9876), b(567894321, 6543);
+    auto c = a;
+    EXPECT_TRUE (b > a);
+    EXPECT_TRUE (a < b);
+    EXPECT_TRUE (b >= a);
+    EXPECT_TRUE (a <= b);
+    EXPECT_TRUE (a == c);
+    EXPECT_TRUE (b != c);
+
+    auto zero = INT64_C(0);
+    EXPECT_TRUE (b > zero);
+    EXPECT_TRUE (zero < a);
+    EXPECT_TRUE (b >= zero);
+    EXPECT_TRUE (zero <= b);
+    EXPECT_TRUE (a != zero);
+    EXPECT_TRUE (zero != a);
+    EXPECT_FALSE (a == zero);
+    EXPECT_FALSE (zero == a);
+}
+
 TEST(gncnumeric_functions, test_invert)
 {
     GncNumeric a(123456789, 9876), b, c;



Summary of changes:
 libgnucash/engine/test/gtest-gnc-numeric.cpp | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)



More information about the gnucash-changes mailing list