Skip to content

Commit

Permalink
add operator comparisons
Browse files Browse the repository at this point in the history
GncNumeric < GncNumeric works
GncNumeric < int64 doesn't compile
  • Loading branch information
christopherlam committed Jan 28, 2024
1 parent a301544 commit f8962e7
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions libgnucash/engine/test/gtest-gnc-numeric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,25 @@ 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);

EXPECT_TRUE (b > 0);
EXPECT_TRUE (0 < a);
EXPECT_TRUE (b >= 0);
EXPECT_TRUE (0 <= b);
EXPECT_TRUE (a != 0);
EXPECT_FALSE (a == 0);
}

TEST(gncnumeric_functions, test_invert)
{
GncNumeric a(123456789, 9876), b, c;
Expand Down

0 comments on commit f8962e7

Please sign in to comment.