abacus: bignum: add output operator

This commit is contained in:
Bruno BELANYI 2021-08-20 18:09:28 +02:00
parent 0a5fb471e4
commit ad5092ea8d
3 changed files with 43 additions and 0 deletions

View file

@ -1,9 +1,29 @@
#include <sstream>
#include <gtest/gtest.h>
#include "bignum.hh"
using namespace abacus::bignum;
TEST(BigNum, dump) {
auto const zero = BigNum(0);
auto const one = BigNum(1);
auto const minus_one = BigNum(-1);
auto const forty_two = BigNum(42);
auto const to_str = [](auto num) {
std::stringstream str;
str << num;
return str.str();
};
ASSERT_EQ(to_str(zero), "0");
ASSERT_EQ(to_str(one), "1");
ASSERT_EQ(to_str(minus_one), "-1");
ASSERT_EQ(to_str(forty_two), "42");
}
TEST(BigNum, equality) {
auto const zero = BigNum(0);
auto const one = BigNum(1);