X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Ftests%2Farb.cpp;h=f8a74d3f3f44fc542cc7b9b84a969d25fcf42786;hp=ffbf74efeb195ef34f6247d823c444f6a5ccc3a1;hb=e0cd98bdff7f026b92f2c0e5b08639e08b98874e;hpb=b02dcbab39b8c28b9baa41436842ca9fe4ae7ffd diff --git a/src/tests/arb.cpp b/src/tests/arb.cpp index ffbf74e..f8a74d3 100644 --- a/src/tests/arb.cpp +++ b/src/tests/arb.cpp @@ -7,7 +7,7 @@ using namespace std; using namespace IPDF; -#define TEST_CASES 100 +#define TEST_CASES 10 void TestShifting(unsigned cases) @@ -87,11 +87,20 @@ void TestConstructFromDouble(unsigned cases) void TestSubtraction() { - + Arbint b(2u, 45L, 10L); + Arbint a(1u, 128L, 0L); + Arbint c(a - b); + Arbint test = -Arbint(2u, 18446744073709551533LU,9L); + Debug("%c%s - %c%s = %c%s", a.SignChar(), a.DigitStr().c_str(), b.SignChar(), b.DigitStr().c_str(), c.SignChar(), c.DigitStr().c_str()); + if (c != test) + { + Fatal("Expected %c%s, got %c%s", test.SignChar(), test.DigitStr().c_str(), c.SignChar(), c.DigitStr().c_str()); + } } int main(int argc, char ** argv) { + Debug("Shift testing..."); TestShifting(TEST_CASES); Debug("Left/Right shift testing succeeded"); @@ -104,5 +113,9 @@ int main(int argc, char ** argv) Debug("Testing construct from double"); TestConstructFromDouble(TEST_CASES); Debug("Construct from double successful"); + + Debug("Testing subtractions"); + TestSubtraction(); + Debug("Testing subtractions successful"); return 0; }