tests: unit: add bignum tests

This commit is contained in:
Bruno BELANYI 2021-08-20 17:22:21 +02:00
parent 2600eb2ba7
commit 7c1b3d302e
3 changed files with 29 additions and 6 deletions

View file

@ -1,5 +0,0 @@
#include <gtest/gtest.h>
TEST(misc, passing) {
ASSERT_EQ(1, 1);
}

27
tests/unit/bignum.cc Normal file
View file

@ -0,0 +1,27 @@
#include <gtest/gtest.h>
#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);
}

View file

@ -6,13 +6,14 @@ gtest = dependency(
if gtest.found() if gtest.found()
unit_test_sources = files( unit_test_sources = files(
'base.cc', 'bignum.cc',
) )
unit_tests = executable( unit_tests = executable(
'unit_tests', 'unit_tests',
sources: unit_test_sources, sources: unit_test_sources,
dependencies: [ dependencies: [
bignum,
gtest, gtest,
], ],
) )