biginteger.t.h 743 B

1234567891011121314151617181920212223242526272829303132333435
  1. //
  2. // biginteger.t.h
  3. // bigdecimal
  4. //
  5. // Created by Sam Jaffe on 6/30/17.
  6. //
  7. #pragma once
  8. #include "biginteger.h"
  9. #include <cxxtest/TestSuite.h>
  10. class biginteger_TestSuite : public CxxTest::TestSuite {
  11. public:
  12. void testAddPastBounds() {
  13. math::biginteger bi{999999999ULL};
  14. TS_ASSERT_EQUALS((bi+1).to_string(), "1000000000");
  15. }
  16. void testAddReciprocalIsZero() {
  17. math::biginteger bi{1000};
  18. TS_ASSERT_EQUALS((bi+(-bi)).to_string(), "0");
  19. }
  20. void testAddNegativeLargerGivesNegative() {
  21. math::biginteger bi{1000};
  22. TS_ASSERT_EQUALS((bi+(-1001)).to_string(), "-1");
  23. }
  24. void testAddNegativeSmallerGivesPositive() {
  25. math::biginteger bi{1000};
  26. TS_ASSERT_EQUALS((bi+(-999)).to_string(), "1");
  27. }
  28. };