浏览代码

Since the bigdecimal tests for int values are largely identical to the ones for biginteger, combine them as a typed test.

Fix other miscellaneous weirdnesses.
- No default construct for bigdecimal
- Includes
- Project settings
Sam Jaffe 7 年之前
父节点
当前提交
43ca1aab4f

+ 7 - 16
bigdecimal.xcodeproj/project.pbxproj

@@ -12,10 +12,10 @@
 		CD2EC1C21F0BCCA700D49DF5 /* bignum_helper.h in Headers */ = {isa = PBXBuildFile; fileRef = CD2EC1C11F0BCCA700D49DF5 /* bignum_helper.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		CD2EC1C51F0BCCBF00D49DF5 /* bignum_helper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD2EC1C41F0BCCBF00D49DF5 /* bignum_helper.cpp */; };
 		CD47694820AFA150009AA8BB /* libbigdecimal.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CD5FB2861F06EFEA005A0D61 /* libbigdecimal.dylib */; };
-		CD47697720AFA6B2009AA8BB /* biginteger_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD47697520AFA6B2009AA8BB /* biginteger_test.cpp */; };
 		CD47698920AFACAE009AA8BB /* GoogleMock.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CD47698020AFAC9C009AA8BB /* GoogleMock.framework */; };
-		CD47698A20AFB48C009AA8BB /* bigdecimal_integral_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD3B82A31F114E1C0081E9FC /* bigdecimal_integral_test.cpp */; };
+		CD47698A20AFB48C009AA8BB /* bignumber_integral_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD3B82A31F114E1C0081E9FC /* bignumber_integral_test.cpp */; };
 		CD47698B20AFB4FD009AA8BB /* bigdecimal_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD14CA711F0DA9FC0091A168 /* bigdecimal_test.cpp */; };
+		CD47698C20B03C5E009AA8BB /* biginteger_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD47697520AFA6B2009AA8BB /* biginteger_test.cpp */; };
 		CD5FB2911F06EFEF005A0D61 /* biginteger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD5FB2801F06EF7D005A0D61 /* biginteger.cpp */; };
 		CD5FB2921F06EFF2005A0D61 /* biginteger.h in Headers */ = {isa = PBXBuildFile; fileRef = CD5FB27F1F06EF70005A0D61 /* biginteger.h */; settings = {ATTRIBUTES = (Public, ); }; };
 /* End PBXBuildFile section */
@@ -71,7 +71,7 @@
 		CD2EC1BE1F0AF3B800D49DF5 /* bigdecimal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = bigdecimal.cpp; sourceTree = "<group>"; };
 		CD2EC1C11F0BCCA700D49DF5 /* bignum_helper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bignum_helper.h; sourceTree = "<group>"; };
 		CD2EC1C41F0BCCBF00D49DF5 /* bignum_helper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = bignum_helper.cpp; sourceTree = "<group>"; };
-		CD3B82A31F114E1C0081E9FC /* bigdecimal_integral_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = bigdecimal_integral_test.cpp; sourceTree = "<group>"; };
+		CD3B82A31F114E1C0081E9FC /* bignumber_integral_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = bignumber_integral_test.cpp; sourceTree = "<group>"; };
 		CD47694320AFA150009AA8BB /* bigdecimal-test.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "bigdecimal-test.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
 		CD47694720AFA150009AA8BB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
 		CD47697520AFA6B2009AA8BB /* biginteger_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = biginteger_test.cpp; sourceTree = "<group>"; };
@@ -165,7 +165,7 @@
 			isa = PBXGroup;
 			children = (
 				CD47697520AFA6B2009AA8BB /* biginteger_test.cpp */,
-				CD3B82A31F114E1C0081E9FC /* bigdecimal_integral_test.cpp */,
+				CD3B82A31F114E1C0081E9FC /* bignumber_integral_test.cpp */,
 				CD14CA711F0DA9FC0091A168 /* bigdecimal_test.cpp */,
 			);
 			path = test;
@@ -310,9 +310,9 @@
 			isa = PBXSourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
-				CD47697720AFA6B2009AA8BB /* biginteger_test.cpp in Sources */,
 				CD47698B20AFB4FD009AA8BB /* bigdecimal_test.cpp in Sources */,
-				CD47698A20AFB48C009AA8BB /* bigdecimal_integral_test.cpp in Sources */,
+				CD47698A20AFB48C009AA8BB /* bignumber_integral_test.cpp in Sources */,
+				CD47698C20B03C5E009AA8BB /* biginteger_test.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -345,10 +345,7 @@
 		CD47694C20AFA150009AA8BB /* Debug */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				CLANG_ENABLE_CODE_COVERAGE = NO;
 				COMBINE_HIDPI_IMAGES = YES;
-				GCC_GENERATE_TEST_COVERAGE_FILES = NO;
-				GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = NO;
 				INFOPLIST_FILE = "bigdecimal-test/Info.plist";
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
 				PRODUCT_BUNDLE_IDENTIFIER = "leumasjaffe.bigdecimal-test";
@@ -359,10 +356,7 @@
 		CD47694D20AFA150009AA8BB /* Release */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				CLANG_ENABLE_CODE_COVERAGE = NO;
 				COMBINE_HIDPI_IMAGES = YES;
-				GCC_GENERATE_TEST_COVERAGE_FILES = NO;
-				GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = NO;
 				INFOPLIST_FILE = "bigdecimal-test/Info.plist";
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
 				PRODUCT_BUNDLE_IDENTIFIER = "leumasjaffe.bigdecimal-test";
@@ -394,8 +388,6 @@
 				ENABLE_TESTABILITY = YES;
 				GCC_C_LANGUAGE_STANDARD = gnu99;
 				GCC_DYNAMIC_NO_PIC = NO;
-				GCC_GENERATE_TEST_COVERAGE_FILES = NO;
-				GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES;
 				GCC_NO_COMMON_BLOCKS = YES;
 				GCC_OPTIMIZATION_LEVEL = 0;
 				GCC_PREPROCESSOR_DEFINITIONS = (
@@ -440,8 +432,6 @@
 				ENABLE_NS_ASSERTIONS = NO;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
 				GCC_C_LANGUAGE_STANDARD = gnu99;
-				GCC_GENERATE_TEST_COVERAGE_FILES = NO;
-				GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES;
 				GCC_NO_COMMON_BLOCKS = YES;
 				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
 				GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
@@ -493,6 +483,7 @@
 				CD47694D20AFA150009AA8BB /* Release */,
 			);
 			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
 		};
 		CD5FB26C1F06EEAF005A0D61 /* Build configuration list for PBXProject "bigdecimal" */ = {
 			isa = XCConfigurationList;

+ 2 - 1
include/bigdecimal.h

@@ -7,7 +7,8 @@
 
 #pragma once
 
-#include "biginteger.h"
+#include <string>
+#include <vector>
 
 namespace math {
   class bigdecimal {

+ 2 - 0
src/bigdecimal.cpp

@@ -62,6 +62,8 @@ static void read_segment(bigdecimal::data_type & data, char const * number, size
   }
 }
 
+bigdecimal::bigdecimal() : is_negative(false), data({0}) {}
+
 bigdecimal::bigdecimal(bool neg, uint64_t value) :
 is_negative(neg) {
   uint64_t next{0};

+ 1 - 1
src/biginteger.cpp

@@ -22,7 +22,7 @@ static void read(int32_t & dst, char const * & str, size_t len) {
 }
 
 biginteger::biginteger()
-: biginteger(false, 0) {}
+: is_negative(false), data({0}) {}
 
 biginteger::biginteger(char const * number)
 : is_negative(number[0] == '-') {

+ 0 - 170
test/bigdecimal_integral_test.cpp

@@ -1,170 +0,0 @@
-//
-//  bigdecimal_integral_test.cpp
-//  bigdecimal
-//
-//  Created by Sam Jaffe on 5/18/18.
-//
-
-#include <gmock/gmock.h>
-
-#include "bigdecimal.h"
-
-TEST(BigDecimal_Integral, ConstructFromStringIsSameValueAsFromInt) {
-  EXPECT_THAT(math::bigdecimal("1000000"),
-              math::bigdecimal(1000000));
-}
-
-TEST(BigDecimal_Integral, AddPastBounds) {
-  math::bigdecimal bi{999999999ULL};
-  EXPECT_THAT((bi+1).to_string(), "1000000000");
-}
-
-TEST(BigDecimal_Integral, AddReciprocalIsZero) {
-  math::bigdecimal bi{1000};
-  EXPECT_THAT((bi+(-bi)).to_string(), "0");
-}
-
-TEST(BigDecimal_Integral, AddNegativeLargerGivesNegative) {
-  math::bigdecimal bi{1000};
-  EXPECT_THAT((bi+(-1001)).to_string(), "-1");
-}
-
-TEST(BigDecimal_Integral, AddNegativeSmallerGivesPositive) {
-  math::bigdecimal bi{1000};
-  EXPECT_THAT((bi+(-999)).to_string(), "1");
-}
-
-TEST(BigDecimal_Integral, SubSelfIsZero) {
-  math::bigdecimal bi{1000};
-  EXPECT_THAT((bi-bi).to_string(), "0");
-}
-
-TEST(BigDecimal_Integral, NegativeMinusNegativeIncreateAbs) {
-  math::bigdecimal bi{-1000};
-  EXPECT_THAT((bi-100).to_string(), "-1100");
-}
-
-TEST(BigDecimal_Integral, SubLargerGivesNegative) {
-  math::bigdecimal bi{1000};
-  EXPECT_THAT((bi-1001).to_string(), "-1");
-}
-
-TEST(BigDecimal_Integral, SubSmallerGivesPositive) {
-  math::bigdecimal bi{1000};
-  EXPECT_THAT((bi-999).to_string(), "1");
-}
-
-TEST(BigDecimal_Integral, SubUnderflowBorrows) {
-  math::bigdecimal bi{1000000000ULL};
-  EXPECT_THAT((bi-1).to_string(), "999999999");
-}
-
-TEST(BigDecimal_Integral, MultiplyZeroReturnsZero) {
-  auto &ZERO =  math::bigdecimal::ZERO;
-  math::bigdecimal bi{999999999ULL};
-  EXPECT_THAT(bi*ZERO, ZERO);
-  EXPECT_THAT(ZERO*bi, ZERO);
-}
-
-TEST(BigDecimal_Integral, MultiplyOneReturnsValue) {
-  auto &ONE =  math::bigdecimal::ONE;
-  math::bigdecimal bi{999999999ULL};
-  EXPECT_THAT((bi*ONE).to_string(), "999999999");
-  EXPECT_THAT((ONE*bi).to_string(), "999999999");
-}
-
-TEST(BigDecimal_Integral, MultiplyNegativeOneReturnsInverse) {
-  auto &NEGATIVE_ONE =  math::bigdecimal::NEGATIVE_ONE;
-  math::bigdecimal bi{999999999ULL};
-  EXPECT_THAT((bi*NEGATIVE_ONE).to_string(), "-999999999");
-  EXPECT_THAT((NEGATIVE_ONE*bi).to_string(), "-999999999");
-}
-
-TEST(BigDecimal_Integral, MultiplyOverflowsIntoNextCell) {
-  math::bigdecimal bi{999999999ULL};
-  EXPECT_THAT((bi*bi).to_string(), "999999998000000001");
-}
-
-TEST(BigDecimal_Integral, MultiplyCarryIntoNextCell) {
-  math::bigdecimal bi{999999999ULL};
-  math::bigdecimal big{bi*bi};
-  EXPECT_THAT((big*big).to_string(),
-                   "999999996000000005999999996000000001");
-}
-
-TEST(BigDecimal_Integral, MultiplyNoOverflow) {
-  math::bigdecimal bi{1000};
-  EXPECT_THAT((bi*bi).to_string(), "1000000");
-}
-
-TEST(BigDecimal_Integral, DivideByZeroThrows) {
-  auto &ZERO =  math::bigdecimal::ZERO;
-  math::bigdecimal bi{1000};
-  EXPECT_THROW(bi/ZERO, std::domain_error);
-}
-
-TEST(BigDecimal_Integral, DivideByOneReturnsValue) {
-  auto &ONE =  math::bigdecimal::ONE;
-  math::bigdecimal bi{1000};
-  EXPECT_THAT(bi/ONE, bi);
-}
-
-TEST(BigDecimal_Integral, DivideByNegativeOneReturnsInverse) {
-  auto &NEGATIVE_ONE =  math::bigdecimal::NEGATIVE_ONE;
-  math::bigdecimal bi{1000};
-  EXPECT_THAT((bi/NEGATIVE_ONE).to_string(), "-1000");
-}
-
-TEST(BigDecimal_Integral, DivisionWithMultipleMultSubSteps) {
-  math::bigdecimal bi{1112};
-  EXPECT_THAT((bi/2).to_string(), "556");
-}
-
-TEST(BigDecimal_Integral, DivisionDroppingNumberOfCells) {
-  math::bigdecimal bi{1000000000ULL};
-  EXPECT_THAT((bi/2).to_string(), "500000000");
-}
-
-TEST(BigDecimal_Integral, DivisionByBiggerNumberIsZero) {
-  math::bigdecimal bi{1000ULL};
-  EXPECT_THAT((bi/1001).to_string(), "0");
-}
-
-TEST(BigDecimal_Integral, DivisionWithLargeNumbers) {
-  math::bigdecimal big{"999999998000000001"};
-  EXPECT_THAT(big.to_string(), "999999998000000001");
-  EXPECT_THAT((big/999999999ULL).to_string(),
-                   "999999999");
-}
-//
-//  TEST(BigDecimal_Integral, ModuloZeroThrows) {
-//    math::bigdecimal bi{1000};
-//    EXPECT_THROW(bi%0, std::domain_error);
-//  }
-//
-//  TEST(BigDecimal_Integral, ModuloBiggerIsSameValue) {
-//    math::bigdecimal bi{1000};
-//    EXPECT_THAT(bi%2000, bi);
-//  }
-//
-//  TEST(BigDecimal_Integral, ModuloSameNumberIsZero) {
-//    math::bigdecimal bi{1000};
-//    EXPECT_THAT(bi%1000, 0);
-//  }
-//
-//  TEST(BigDecimal_Integral, ModuloDivisorIsZero) {
-//    math::bigdecimal bi{1000};
-//    EXPECT_THAT(bi%100, 0);
-//  }
-//
-//  TEST(BigDecimal_Integral, ModuloDiffSignIsInverseElement) {
-//    math::bigdecimal bi{1000};
-//    math::bigdecimal mod{13};
-//    EXPECT_THAT((bi%mod)+((-bi)%mod), mod);
-//  }
-//
-//  TEST(BigDecimal_Integral, ModuloNegativesIsNegative) {
-//    math::bigdecimal bi{1000};
-//    math::bigdecimal mod{13};
-//    EXPECT_THAT((bi%mod), -((-bi)%(-mod)));
-//  }

+ 0 - 127
test/biginteger_test.cpp

@@ -9,133 +9,6 @@
 
 #include "biginteger.h"
 
-TEST(BigInteger, ConstructFromStringIsSameValueAsFromInt) {
-  EXPECT_THAT(math::biginteger("1000000"),
-              math::biginteger(1000000));
-}
-
-TEST(BigInteger, AddPastBounds) {
-  math::biginteger bi{999999999ULL};
-  EXPECT_THAT((bi+1).to_string(), "1000000000");
-}
-
-TEST(BigInteger, AddReciprocalIsZero) {
-  math::biginteger bi{1000};
-  EXPECT_THAT((bi+(-bi)).to_string(), "0");
-}
-
-TEST(BigInteger, AddNegativeLargerGivesNegative) {
-  math::biginteger bi{1000};
-  EXPECT_THAT((bi+(-1001)).to_string(), "-1");
-}
-
-TEST(BigInteger, AddNegativeSmallerGivesPositive) {
-  math::biginteger bi{1000};
-  EXPECT_THAT((bi+(-999)).to_string(), "1");
-}
-
-TEST(BigInteger, SubSelfIsZero) {
-  math::biginteger bi{1000};
-  EXPECT_THAT((bi-bi).to_string(), "0");
-}
-
-TEST(BigInteger, NegativeMinusNegativeIncreateAbs) {
-  math::biginteger bi{-1000};
-  EXPECT_THAT((bi-100).to_string(), "-1100");
-}
-
-TEST(BigInteger, SubLargerGivesNegative) {
-  math::biginteger bi{1000};
-  EXPECT_THAT((bi-1001).to_string(), "-1");
-}
-
-TEST(BigInteger, SubSmallerGivesPositive) {
-  math::biginteger bi{1000};
-  EXPECT_THAT((bi-999).to_string(), "1");
-}
-
-TEST(BigInteger, SubUnderflowBorrows) {
-  math::biginteger bi{1000000000ULL};
-  EXPECT_THAT((bi-1).to_string(), "999999999");
-}
-
-TEST(BigInteger, MultiplyZeroReturnsZero) {
-  auto &ZERO =  math::biginteger::ZERO;
-  math::biginteger bi{999999999ULL};
-  EXPECT_THAT(bi*ZERO, ZERO);
-  EXPECT_THAT(ZERO*bi, ZERO);
-}
-
-TEST(BigInteger, MultiplyOneReturnsValue) {
-  auto &ONE =  math::biginteger::ONE;
-  math::biginteger bi{999999999ULL};
-  EXPECT_THAT((bi*ONE).to_string(), "999999999");
-  EXPECT_THAT((ONE*bi).to_string(), "999999999");
-}
-
-TEST(BigInteger, MultiplyNegativeOneReturnsInverse) {
-  auto &NEGATIVE_ONE =  math::biginteger::NEGATIVE_ONE;
-  math::biginteger bi{999999999ULL};
-  EXPECT_THAT((bi*NEGATIVE_ONE).to_string(), "-999999999");
-  EXPECT_THAT((NEGATIVE_ONE*bi).to_string(), "-999999999");
-}
-
-TEST(BigInteger, MultiplyOverflowsIntoNextCell) {
-  math::biginteger bi{999999999ULL};
-  EXPECT_THAT((bi*bi).to_string(), "999999998000000001");
-}
-
-TEST(BigInteger, MultiplyCarryIntoNextCell) {
-  math::biginteger bi{999999999ULL};
-  math::biginteger big{bi*bi};
-  EXPECT_THAT((big*big).to_string(),
-                   "999999996000000005999999996000000001");
-}
-
-TEST(BigInteger, MultiplyNoOverflow) {
-  math::biginteger bi{1000};
-  EXPECT_THAT((bi*bi).to_string(), "1000000");
-}
-
-TEST(BigInteger, DivideByZeroThrows) {
-  auto &ZERO =  math::biginteger::ZERO;
-  math::biginteger bi{1000};
-  EXPECT_THROW(bi/ZERO, std::domain_error);
-}
-
-TEST(BigInteger, DivideByOneReturnsValue) {
-  auto &ONE =  math::biginteger::ONE;
-  math::biginteger bi{1000};
-  EXPECT_THAT(bi/ONE, bi);
-}
-
-TEST(BigInteger, DivideByNegativeOneReturnsInverse) {
-  auto &NEGATIVE_ONE =  math::biginteger::NEGATIVE_ONE;
-  math::biginteger bi{1000};
-  EXPECT_THAT((bi/NEGATIVE_ONE).to_string(), "-1000");
-}
-
-TEST(BigInteger, DivisionWithMultipleMultSubSteps) {
-  math::biginteger bi{1112};
-  EXPECT_THAT((bi/2).to_string(), "556");
-}
-
-TEST(BigInteger, DivisionDroppingNumberOfCells) {
-  math::biginteger bi{1000000000ULL};
-  EXPECT_THAT((bi/2).to_string(), "500000000");
-}
-
-TEST(BigInteger, DivisionByBiggerNumberIsZero) {
-  math::biginteger bi{1000ULL};
-  EXPECT_THAT((bi/1001).to_string(), "0");
-}
-
-TEST(BigInteger, DivisionWithLargeNumbers) {
-  math::biginteger big{"999999998000000001"};
-  EXPECT_THAT(big.to_string(), "999999998000000001");
-  EXPECT_THAT((big/999999999ULL).to_string(), "999999999");
-}
-
 TEST(BigInteger, ModuloZeroThrows) {
   math::biginteger bi{1000};
   EXPECT_THROW(bi%0, std::domain_error);

+ 186 - 0
test/bignumber_integral_test.cpp

@@ -0,0 +1,186 @@
+//
+//  bigdecimal_integral_test.cpp
+//  bigdecimal
+//
+//  Created by Sam Jaffe on 5/18/18.
+//
+
+#include <gmock/gmock.h>
+
+#include "biginteger.h"
+#include "bigdecimal.h"
+
+template <typename T>
+class BigIntLikeTest : public testing::Test {
+public:
+  T typeget_;
+};
+#define BigNumber decltype(this->typeget_)
+
+typedef testing::Types<math::biginteger, math::bigdecimal> IntLikeBigNumbers;
+TYPED_TEST_CASE(BigIntLikeTest, IntLikeBigNumbers);
+
+TYPED_TEST(BigIntLikeTest, DefaultConstructorCreatesZero) {
+  EXPECT_THAT(BigNumber(), 0);
+  EXPECT_THAT(BigNumber().to_string(), "0");
+}
+
+TYPED_TEST(BigIntLikeTest, ConstructFromStringIsSameValueAsFromInt) {
+  EXPECT_THAT(BigNumber("1000000"),
+              BigNumber(1000000));
+}
+
+TYPED_TEST(BigIntLikeTest, AddPastBounds) {
+  BigNumber bi{999999999ULL};
+  EXPECT_THAT((bi+1).to_string(), "1000000000");
+}
+
+TYPED_TEST(BigIntLikeTest, AddReciprocalIsZero) {
+  BigNumber bi{1000};
+  EXPECT_THAT((bi+(-bi)).to_string(), "0");
+}
+
+TYPED_TEST(BigIntLikeTest, AddNegativeLargerGivesNegative) {
+  BigNumber bi{1000};
+  EXPECT_THAT((bi+(-1001)).to_string(), "-1");
+}
+
+TYPED_TEST(BigIntLikeTest, AddNegativeSmallerGivesPositive) {
+  BigNumber bi{1000};
+  EXPECT_THAT((bi+(-999)).to_string(), "1");
+}
+
+TYPED_TEST(BigIntLikeTest, SubSelfIsZero) {
+  BigNumber bi{1000};
+  EXPECT_THAT((bi-bi).to_string(), "0");
+}
+
+TYPED_TEST(BigIntLikeTest, NegativeMinusNegativeIncreateAbs) {
+  BigNumber bi{-1000};
+  EXPECT_THAT((bi-100).to_string(), "-1100");
+}
+
+TYPED_TEST(BigIntLikeTest, SubLargerGivesNegative) {
+  BigNumber bi{1000};
+  EXPECT_THAT((bi-1001).to_string(), "-1");
+}
+
+TYPED_TEST(BigIntLikeTest, SubSmallerGivesPositive) {
+  BigNumber bi{1000};
+  EXPECT_THAT((bi-999).to_string(), "1");
+}
+
+TYPED_TEST(BigIntLikeTest, SubUnderflowBorrows) {
+  BigNumber bi{1000000000ULL};
+  EXPECT_THAT((bi-1).to_string(), "999999999");
+}
+
+TYPED_TEST(BigIntLikeTest, MultiplyZeroReturnsZero) {
+  auto &ZERO =  BigNumber::ZERO;
+  BigNumber bi{999999999ULL};
+  EXPECT_THAT(bi*ZERO, ZERO);
+  EXPECT_THAT(ZERO*bi, ZERO);
+}
+
+TYPED_TEST(BigIntLikeTest, MultiplyOneReturnsValue) {
+  auto &ONE =  BigNumber::ONE;
+  BigNumber bi{999999999ULL};
+  EXPECT_THAT((bi*ONE).to_string(), "999999999");
+  EXPECT_THAT((ONE*bi).to_string(), "999999999");
+}
+
+TYPED_TEST(BigIntLikeTest, MultiplyNegativeOneReturnsInverse) {
+  auto &NEGATIVE_ONE =  BigNumber::NEGATIVE_ONE;
+  BigNumber bi{999999999ULL};
+  EXPECT_THAT((bi*NEGATIVE_ONE).to_string(), "-999999999");
+  EXPECT_THAT((NEGATIVE_ONE*bi).to_string(), "-999999999");
+}
+
+TYPED_TEST(BigIntLikeTest, MultiplyOverflowsIntoNextCell) {
+  BigNumber bi{999999999ULL};
+  EXPECT_THAT((bi*bi).to_string(), "999999998000000001");
+}
+
+TYPED_TEST(BigIntLikeTest, MultiplyCarryIntoNextCell) {
+  BigNumber bi{999999999ULL};
+  BigNumber big{bi*bi};
+  EXPECT_THAT((big*big).to_string(),
+                   "999999996000000005999999996000000001");
+}
+
+TYPED_TEST(BigIntLikeTest, MultiplyNoOverflow) {
+  BigNumber bi{1000};
+  EXPECT_THAT((bi*bi).to_string(), "1000000");
+}
+
+TYPED_TEST(BigIntLikeTest, DivideByZeroThrows) {
+  auto &ZERO =  BigNumber::ZERO;
+  BigNumber bi{1000};
+  EXPECT_THROW(bi/ZERO, std::domain_error);
+}
+
+TYPED_TEST(BigIntLikeTest, DivideByOneReturnsValue) {
+  auto &ONE =  BigNumber::ONE;
+  BigNumber bi{1000};
+  EXPECT_THAT(bi/ONE, bi);
+}
+
+TYPED_TEST(BigIntLikeTest, DivideByNegativeOneReturnsInverse) {
+  auto &NEGATIVE_ONE =  BigNumber::NEGATIVE_ONE;
+  BigNumber bi{1000};
+  EXPECT_THAT((bi/NEGATIVE_ONE).to_string(), "-1000");
+}
+
+TYPED_TEST(BigIntLikeTest, DivisionWithMultipleMultSubSteps) {
+  BigNumber bi{1112};
+  EXPECT_THAT((bi/2).to_string(), "556");
+}
+
+TYPED_TEST(BigIntLikeTest, DivisionDroppingNumberOfCells) {
+  BigNumber bi{1000000000ULL};
+  EXPECT_THAT((bi/2).to_string(), "500000000");
+}
+
+TYPED_TEST(BigIntLikeTest, DivisionByBiggerNumberIsZero) {
+  BigNumber bi{1000ULL};
+  EXPECT_THAT((bi/1001).to_string(), "0");
+}
+
+TYPED_TEST(BigIntLikeTest, DivisionWithLargeNumbers) {
+  BigNumber big{"999999998000000001"};
+  EXPECT_THAT(big.to_string(), "999999998000000001");
+  EXPECT_THAT((big/999999999ULL).to_string(),
+                   "999999999");
+}
+//
+//  TYPED_TEST(BigIntLikeTest, ModuloZeroThrows) {
+//    BigNumber bi{1000};
+//    EXPECT_THROW(bi%0, std::domain_error);
+//  }
+//
+//  TYPED_TEST(BigIntLikeTest, ModuloBiggerIsSameValue) {
+//    BigNumber bi{1000};
+//    EXPECT_THAT(bi%2000, bi);
+//  }
+//
+//  TYPED_TEST(BigIntLikeTest, ModuloSameNumberIsZero) {
+//    BigNumber bi{1000};
+//    EXPECT_THAT(bi%1000, 0);
+//  }
+//
+//  TYPED_TEST(BigIntLikeTest, ModuloDivisorIsZero) {
+//    BigNumber bi{1000};
+//    EXPECT_THAT(bi%100, 0);
+//  }
+//
+//  TYPED_TEST(BigIntLikeTest, ModuloDiffSignIsInverseElement) {
+//    BigNumber bi{1000};
+//    BigNumber mod{13};
+//    EXPECT_THAT((bi%mod)+((-bi)%mod), mod);
+//  }
+//
+//  TYPED_TEST(BigIntLikeTest, ModuloNegativesIsNegative) {
+//    BigNumber bi{1000};
+//    BigNumber mod{13};
+//    EXPECT_THAT((bi%mod), -((-bi)%(-mod)));
+//  }