瀏覽代碼

Convert to using GoogleMock for testing

Sam Jaffe 7 年之前
父節點
當前提交
dc784283ab

+ 24 - 0
bigdecimal-test/Info.plist

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>en</string>
+	<key>CFBundleExecutable</key>
+	<string>$(EXECUTABLE_NAME)</string>
+	<key>CFBundleIdentifier</key>
+	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>$(PRODUCT_NAME)</string>
+	<key>CFBundlePackageType</key>
+	<string>BNDL</string>
+	<key>CFBundleShortVersionString</key>
+	<string>1.0</string>
+	<key>CFBundleSignature</key>
+	<string>????</string>
+	<key>CFBundleVersion</key>
+	<string>1</string>
+</dict>
+</plist>

+ 191 - 157
bigdecimal.xcodeproj/project.pbxproj

@@ -8,54 +8,86 @@
 
 /* Begin PBXBuildFile section */
 		CD2EC1BC1F0AF2C300D49DF5 /* bigdecimal.h in Headers */ = {isa = PBXBuildFile; fileRef = CD2EC1BB1F0AF2C300D49DF5 /* bigdecimal.h */; };
-		CD2EC1BD1F0AF2C300D49DF5 /* bigdecimal.h in Headers */ = {isa = PBXBuildFile; fileRef = CD2EC1BB1F0AF2C300D49DF5 /* bigdecimal.h */; };
 		CD2EC1BF1F0AF3B800D49DF5 /* bigdecimal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD2EC1BE1F0AF3B800D49DF5 /* bigdecimal.cpp */; };
-		CD2EC1C01F0AF3B800D49DF5 /* bigdecimal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD2EC1BE1F0AF3B800D49DF5 /* bigdecimal.cpp */; };
 		CD2EC1C21F0BCCA700D49DF5 /* bignum_helper.h in Headers */ = {isa = PBXBuildFile; fileRef = CD2EC1C11F0BCCA700D49DF5 /* bignum_helper.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		CD2EC1C31F0BCCA700D49DF5 /* 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 */; };
-		CD2EC1C61F0BCCBF00D49DF5 /* 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 */; };
+		CD47698B20AFB4FD009AA8BB /* bigdecimal_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD14CA711F0DA9FC0091A168 /* bigdecimal_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, ); }; };
-		CD5FB2A31F06F03D005A0D61 /* biginteger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD5FB2801F06EF7D005A0D61 /* biginteger.cpp */; };
-		CD5FB2A41F06F048005A0D61 /* libbigdecimal_s.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CD5FB2981F06F030005A0D61 /* libbigdecimal_s.a */; };
-		CD5FB2A71F06F0D2005A0D61 /* bigdecimal_tc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD5FB2A61F06F0D2005A0D61 /* bigdecimal_tc.cpp */; };
 /* End PBXBuildFile section */
 
-/* Begin PBXCopyFilesBuildPhase section */
-		CD5FB26F1F06EEAF005A0D61 /* CopyFiles */ = {
-			isa = PBXCopyFilesBuildPhase;
-			buildActionMask = 2147483647;
-			dstPath = /usr/share/man/man1/;
-			dstSubfolderSpec = 0;
-			files = (
-			);
-			runOnlyForDeploymentPostprocessing = 1;
+/* Begin PBXContainerItemProxy section */
+		CD47694920AFA150009AA8BB /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = CD5FB2691F06EEAF005A0D61 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = CD5FB2851F06EFEA005A0D61;
+			remoteInfo = bigdecimal;
+		};
+		CD47697F20AFAC9C009AA8BB /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = CD47697820AFAC9C009AA8BB /* GoogleMock.xcodeproj */;
+			proxyType = 2;
+			remoteGlobalIDString = 05818F861A685AEA0072A469;
+			remoteInfo = GoogleMock;
+		};
+		CD47698120AFAC9C009AA8BB /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = CD47697820AFAC9C009AA8BB /* GoogleMock.xcodeproj */;
+			proxyType = 2;
+			remoteGlobalIDString = 05E96ABD1A68600C00204102;
+			remoteInfo = gmock;
+		};
+		CD47698320AFAC9C009AA8BB /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = CD47697820AFAC9C009AA8BB /* GoogleMock.xcodeproj */;
+			proxyType = 2;
+			remoteGlobalIDString = 05E96B1F1A68634900204102;
+			remoteInfo = gtest;
+		};
+		CD47698520AFAC9C009AA8BB /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = CD47697820AFAC9C009AA8BB /* GoogleMock.xcodeproj */;
+			proxyType = 2;
+			remoteGlobalIDString = 05818F901A685AEA0072A469;
+			remoteInfo = GoogleMockTests;
+		};
+		CD47698720AFACA8009AA8BB /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = CD47697820AFAC9C009AA8BB /* GoogleMock.xcodeproj */;
+			proxyType = 1;
+			remoteGlobalIDString = 05818F851A685AEA0072A469;
+			remoteInfo = GoogleMock;
 		};
-/* End PBXCopyFilesBuildPhase section */
+/* End PBXContainerItemProxy section */
 
 /* Begin PBXFileReference section */
-		CD14CA711F0DA9FC0091A168 /* bigdecimal.t.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bigdecimal.t.h; sourceTree = "<group>"; };
+		CD14CA711F0DA9FC0091A168 /* bigdecimal_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = bigdecimal_test.cpp; sourceTree = "<group>"; };
 		CD2EC1BB1F0AF2C300D49DF5 /* bigdecimal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bigdecimal.h; sourceTree = "<group>"; };
 		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_integer.t.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bigdecimal_integer.t.h; sourceTree = "<group>"; };
-		CD5FB2711F06EEAF005A0D61 /* bigdecimal_tc */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = bigdecimal_tc; sourceTree = BUILT_PRODUCTS_DIR; };
-		CD5FB27E1F06EF64005A0D61 /* biginteger.t.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = biginteger.t.h; sourceTree = "<group>"; };
+		CD3B82A31F114E1C0081E9FC /* bigdecimal_integral_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = bigdecimal_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>"; };
+		CD47697820AFAC9C009AA8BB /* GoogleMock.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = GoogleMock.xcodeproj; path = "../../../gmock-xcode-master/GoogleMock.xcodeproj"; sourceTree = "<group>"; };
 		CD5FB27F1F06EF70005A0D61 /* biginteger.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = biginteger.h; sourceTree = "<group>"; };
 		CD5FB2801F06EF7D005A0D61 /* biginteger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = biginteger.cpp; sourceTree = "<group>"; };
 		CD5FB2861F06EFEA005A0D61 /* libbigdecimal.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libbigdecimal.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
-		CD5FB2981F06F030005A0D61 /* libbigdecimal_s.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libbigdecimal_s.a; sourceTree = BUILT_PRODUCTS_DIR; };
-		CD5FB2A61F06F0D2005A0D61 /* bigdecimal_tc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = bigdecimal_tc.cpp; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
-		CD5FB26E1F06EEAF005A0D61 /* Frameworks */ = {
+		CD47694020AFA150009AA8BB /* Frameworks */ = {
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
-				CD5FB2A41F06F048005A0D61 /* libbigdecimal_s.a in Frameworks */,
+				CD47698920AFACAE009AA8BB /* GoogleMock.framework in Frameworks */,
+				CD47694820AFA150009AA8BB /* libbigdecimal.dylib in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -66,22 +98,36 @@
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
-		CD5FB2951F06F030005A0D61 /* Frameworks */ = {
-			isa = PBXFrameworksBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
 /* End PBXFrameworksBuildPhase section */
 
 /* Begin PBXGroup section */
+		CD47694420AFA150009AA8BB /* bigdecimal-test */ = {
+			isa = PBXGroup;
+			children = (
+				CD47694720AFA150009AA8BB /* Info.plist */,
+			);
+			path = "bigdecimal-test";
+			sourceTree = "<group>";
+		};
+		CD47697920AFAC9C009AA8BB /* Products */ = {
+			isa = PBXGroup;
+			children = (
+				CD47698020AFAC9C009AA8BB /* GoogleMock.framework */,
+				CD47698220AFAC9C009AA8BB /* gmock.framework */,
+				CD47698420AFAC9C009AA8BB /* gtest.framework */,
+				CD47698620AFAC9C009AA8BB /* GoogleMockTests.xctest */,
+			);
+			name = Products;
+			sourceTree = "<group>";
+		};
 		CD5FB2681F06EEAF005A0D61 = {
 			isa = PBXGroup;
 			children = (
+				CD47697820AFAC9C009AA8BB /* GoogleMock.xcodeproj */,
 				CD5FB27B1F06EED6005A0D61 /* include */,
 				CD5FB27C1F06EED6005A0D61 /* src */,
 				CD5FB27D1F06EED6005A0D61 /* test */,
+				CD47694420AFA150009AA8BB /* bigdecimal-test */,
 				CD5FB2721F06EEAF005A0D61 /* Products */,
 			);
 			sourceTree = "<group>";
@@ -89,9 +135,8 @@
 		CD5FB2721F06EEAF005A0D61 /* Products */ = {
 			isa = PBXGroup;
 			children = (
-				CD5FB2711F06EEAF005A0D61 /* bigdecimal_tc */,
 				CD5FB2861F06EFEA005A0D61 /* libbigdecimal.dylib */,
-				CD5FB2981F06F030005A0D61 /* libbigdecimal_s.a */,
+				CD47694320AFA150009AA8BB /* bigdecimal-test.xctest */,
 			);
 			name = Products;
 			sourceTree = "<group>";
@@ -119,10 +164,9 @@
 		CD5FB27D1F06EED6005A0D61 /* test */ = {
 			isa = PBXGroup;
 			children = (
-				CD5FB27E1F06EF64005A0D61 /* biginteger.t.h */,
-				CD3B82A31F114E1C0081E9FC /* bigdecimal_integer.t.h */,
-				CD14CA711F0DA9FC0091A168 /* bigdecimal.t.h */,
-				CD5FB2A61F06F0D2005A0D61 /* bigdecimal_tc.cpp */,
+				CD47697520AFA6B2009AA8BB /* biginteger_test.cpp */,
+				CD3B82A31F114E1C0081E9FC /* bigdecimal_integral_test.cpp */,
+				CD14CA711F0DA9FC0091A168 /* bigdecimal_test.cpp */,
 			);
 			path = test;
 			sourceTree = "<group>";
@@ -140,35 +184,27 @@
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
-		CD5FB2961F06F030005A0D61 /* Headers */ = {
-			isa = PBXHeadersBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-				CD2EC1C31F0BCCA700D49DF5 /* bignum_helper.h in Headers */,
-				CD2EC1BD1F0AF2C300D49DF5 /* bigdecimal.h in Headers */,
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
 /* End PBXHeadersBuildPhase section */
 
 /* Begin PBXNativeTarget section */
-		CD5FB2701F06EEAF005A0D61 /* bigdecimal_tc */ = {
+		CD47694220AFA150009AA8BB /* bigdecimal-test */ = {
 			isa = PBXNativeTarget;
-			buildConfigurationList = CD5FB2781F06EEAF005A0D61 /* Build configuration list for PBXNativeTarget "bigdecimal_tc" */;
+			buildConfigurationList = CD47694B20AFA150009AA8BB /* Build configuration list for PBXNativeTarget "bigdecimal-test" */;
 			buildPhases = (
-				CD5FB2A51F06F04C005A0D61 /* ShellScript */,
-				CD5FB26D1F06EEAF005A0D61 /* Sources */,
-				CD5FB26E1F06EEAF005A0D61 /* Frameworks */,
-				CD5FB26F1F06EEAF005A0D61 /* CopyFiles */,
+				CD47693F20AFA150009AA8BB /* Sources */,
+				CD47694020AFA150009AA8BB /* Frameworks */,
+				CD47694120AFA150009AA8BB /* Resources */,
 			);
 			buildRules = (
 			);
 			dependencies = (
+				CD47698820AFACA8009AA8BB /* PBXTargetDependency */,
+				CD47694A20AFA150009AA8BB /* PBXTargetDependency */,
 			);
-			name = bigdecimal_tc;
-			productName = bigdecimal;
-			productReference = CD5FB2711F06EEAF005A0D61 /* bigdecimal_tc */;
-			productType = "com.apple.product-type.tool";
+			name = "bigdecimal-test";
+			productName = "bigdecimal-test";
+			productReference = CD47694320AFA150009AA8BB /* bigdecimal-test.xctest */;
+			productType = "com.apple.product-type.bundle.unit-test";
 		};
 		CD5FB2851F06EFEA005A0D61 /* bigdecimal */ = {
 			isa = PBXNativeTarget;
@@ -187,23 +223,6 @@
 			productReference = CD5FB2861F06EFEA005A0D61 /* libbigdecimal.dylib */;
 			productType = "com.apple.product-type.library.dynamic";
 		};
-		CD5FB2971F06F030005A0D61 /* bigdecimal_s */ = {
-			isa = PBXNativeTarget;
-			buildConfigurationList = CD5FB2A01F06F030005A0D61 /* Build configuration list for PBXNativeTarget "bigdecimal_s" */;
-			buildPhases = (
-				CD5FB2941F06F030005A0D61 /* Sources */,
-				CD5FB2951F06F030005A0D61 /* Frameworks */,
-				CD5FB2961F06F030005A0D61 /* Headers */,
-			);
-			buildRules = (
-			);
-			dependencies = (
-			);
-			name = bigdecimal_s;
-			productName = bigdecimal_s;
-			productReference = CD5FB2981F06F030005A0D61 /* libbigdecimal_s.a */;
-			productType = "com.apple.product-type.library.static";
-		};
 /* End PBXNativeTarget section */
 
 /* Begin PBXProject section */
@@ -213,15 +232,12 @@
 				LastUpgradeCheck = 0720;
 				ORGANIZATIONNAME = "Sam Jaffe";
 				TargetAttributes = {
-					CD5FB2701F06EEAF005A0D61 = {
+					CD47694220AFA150009AA8BB = {
 						CreatedOnToolsVersion = 7.2.1;
 					};
 					CD5FB2851F06EFEA005A0D61 = {
 						CreatedOnToolsVersion = 7.2.1;
 					};
-					CD5FB2971F06F030005A0D61 = {
-						CreatedOnToolsVersion = 7.2.1;
-					};
 				};
 			};
 			buildConfigurationList = CD5FB26C1F06EEAF005A0D61 /* Build configuration list for PBXProject "bigdecimal" */;
@@ -234,40 +250,69 @@
 			mainGroup = CD5FB2681F06EEAF005A0D61;
 			productRefGroup = CD5FB2721F06EEAF005A0D61 /* Products */;
 			projectDirPath = "";
+			projectReferences = (
+				{
+					ProductGroup = CD47697920AFAC9C009AA8BB /* Products */;
+					ProjectRef = CD47697820AFAC9C009AA8BB /* GoogleMock.xcodeproj */;
+				},
+			);
 			projectRoot = "";
 			targets = (
-				CD5FB2701F06EEAF005A0D61 /* bigdecimal_tc */,
 				CD5FB2851F06EFEA005A0D61 /* bigdecimal */,
-				CD5FB2971F06F030005A0D61 /* bigdecimal_s */,
+				CD47694220AFA150009AA8BB /* bigdecimal-test */,
 			);
 		};
 /* End PBXProject section */
 
-/* Begin PBXShellScriptBuildPhase section */
-		CD5FB2A51F06F04C005A0D61 /* ShellScript */ = {
-			isa = PBXShellScriptBuildPhase;
+/* Begin PBXReferenceProxy section */
+		CD47698020AFAC9C009AA8BB /* GoogleMock.framework */ = {
+			isa = PBXReferenceProxy;
+			fileType = wrapper.framework;
+			path = GoogleMock.framework;
+			remoteRef = CD47697F20AFAC9C009AA8BB /* PBXContainerItemProxy */;
+			sourceTree = BUILT_PRODUCTS_DIR;
+		};
+		CD47698220AFAC9C009AA8BB /* gmock.framework */ = {
+			isa = PBXReferenceProxy;
+			fileType = wrapper.framework;
+			path = gmock.framework;
+			remoteRef = CD47698120AFAC9C009AA8BB /* PBXContainerItemProxy */;
+			sourceTree = BUILT_PRODUCTS_DIR;
+		};
+		CD47698420AFAC9C009AA8BB /* gtest.framework */ = {
+			isa = PBXReferenceProxy;
+			fileType = wrapper.framework;
+			path = gtest.framework;
+			remoteRef = CD47698320AFAC9C009AA8BB /* PBXContainerItemProxy */;
+			sourceTree = BUILT_PRODUCTS_DIR;
+		};
+		CD47698620AFAC9C009AA8BB /* GoogleMockTests.xctest */ = {
+			isa = PBXReferenceProxy;
+			fileType = wrapper.cfbundle;
+			path = GoogleMockTests.xctest;
+			remoteRef = CD47698520AFAC9C009AA8BB /* PBXContainerItemProxy */;
+			sourceTree = BUILT_PRODUCTS_DIR;
+		};
+/* End PBXReferenceProxy section */
+
+/* Begin PBXResourcesBuildPhase section */
+		CD47694120AFA150009AA8BB /* Resources */ = {
+			isa = PBXResourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
 			);
-			inputPaths = (
-				"$(SRCROOT)/test/biginteger.t.h",
-				"$(SRCROOT)/test/bigdecimal.t.h",
-			);
-			outputPaths = (
-				"$(SRCROOT)/test/bigdecimal_tc.cpp",
-			);
 			runOnlyForDeploymentPostprocessing = 0;
-			shellPath = /bin/sh;
-			shellScript = "cd test; cxxtestgen --error-printer -o bigdecimal_tc.cpp biginteger.t.h bigdecimal.t.h bigdecimal_integer.t.h";
 		};
-/* End PBXShellScriptBuildPhase section */
+/* End PBXResourcesBuildPhase section */
 
 /* Begin PBXSourcesBuildPhase section */
-		CD5FB26D1F06EEAF005A0D61 /* Sources */ = {
+		CD47693F20AFA150009AA8BB /* Sources */ = {
 			isa = PBXSourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
-				CD5FB2A71F06F0D2005A0D61 /* bigdecimal_tc.cpp in Sources */,
+				CD47697720AFA6B2009AA8BB /* biginteger_test.cpp in Sources */,
+				CD47698B20AFB4FD009AA8BB /* bigdecimal_test.cpp in Sources */,
+				CD47698A20AFB48C009AA8BB /* bigdecimal_integral_test.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -281,19 +326,50 @@
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
-		CD5FB2941F06F030005A0D61 /* Sources */ = {
-			isa = PBXSourcesBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-				CD2EC1C01F0AF3B800D49DF5 /* bigdecimal.cpp in Sources */,
-				CD5FB2A31F06F03D005A0D61 /* biginteger.cpp in Sources */,
-				CD2EC1C61F0BCCBF00D49DF5 /* bignum_helper.cpp in Sources */,
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
 /* End PBXSourcesBuildPhase section */
 
+/* Begin PBXTargetDependency section */
+		CD47694A20AFA150009AA8BB /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = CD5FB2851F06EFEA005A0D61 /* bigdecimal */;
+			targetProxy = CD47694920AFA150009AA8BB /* PBXContainerItemProxy */;
+		};
+		CD47698820AFACA8009AA8BB /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			name = GoogleMock;
+			targetProxy = CD47698720AFACA8009AA8BB /* PBXContainerItemProxy */;
+		};
+/* End PBXTargetDependency section */
+
 /* Begin XCBuildConfiguration section */
+		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";
+				PRODUCT_NAME = "$(TARGET_NAME)";
+			};
+			name = Debug;
+		};
+		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";
+				PRODUCT_NAME = "$(TARGET_NAME)";
+			};
+			name = Release;
+		};
 		CD5FB2761F06EEAF005A0D61 /* Debug */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
@@ -318,6 +394,8 @@
 				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 = (
@@ -362,6 +440,8 @@
 				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;
@@ -377,22 +457,6 @@
 			};
 			name = Release;
 		};
-		CD5FB2791F06EEAF005A0D61 /* Debug */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				HEADER_SEARCH_PATHS = /usr/local/include;
-				PRODUCT_NAME = "$(TARGET_NAME)";
-			};
-			name = Debug;
-		};
-		CD5FB27A1F06EEAF005A0D61 /* Release */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				HEADER_SEARCH_PATHS = /usr/local/include;
-				PRODUCT_NAME = "$(TARGET_NAME)";
-			};
-			name = Release;
-		};
 		CD5FB28F1F06EFEA005A0D61 /* Debug */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
@@ -419,43 +483,22 @@
 			};
 			name = Release;
 		};
-		CD5FB2A11F06F030005A0D61 /* Debug */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				EXECUTABLE_PREFIX = lib;
-				GCC_ENABLE_CPP_EXCEPTIONS = YES;
-				GCC_ENABLE_CPP_RTTI = YES;
-				PRODUCT_NAME = "$(TARGET_NAME)";
-			};
-			name = Debug;
-		};
-		CD5FB2A21F06F030005A0D61 /* Release */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				EXECUTABLE_PREFIX = lib;
-				GCC_ENABLE_CPP_EXCEPTIONS = YES;
-				GCC_ENABLE_CPP_RTTI = YES;
-				PRODUCT_NAME = "$(TARGET_NAME)";
-			};
-			name = Release;
-		};
 /* End XCBuildConfiguration section */
 
 /* Begin XCConfigurationList section */
-		CD5FB26C1F06EEAF005A0D61 /* Build configuration list for PBXProject "bigdecimal" */ = {
+		CD47694B20AFA150009AA8BB /* Build configuration list for PBXNativeTarget "bigdecimal-test" */ = {
 			isa = XCConfigurationList;
 			buildConfigurations = (
-				CD5FB2761F06EEAF005A0D61 /* Debug */,
-				CD5FB2771F06EEAF005A0D61 /* Release */,
+				CD47694C20AFA150009AA8BB /* Debug */,
+				CD47694D20AFA150009AA8BB /* Release */,
 			);
 			defaultConfigurationIsVisible = 0;
-			defaultConfigurationName = Release;
 		};
-		CD5FB2781F06EEAF005A0D61 /* Build configuration list for PBXNativeTarget "bigdecimal_tc" */ = {
+		CD5FB26C1F06EEAF005A0D61 /* Build configuration list for PBXProject "bigdecimal" */ = {
 			isa = XCConfigurationList;
 			buildConfigurations = (
-				CD5FB2791F06EEAF005A0D61 /* Debug */,
-				CD5FB27A1F06EEAF005A0D61 /* Release */,
+				CD5FB2761F06EEAF005A0D61 /* Debug */,
+				CD5FB2771F06EEAF005A0D61 /* Release */,
 			);
 			defaultConfigurationIsVisible = 0;
 			defaultConfigurationName = Release;
@@ -469,15 +512,6 @@
 			defaultConfigurationIsVisible = 0;
 			defaultConfigurationName = Release;
 		};
-		CD5FB2A01F06F030005A0D61 /* Build configuration list for PBXNativeTarget "bigdecimal_s" */ = {
-			isa = XCConfigurationList;
-			buildConfigurations = (
-				CD5FB2A11F06F030005A0D61 /* Debug */,
-				CD5FB2A21F06F030005A0D61 /* Release */,
-			);
-			defaultConfigurationIsVisible = 0;
-			defaultConfigurationName = Release;
-		};
 /* End XCConfigurationList section */
 	};
 	rootObject = CD5FB2691F06EEAF005A0D61 /* Project object */;

+ 0 - 157
test/bigdecimal.t.h

@@ -1,157 +0,0 @@
-//
-//  bigdecimal.t.h
-//  bigdecimal
-//
-//  Created by Sam Jaffe on 7/5/17.
-//
-
-#pragma once
-
-#include "bigdecimal.h"
-
-#include <cxxtest/TestSuite.h>
-
-class bigdecimal_TestSuite : public CxxTest::TestSuite {
-public:
-//  void testConstructFromStringIsSameValueAsFromInt() {
-//    using bi = math::bigdecimal;
-//    TS_ASSERT_EQUALS(bi("1000000"), bi(1000000));
-//  }
-//
-  
-  void testConstructIntegerAsDecimal() {
-    using bd = math::bigdecimal;
-    TS_ASSERT_EQUALS(bd("1000.00").to_string(), "1000.00");
-  }
-
-  void testConstructDecimal() {
-    using bd = math::bigdecimal;
-    TS_ASSERT_EQUALS(bd("1000.10").to_string(), "1000.10");
-    TS_ASSERT_EQUALS(bd("1000.01").to_string(), "1000.01");
-  }
-
-  void testRescaleHigherAddsDigits() {
-    math::bigdecimal dec(100);
-    TS_ASSERT_EQUALS(dec.scale(), 0);
-    dec.rescale(2);
-    TS_ASSERT_EQUALS(dec.to_string(), "100.00");
-  }
-  
-  void testRescaleLowerCanBeLossy() {
-    math::bigdecimal dec("100.10");
-    TS_ASSERT_EQUALS(dec.scale(), 2);
-    dec.rescale(0);
-    dec.rescale(2);
-    TS_ASSERT_EQUALS(dec.to_string(), "100.00");
-  }
-  
-  void testNegativeScaleLosesLowerDigits() {
-    math::bigdecimal dec("123", -2);
-    TS_ASSERT_EQUALS(dec.to_string(), "100");
-  }
-  
-  void testConstructWithScaleEqualsWithout() {
-    math::bigdecimal scl(100, -2);
-    TS_ASSERT_EQUALS(scl.to_string(), "100");
-  }
-  
-  void testScaleBelowNegSegDoesntLoseAnything() {
-    TS_ASSERT_EQUALS(math::bigdecimal("1000000000", -9).to_string(),
-                     "1000000000");
-  }
-  
-  void testAddTwoDecimalsSameScale() {
-    using bd = math::bigdecimal;
-    bd a("1000.10");
-    bd b("1000.01");
-    TS_ASSERT_EQUALS(a.scale(), b.scale());
-    TS_ASSERT_EQUALS((a+b).to_string(), "2000.11");
-  }
-  
-  void testAddTwoDecimalsDifferentScalesUsesHigherScale() {
-    using bd = math::bigdecimal;
-    bd a("1000.10");
-    bd b("1000");
-    TS_ASSERT(a.scale() > b.scale());
-    TS_ASSERT_EQUALS((a+b).to_string(), "2000.10");
-  }
-  
-  void testAddNumberWithInversePreservesScale() {
-    math::bigdecimal a("1.001");
-    TS_ASSERT_EQUALS((a+(-a)).to_string(), "0.000");
-  }
-  
-  void testSubtractTwoDecimalsDifferentScalesUsesHigherScale() {
-    using bd = math::bigdecimal;
-    bd a("900.10");
-    bd b("1000");
-    TS_ASSERT(a.scale() > b.scale());
-    TS_ASSERT_EQUALS((a-b).to_string(), "-99.90");
-    TS_ASSERT_EQUALS((b-a).to_string(), "99.90");
-  }
-
-  void testMultiplicationIncreasesScale() {
-    math::bigdecimal bd("1.1");
-    auto out = bd * bd;
-    TS_ASSERT_EQUALS(out.scale(), bd.scale() + bd.scale());
-    TS_ASSERT_EQUALS(out.to_string(), "1.21");
-  }
-  
-  void testMultiplicationNegativeScaleCountersPositiveScale() {
-    math::bigdecimal a("0.01");
-    math::bigdecimal b("100", -2);
-    TS_ASSERT_EQUALS((a*b).to_string(), "1");
-  }
-  
-  void testMultiplicationCreateNewOffsetCell() {
-    math::bigdecimal C(1, 5);
-    TS_ASSERT_EQUALS((C*C).to_string(), "1.0000000000");
-  }
-
-  void testMultiplicationNegativeToPositiveScale() {
-    math::bigdecimal C(1, 5);
-    math::bigdecimal D(100, -2);
-    TS_ASSERT_EQUALS((D*C).to_string(), "100.000");
-  }
-  
-  void testMultiplicationFromDroppedToNonDropScale() {
-    math::bigdecimal C(1, 5);
-    math::bigdecimal E(1000000000, -9);
-    TS_ASSERT_EQUALS((E*C).to_string(), "1000000000");
-  }
-
-  void testMultiplicationFromDroppedToLowerScale() {
-    math::bigdecimal D(100, -2);
-    math::bigdecimal E(1000000000, -9);
-    TS_ASSERT_EQUALS((E*D).to_string(), "100000000000");
-  }
-
-  void testMultiplicationFromNonDropToDroppedScale() {
-    math::bigdecimal F(10000, -4);
-    math::bigdecimal G(100000, -5);
-    TS_ASSERT_EQUALS((G*F).to_string(), "1000000000");
-  }
-  
-  void testDivideHigherScaleByLowerScale() {
-    math::bigdecimal a("1", 2);
-    math::bigdecimal b("1", 1);
-    TS_ASSERT_EQUALS((a/b).to_string(), "1.0");
-  }
-
-  void testDivideLowerScaleByHigherScale() {
-    math::bigdecimal a("10", 1);
-    math::bigdecimal b("1", 2);
-    TS_ASSERT_EQUALS((a/b).to_string(), "10");
-  }
-  
-  void testDivideByLargerNumberGivesDecimalIfScaleAllows() {
-    math::bigdecimal a("1" ,  0);
-    math::bigdecimal b("1" ,  1);
-    math::bigdecimal c("10",  0);
-    math::bigdecimal d("10", -1);
-    TS_ASSERT_EQUALS((a/c).to_string(), "0");
-    TS_ASSERT_EQUALS((a/d).to_string(), "0.1");
-    TS_ASSERT_EQUALS((b/c).to_string(), "0.1");
-    TS_ASSERT_EQUALS((b/d).to_string(), "0.10");
-  }
-};

+ 0 - 175
test/bigdecimal_integer.t.h

@@ -1,175 +0,0 @@
-//
-//  bigdecimal.t.h
-//  bigdecimal
-//
-//  Created by Sam Jaffe on 6/30/17.
-//
-
-#pragma once
-
-#include "bigdecimal.h"
-
-#include <cxxtest/TestSuite.h>
-
-class bigdecimal_integer_TestSuite : public CxxTest::TestSuite {
-public:
-  void testConstructFromStringIsSameValueAsFromInt() {
-    using bi = math::bigdecimal;
-    TS_ASSERT_EQUALS(bi("1000000"), bi(1000000));
-  }
-  
-  void testAddPastBounds() {
-    math::bigdecimal bi{999999999ULL};
-    TS_ASSERT_EQUALS((bi+1).to_string(), "1000000000");
-  }
-  
-  void testAddReciprocalIsZero() {
-    math::bigdecimal bi{1000};
-    TS_ASSERT_EQUALS((bi+(-bi)).to_string(), "0");
-  }
-
-  void testAddNegativeLargerGivesNegative() {
-    math::bigdecimal bi{1000};
-    TS_ASSERT_EQUALS((bi+(-1001)).to_string(), "-1");
-  }
-
-  void testAddNegativeSmallerGivesPositive() {
-    math::bigdecimal bi{1000};
-    TS_ASSERT_EQUALS((bi+(-999)).to_string(), "1");
-  }
-  
-  void testSubSelfIsZero() {
-    math::bigdecimal bi{1000};
-    TS_ASSERT_EQUALS((bi-bi).to_string(), "0");
-  }
-  
-  void testNegativeMinusNegativeIncreateAbs() {
-    math::bigdecimal bi{-1000};
-    TS_ASSERT_EQUALS((bi-100).to_string(), "-1100");
-  }
-  
-  void testSubLargerGivesNegative() {
-    math::bigdecimal bi{1000};
-    TS_ASSERT_EQUALS((bi-1001).to_string(), "-1");
-  }
-  
-  void testSubSmallerGivesPositive() {
-    math::bigdecimal bi{1000};
-    TS_ASSERT_EQUALS((bi-999).to_string(), "1");
-  }
-
-  void testSubUnderflowBorrows() {
-    math::bigdecimal bi{1000000000ULL};
-    TS_ASSERT_EQUALS((bi-1).to_string(), "999999999");
-  }
-
-  void testMultiplyZeroReturnsZero() {
-    auto &ZERO =  math::bigdecimal::ZERO;
-    math::bigdecimal bi{999999999ULL};
-    TS_ASSERT_EQUALS(bi*ZERO, ZERO);
-    TS_ASSERT_EQUALS(ZERO*bi, ZERO);
-  }
-  
-  void testMultiplyOneReturnsValue() {
-    auto &ONE =  math::bigdecimal::ONE;
-    math::bigdecimal bi{999999999ULL};
-    TS_ASSERT_EQUALS((bi*ONE).to_string(), "999999999");
-    TS_ASSERT_EQUALS((ONE*bi).to_string(), "999999999");
-  }
-
-  void testMultiplyNegativeOneReturnsInverse() {
-    auto &NEGATIVE_ONE =  math::bigdecimal::NEGATIVE_ONE;
-    math::bigdecimal bi{999999999ULL};
-    TS_ASSERT_EQUALS((bi*NEGATIVE_ONE).to_string(), "-999999999");
-    TS_ASSERT_EQUALS((NEGATIVE_ONE*bi).to_string(), "-999999999");
-  }
-  
-  void testMultiplyOverflowsIntoNextCell() {
-    math::bigdecimal bi{999999999ULL};
-    TS_ASSERT_EQUALS((bi*bi).to_string(), "999999998000000001");
-  }
-  
-  void testMultiplyCarryIntoNextCell() {
-    math::bigdecimal bi{999999999ULL};
-    math::bigdecimal big{bi*bi};
-    TS_ASSERT_EQUALS((big*big).to_string(),
-                     "999999996000000005999999996000000001");
-  }
-  
-  void testMultiplyNoOverflow() {
-    math::bigdecimal bi{1000};
-    TS_ASSERT_EQUALS((bi*bi).to_string(), "1000000");
-  }
-  
-  void testDivideByZeroThrows() {
-    auto &ZERO =  math::bigdecimal::ZERO;
-    math::bigdecimal bi{1000};
-    TS_ASSERT_THROWS(bi/ZERO, std::domain_error);
-  }
-  
-  void testDivideByOneReturnsValue() {
-    auto &ONE =  math::bigdecimal::ONE;
-    math::bigdecimal bi{1000};
-    TS_ASSERT_EQUALS(bi/ONE, bi);
-  }
-
-  void testDivideByNegativeOneReturnsInverse() {
-    auto &NEGATIVE_ONE =  math::bigdecimal::NEGATIVE_ONE;
-    math::bigdecimal bi{1000};
-    TS_ASSERT_EQUALS((bi/NEGATIVE_ONE).to_string(), "-1000");
-  }
-
-  void testDivisionWithMultipleMultSubSteps() {
-    math::bigdecimal bi{1112};
-    TS_ASSERT_EQUALS((bi/2).to_string(), "556");
-  }
-  
-  void testDivisionDroppingNumberOfCells() {
-    math::bigdecimal bi{1000000000ULL};
-    TS_ASSERT_EQUALS((bi/2).to_string(), "500000000");
-  }
-  
-  void testDivisionByBiggerNumberIsZero() {
-    math::bigdecimal bi{1000ULL};
-    TS_ASSERT_EQUALS((bi/1001).to_string(), "0");
-  }
-  
-  void testDivisionWithLargeNumbers() {
-    math::bigdecimal big{"999999998000000001"};
-    TS_ASSERT_EQUALS(big.to_string(), "999999998000000001");
-    TS_ASSERT_EQUALS((big/999999999ULL).to_string(),
-                     "999999999");
-  }
-//  
-//  void testModuloZeroThrows() {
-//    math::bigdecimal bi{1000};
-//    TS_ASSERT_THROWS(bi%0, std::domain_error);
-//  }
-//  
-//  void testModuloBiggerIsSameValue() {
-//    math::bigdecimal bi{1000};
-//    TS_ASSERT_EQUALS(bi%2000, bi);
-//  }
-//  
-//  void testModuloSameNumberIsZero() {
-//    math::bigdecimal bi{1000};
-//    TS_ASSERT_EQUALS(bi%1000, 0);
-//  }
-//
-//  void testModuloDivisorIsZero() {
-//    math::bigdecimal bi{1000};
-//    TS_ASSERT_EQUALS(bi%100, 0);
-//  }
-//
-//  void testModuloDiffSignIsInverseElement() {
-//    math::bigdecimal bi{1000};
-//    math::bigdecimal mod{13};
-//    TS_ASSERT_EQUALS((bi%mod)+((-bi)%mod), mod);
-//  }
-//
-//  void testModuloNegativesIsNegative() {
-//    math::bigdecimal bi{1000};
-//    math::bigdecimal mod{13};
-//    TS_ASSERT_EQUALS((bi%mod), -((-bi)%(-mod)));
-//  }
-};

+ 170 - 0
test/bigdecimal_integral_test.cpp

@@ -0,0 +1,170 @@
+//
+//  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)));
+//  }

+ 150 - 0
test/bigdecimal_test.cpp

@@ -0,0 +1,150 @@
+//
+//  bigdecimal_test.cpp
+//  bigdecimal
+//
+//  Created by Sam Jaffe on 5/18/18.
+//
+
+#include <gmock/gmock.h>
+
+#include "bigdecimal.h"
+
+//  TEST(BigDecimal, ConstructFromStringIsSameValueAsFromInt) {
+//    using bi = math::bigdecimal;
+//    EXPECT_THAT(bi("1000000"), bi(1000000));
+//  }
+//
+
+TEST(BigDecimal, ConstructIntegerAsDecimal) {
+  EXPECT_THAT(math::bigdecimal("1000.00").to_string(), "1000.00");
+}
+
+TEST(BigDecimal, ConstructDecimal) {
+  EXPECT_THAT(math::bigdecimal("1000.10").to_string(), "1000.10");
+  EXPECT_THAT(math::bigdecimal("1000.01").to_string(), "1000.01");
+}
+
+TEST(BigDecimal, RescaleHigherAddsDigits) {
+  math::bigdecimal dec(100);
+  EXPECT_THAT(dec.scale(), 0);
+  dec.rescale(2);
+  EXPECT_THAT(dec.to_string(), "100.00");
+}
+
+TEST(BigDecimal, RescaleLowerCanBeLossy) {
+  math::bigdecimal dec("100.10");
+  EXPECT_THAT(dec.scale(), 2);
+  dec.rescale(0);
+  dec.rescale(2);
+  EXPECT_THAT(dec.to_string(), "100.00");
+}
+
+TEST(BigDecimal, NegativeScaleLosesLowerDigits) {
+  math::bigdecimal dec("123", -2);
+  EXPECT_THAT(dec.to_string(), "100");
+}
+
+TEST(BigDecimal, ConstructWithScaleEqualsWithout) {
+  math::bigdecimal scl(100, -2);
+  EXPECT_THAT(scl.to_string(), "100");
+}
+
+TEST(BigDecimal, ScaleBelowNegSegDoesntLoseAnything) {
+  EXPECT_THAT(math::bigdecimal("1000000000", -9).to_string(),
+                   "1000000000");
+}
+
+TEST(BigDecimal, AddTwoDecimalsSameScale) {
+  using bd = math::bigdecimal;
+  bd a("1000.10");
+  bd b("1000.01");
+  EXPECT_THAT(a.scale(), b.scale());
+  EXPECT_THAT((a+b).to_string(), "2000.11");
+}
+
+TEST(BigDecimal, AddTwoDecimalsDifferentScalesUsesHigherScale) {
+  using bd = math::bigdecimal;
+  bd a("1000.10");
+  bd b("1000");
+  EXPECT_THAT(a.scale(), testing::Gt(b.scale()));
+  EXPECT_THAT((a+b).to_string(), "2000.10");
+}
+
+TEST(BigDecimal, AddNumberWithInversePreservesScale) {
+  math::bigdecimal a("1.001");
+  EXPECT_THAT((a+(-a)).to_string(), "0.000");
+}
+
+TEST(BigDecimal, SubtractTwoDecimalsDifferentScalesUsesHigherScale) {
+  using bd = math::bigdecimal;
+  bd a("900.10");
+  bd b("1000");
+  EXPECT_THAT(a.scale(), testing::Gt(b.scale()));
+  EXPECT_THAT((a-b).to_string(), "-99.90");
+  EXPECT_THAT((b-a).to_string(), "99.90");
+}
+
+TEST(BigDecimal, MultiplicationIncreasesScale) {
+  math::bigdecimal bd("1.1");
+  auto out = bd * bd;
+  EXPECT_THAT(out.scale(), bd.scale() + bd.scale());
+  EXPECT_THAT(out.to_string(), "1.21");
+}
+
+TEST(BigDecimal, MultiplicationNegativeScaleCountersPositiveScale) {
+  math::bigdecimal a("0.01");
+  math::bigdecimal b("100", -2);
+  EXPECT_THAT((a*b).to_string(), "1");
+}
+
+TEST(BigDecimal, MultiplicationCreateNewOffsetCell) {
+  math::bigdecimal C(1, 5);
+  EXPECT_THAT((C*C).to_string(), "1.0000000000");
+}
+
+TEST(BigDecimal, MultiplicationNegativeToPositiveScale) {
+  math::bigdecimal C(1, 5);
+  math::bigdecimal D(100, -2);
+  EXPECT_THAT((D*C).to_string(), "100.000");
+}
+
+TEST(BigDecimal, MultiplicationFromDroppedToNonDropScale) {
+  math::bigdecimal C(1, 5);
+  math::bigdecimal E(1000000000, -9);
+  EXPECT_THAT((E*C).to_string(), "1000000000");
+}
+
+TEST(BigDecimal, MultiplicationFromDroppedToLowerScale) {
+  math::bigdecimal D(100, -2);
+  math::bigdecimal E(1000000000, -9);
+  EXPECT_THAT((E*D).to_string(), "100000000000");
+}
+
+TEST(BigDecimal, MultiplicationFromNonDropToDroppedScale) {
+  math::bigdecimal F(10000, -4);
+  math::bigdecimal G(100000, -5);
+  EXPECT_THAT((G*F).to_string(), "1000000000");
+}
+
+TEST(BigDecimal, DivideHigherScaleByLowerScale) {
+  math::bigdecimal a("1", 2);
+  math::bigdecimal b("1", 1);
+  EXPECT_THAT((a/b).to_string(), "1.0");
+}
+
+TEST(BigDecimal, DivideLowerScaleByHigherScale) {
+  math::bigdecimal a("10", 1);
+  math::bigdecimal b("1", 2);
+  EXPECT_THAT((a/b).to_string(), "10");
+}
+
+TEST(BigDecimal, DivideByLargerNumberGivesDecimalIfScaleAllows) {
+  math::bigdecimal a("1" ,  0);
+  math::bigdecimal b("1" ,  1);
+  math::bigdecimal c("10",  0);
+  math::bigdecimal d("10", -1);
+  EXPECT_THAT((a/c).to_string(), "0");
+  EXPECT_THAT((a/d).to_string(), "0.1");
+  EXPECT_THAT((b/c).to_string(), "0.1");
+  EXPECT_THAT((b/d).to_string(), "0.10");
+}

+ 0 - 175
test/biginteger.t.h

@@ -1,175 +0,0 @@
-//
-//  biginteger.t.h
-//  bigdecimal
-//
-//  Created by Sam Jaffe on 6/30/17.
-//
-
-#pragma once
-
-#include "biginteger.h"
-
-#include <cxxtest/TestSuite.h>
-
-class biginteger_TestSuite : public CxxTest::TestSuite {
-public:
-  void testConstructFromStringIsSameValueAsFromInt() {
-    using bi = math::biginteger;
-    TS_ASSERT_EQUALS(bi("1000000"), bi(1000000));
-  }
-  
-  void testAddPastBounds() {
-    math::biginteger bi{999999999ULL};
-    TS_ASSERT_EQUALS((bi+1).to_string(), "1000000000");
-  }
-  
-  void testAddReciprocalIsZero() {
-    math::biginteger bi{1000};
-    TS_ASSERT_EQUALS((bi+(-bi)).to_string(), "0");
-  }
-
-  void testAddNegativeLargerGivesNegative() {
-    math::biginteger bi{1000};
-    TS_ASSERT_EQUALS((bi+(-1001)).to_string(), "-1");
-  }
-
-  void testAddNegativeSmallerGivesPositive() {
-    math::biginteger bi{1000};
-    TS_ASSERT_EQUALS((bi+(-999)).to_string(), "1");
-  }
-  
-  void testSubSelfIsZero() {
-    math::biginteger bi{1000};
-    TS_ASSERT_EQUALS((bi-bi).to_string(), "0");
-  }
-  
-  void testNegativeMinusNegativeIncreateAbs() {
-    math::biginteger bi{-1000};
-    TS_ASSERT_EQUALS((bi-100).to_string(), "-1100");
-  }
-  
-  void testSubLargerGivesNegative() {
-    math::biginteger bi{1000};
-    TS_ASSERT_EQUALS((bi-1001).to_string(), "-1");
-  }
-  
-  void testSubSmallerGivesPositive() {
-    math::biginteger bi{1000};
-    TS_ASSERT_EQUALS((bi-999).to_string(), "1");
-  }
-
-  void testSubUnderflowBorrows() {
-    math::biginteger bi{1000000000ULL};
-    TS_ASSERT_EQUALS((bi-1).to_string(), "999999999");
-  }
-
-  void testMultiplyZeroReturnsZero() {
-    auto &ZERO =  math::biginteger::ZERO;
-    math::biginteger bi{999999999ULL};
-    TS_ASSERT_EQUALS(bi*ZERO, ZERO);
-    TS_ASSERT_EQUALS(ZERO*bi, ZERO);
-  }
-  
-  void testMultiplyOneReturnsValue() {
-    auto &ONE =  math::biginteger::ONE;
-    math::biginteger bi{999999999ULL};
-    TS_ASSERT_EQUALS((bi*ONE).to_string(), "999999999");
-    TS_ASSERT_EQUALS((ONE*bi).to_string(), "999999999");
-  }
-
-  void testMultiplyNegativeOneReturnsInverse() {
-    auto &NEGATIVE_ONE =  math::biginteger::NEGATIVE_ONE;
-    math::biginteger bi{999999999ULL};
-    TS_ASSERT_EQUALS((bi*NEGATIVE_ONE).to_string(), "-999999999");
-    TS_ASSERT_EQUALS((NEGATIVE_ONE*bi).to_string(), "-999999999");
-  }
-  
-  void testMultiplyOverflowsIntoNextCell() {
-    math::biginteger bi{999999999ULL};
-    TS_ASSERT_EQUALS((bi*bi).to_string(), "999999998000000001");
-  }
-  
-  void testMultiplyCarryIntoNextCell() {
-    math::biginteger bi{999999999ULL};
-    math::biginteger big{bi*bi};
-    TS_ASSERT_EQUALS((big*big).to_string(),
-                     "999999996000000005999999996000000001");
-  }
-  
-  void testMultiplyNoOverflow() {
-    math::biginteger bi{1000};
-    TS_ASSERT_EQUALS((bi*bi).to_string(), "1000000");
-  }
-  
-  void testDivideByZeroThrows() {
-    auto &ZERO =  math::biginteger::ZERO;
-    math::biginteger bi{1000};
-    TS_ASSERT_THROWS(bi/ZERO, std::domain_error);
-  }
-  
-  void testDivideByOneReturnsValue() {
-    auto &ONE =  math::biginteger::ONE;
-    math::biginteger bi{1000};
-    TS_ASSERT_EQUALS(bi/ONE, bi);
-  }
-
-  void testDivideByNegativeOneReturnsInverse() {
-    auto &NEGATIVE_ONE =  math::biginteger::NEGATIVE_ONE;
-    math::biginteger bi{1000};
-    TS_ASSERT_EQUALS((bi/NEGATIVE_ONE).to_string(), "-1000");
-  }
-
-  void testDivisionWithMultipleMultSubSteps() {
-    math::biginteger bi{1112};
-    TS_ASSERT_EQUALS((bi/2).to_string(), "556");
-  }
-  
-  void testDivisionDroppingNumberOfCells() {
-    math::biginteger bi{1000000000ULL};
-    TS_ASSERT_EQUALS((bi/2).to_string(), "500000000");
-  }
-  
-  void testDivisionByBiggerNumberIsZero() {
-    math::biginteger bi{1000ULL};
-    TS_ASSERT_EQUALS((bi/1001).to_string(), "0");
-  }
-  
-  void testDivisionWithLargeNumbers() {
-    math::biginteger big{"999999998000000001"};
-    TS_ASSERT_EQUALS(big.to_string(), "999999998000000001");
-    TS_ASSERT_EQUALS((big/999999999ULL).to_string(),
-                     "999999999");
-  }
-  
-  void testModuloZeroThrows() {
-    math::biginteger bi{1000};
-    TS_ASSERT_THROWS(bi%0, std::domain_error);
-  }
-  
-  void testModuloBiggerIsSameValue() {
-    math::biginteger bi{1000};
-    TS_ASSERT_EQUALS(bi%2000, bi);
-  }
-  
-  void testModuloSameNumberIsZero() {
-    math::biginteger bi{1000};
-    TS_ASSERT_EQUALS(bi%1000, 0);
-  }
-
-  void testModuloDivisorIsZero() {
-    math::biginteger bi{1000};
-    TS_ASSERT_EQUALS(bi%100, 0);
-  }
-
-  void testModuloDiffSignIsInverseElement() {
-    math::biginteger bi{1000};
-    math::biginteger mod{13};
-    TS_ASSERT_EQUALS((bi%mod)+((-bi)%mod), mod);
-  }
-
-  void testModuloNegativesIsNegative() {
-    math::biginteger bi{1000};
-    math::biginteger mod{13};
-    TS_ASSERT_EQUALS((bi%mod), -((-bi)%(-mod)));
-  }
-};

+ 169 - 0
test/biginteger_test.cpp

@@ -0,0 +1,169 @@
+//
+//  biginteger_test.cpp
+//  bigdecimal
+//
+//  Created by Sam Jaffe on 5/18/18.
+//
+
+#include <gmock/gmock.h>
+
+#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);
+}
+
+TEST(BigInteger, ModuloBiggerIsSameValue) {
+  math::biginteger bi{1000};
+  EXPECT_THAT(bi%2000, bi);
+}
+
+TEST(BigInteger, ModuloSameNumberIsZero) {
+  math::biginteger bi{1000};
+  EXPECT_THAT(bi%1000, 0);
+}
+
+TEST(BigInteger, ModuloDivisorIsZero) {
+  math::biginteger bi{1000};
+  EXPECT_THAT(bi%100, 0);
+}
+
+TEST(BigInteger, ModuloDiffSignIsInverseElement) {
+  math::biginteger bi{1000};
+  math::biginteger mod{13};
+  EXPECT_THAT((bi%mod)+((-bi)%mod), mod);
+}
+
+TEST(BigInteger, ModuloNegativesIsNegative) {
+  math::biginteger bi{1000};
+  math::biginteger mod{13};
+  EXPECT_THAT((bi%mod), -((-bi)%(-mod)));
+}