From 7c1b3d302ec87392b906515d7309f56d63e81ff8 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Fri, 20 Aug 2021 17:22:21 +0200 Subject: [PATCH] tests: unit: add bignum tests --- tests/unit/base.cc | 5 ----- tests/unit/bignum.cc | 27 +++++++++++++++++++++++++++ tests/unit/meson.build | 3 ++- 3 files changed, 29 insertions(+), 6 deletions(-) delete mode 100644 tests/unit/base.cc create mode 100644 tests/unit/bignum.cc diff --git a/tests/unit/base.cc b/tests/unit/base.cc deleted file mode 100644 index 4573678..0000000 --- a/tests/unit/base.cc +++ /dev/null @@ -1,5 +0,0 @@ -#include - -TEST(misc, passing) { - ASSERT_EQ(1, 1); -} diff --git a/tests/unit/bignum.cc b/tests/unit/bignum.cc new file mode 100644 index 0000000..e7dfdc6 --- /dev/null +++ b/tests/unit/bignum.cc @@ -0,0 +1,27 @@ +#include + +#include "bignum.hh" + +using namespace abacus::bignum; + +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); +} + +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); + + ASSERT_GT(one, zero); + ASSERT_GE(one, zero); + ASSERT_GE(one, one); +} diff --git a/tests/unit/meson.build b/tests/unit/meson.build index e866754..db8eddd 100644 --- a/tests/unit/meson.build +++ b/tests/unit/meson.build @@ -6,13 +6,14 @@ gtest = dependency( if gtest.found() unit_test_sources = files( - 'base.cc', + 'bignum.cc', ) unit_tests = executable( 'unit_tests', sources: unit_test_sources, dependencies: [ + bignum, gtest, ], )