abacus: bignum: fix order comparisons
This is a pretty big oversight...
This commit is contained in:
parent
5bc3963317
commit
3397bf4310
|
@ -16,6 +16,10 @@ namespace {
|
|||
auto static constexpr BASE = 10;
|
||||
|
||||
bool do_less_than(digits_type const& lhs, digits_type const& rhs) {
|
||||
if (lhs.size() != rhs.size()) {
|
||||
return lhs.size() < rhs.size();
|
||||
}
|
||||
|
||||
return std::lexicographical_compare(lhs.rbegin(), lhs.rend(), rhs.rbegin(),
|
||||
rhs.rend());
|
||||
}
|
||||
|
|
|
@ -60,6 +60,14 @@ TEST(BigNum, comparisons) {
|
|||
EXPECT_GE(one, one);
|
||||
}
|
||||
|
||||
TEST(BigNum, comparisons_digits) {
|
||||
auto const nine = BigNum(9);
|
||||
auto const ten = BigNum(10);
|
||||
|
||||
EXPECT_LT(nine, ten);
|
||||
EXPECT_GT(ten, nine);
|
||||
}
|
||||
|
||||
TEST(BigNum, unary) {
|
||||
auto const zero = BigNum(0);
|
||||
auto const one = BigNum(1);
|
||||
|
|
Loading…
Reference in a new issue