From 6f7e1102dbcb0a51d9ed813877f8ddd6ce4b6773 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Fri, 20 Aug 2021 18:34:41 +0200 Subject: [PATCH] abacus: bignum: add default constructor --- src/bignum/bignum.hh | 2 +- tests/unit/bignum.cc | 32 ++++++++++++++++---------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/bignum/bignum.hh b/src/bignum/bignum.hh index ab1699f..8774eb0 100644 --- a/src/bignum/bignum.hh +++ b/src/bignum/bignum.hh @@ -9,7 +9,7 @@ namespace abacus::bignum { class BigNum { public: - explicit BigNum(std::int64_t number); + explicit BigNum(std::int64_t number = 0); friend std::ostream& operator<<(std::ostream& out, BigNum const& num) { return num.dump(out); diff --git a/tests/unit/bignum.cc b/tests/unit/bignum.cc index 45515e4..65ff7d5 100644 --- a/tests/unit/bignum.cc +++ b/tests/unit/bignum.cc @@ -18,41 +18,41 @@ TEST(BigNum, dump) { 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"); + EXPECT_EQ(to_str(zero), "0"); + EXPECT_EQ(to_str(one), "1"); + EXPECT_EQ(to_str(minus_one), "-1"); + EXPECT_EQ(to_str(forty_two), "42"); } TEST(BigNum, equality) { auto const zero = BigNum(0); auto const one = BigNum(1); - ASSERT_EQ(zero, zero); - ASSERT_EQ(one, one); - ASSERT_NE(zero, one); + EXPECT_EQ(zero, zero); + EXPECT_EQ(one, one); + EXPECT_NE(zero, one); } TEST(BigNum, comparisons) { auto const zero = BigNum(0); auto const one = BigNum(1); - ASSERT_LT(zero, one); - ASSERT_LE(zero, one); - ASSERT_LE(zero, zero); + EXPECT_LT(zero, one); + EXPECT_LE(zero, one); + EXPECT_LE(zero, zero); - ASSERT_GT(one, zero); - ASSERT_GE(one, zero); - ASSERT_GE(one, one); + EXPECT_GT(one, zero); + EXPECT_GE(one, zero); + EXPECT_GE(one, one); } TEST(BigNum, unary) { auto const zero = BigNum(0); auto const one = BigNum(1); - ASSERT_EQ(zero, -zero); - ASSERT_NE(one, -one); + EXPECT_EQ(zero, -zero); + EXPECT_NE(one, -one); auto const minus_one = BigNum(-1); - ASSERT_EQ(minus_one, -one); + EXPECT_EQ(minus_one, -one); }