From 7ed000495cf44cd39fb164d5dcd98a22ac64ae78 Mon Sep 17 00:00:00 2001 From: Ed Hennis Date: Wed, 3 Jun 2026 21:44:41 -0400 Subject: [PATCH] Add test cases to testRelationals to show the problem --- src/test/basics/Number_test.cpp | 57 ++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/src/test/basics/Number_test.cpp b/src/test/basics/Number_test.cpp index 81019970ad..a688aaceb0 100644 --- a/src/test/basics/Number_test.cpp +++ b/src/test/basics/Number_test.cpp @@ -1386,10 +1386,59 @@ public: testRelationals() { testcase << "test_relationals " << to_string(Number::getMantissaScale()); - BEAST_EXPECT(!(Number{100} < Number{10})); - BEAST_EXPECT(Number{100} > Number{10}); - BEAST_EXPECT(Number{100} >= Number{10}); - BEAST_EXPECT(!(Number{100} <= Number{10})); + + { + // Inequality test cases are + using Case = std::tuple; + auto const c = std::to_array({ + {100, 10, __LINE__}, + {50, 20, __LINE__}, + {10, -100, __LINE__}, + {100, -10, __LINE__}, + {10, -10, __LINE__}, + {100, 0, __LINE__}, + {1, 0, __LINE__}, + {0, -10, __LINE__}, + {0, -1, __LINE__}, + {-10, -100, __LINE__}, + {-20, -50, __LINE__}, + }); + + for (auto const [larger, smaller, line] : c) + { + std::stringstream ss; + ss << larger << " > " << smaller; + auto const str = ss.str(); + + expect(!(larger < smaller), str + " (<)", __FILE__, line); + expect(larger > smaller, str + " (>)", __FILE__, line); + expect(larger >= smaller, str + " (>=)", __FILE__, line); + expect(!(larger <= smaller), str + " (<=)", __FILE__, line); + } + } + + { + // Equality test cases are . Number will be compared against itself + using Case = std::pair; + auto const c = std::to_array({ + {700, __LINE__}, + {50, __LINE__}, + {1, __LINE__}, + {0, __LINE__}, + {-1, __LINE__}, + {-30, __LINE__}, + {-600, __LINE__}, + }); + for (auto const [n, line] : c) + { + auto const str = to_string(n); + + expect(!(n < n), str + " < ", __FILE__, line); + expect(!(n > n), str + " >", __FILE__, line); + expect(n >= n, str + " >=", __FILE__, line); + expect(n <= n, str + " <=", __FILE__, line); + } + } } void