Jelajahi Sumber

Move tests to GoogleTest

Sam Jaffe 7 tahun lalu
induk
melakukan
51d75ddba3
5 mengubah file dengan 389 tambahan dan 175 penghapusan
  1. 0 106
      matrix.t.h
  2. 251 69
      matrix.xcodeproj/project.pbxproj
  3. 12 0
      matrix_dummy.cpp
  4. 102 0
      matrix_test.cpp
  5. 24 0
      matrix_test/Info.plist

+ 0 - 106
matrix.t.h

@@ -1,106 +0,0 @@
-//
-//  matrix_tc.h
-//  math
-//
-//  Created by Sam Jaffe on 8/18/16.
-//
-#pragma once
-
-#include <cxxtest/TestSuite.h>
-
-#include "matrix.hpp"
-#include "matrix_helpers.hpp"
-
-class matrix_TestSuite : public CxxTest::TestSuite {
-public:
-  using matr2i = math::matrix::matrix<int, 2, 2>;
-  using matr2 = math::matrix::matrix<double, 2, 2>;
-public:
-  void test_matrix_equals() const {
-    using math::matrix::identity;
-    TS_ASSERT_EQUALS((identity<int, 2>()), (matr2i{{1,0},{0,1}}));
-  }
-  
-  void test_matrix_sum() const {
-    auto iden = math::matrix::identity<int, 2>();
-    auto result = matr2i{{2,0},{0,2}};
-    TS_ASSERT_EQUALS(iden + iden, result);
-  }
-  
-  void test_matrix_default_zero() const {
-    auto zero = matr2i{{0,0},{0,0}};
-    TS_ASSERT_EQUALS(matr2i{}, zero);
-  }
-
-  void test_matrix_subtract() const {
-    auto zero = matr2i{{0,0},{0,0}};
-    auto iden = math::matrix::identity<int, 2>();
-    TS_ASSERT_EQUALS(iden-iden, zero);
-  }
-  
-//  void test_matrix_negate() const {
-//    auto iden = math::matrix::identity<int, 2>();
-//    TS_ASSERT_EQUALS(-iden, (matr2i{{-1,0},{0,-1}}));
-//  }
-  
-  void test_matrix_scaling() const {
-    auto iden = math::matrix::identity<double, 2>();
-    TS_ASSERT_EQUALS(2*iden, (matr2{{2.0,0.0},{0.0,2.0}}));
-    TS_ASSERT_EQUALS(iden*2, (matr2{{2.0,0.0},{0.0,2.0}}));
-    TS_ASSERT_EQUALS(iden/2.0, (matr2{{0.5,0.0},{0.0,0.5}}));
-  }
-  
-  void test_matrix_multiplication_same_dim() const {
-    auto A = matr2i{{1,2},{2,3}};
-    auto B = matr2i{{1,0},{1,1}};
-    TS_ASSERT_EQUALS(A*B, (matr2i{{3,2},{5,3}}));
-    TS_ASSERT_EQUALS(B*A, (matr2i{{1,2},{3,5}}));
-  }
-  
-  void test_matrix_multiplication_diff_dim() const {
-    auto A = math::matrix::matrix<int, 3, 2>{{1,0},{0,1},{1,1}};
-    auto B = math::matrix::matrix<int, 2, 3>{{0,1,0},{1,0,1}};
-    TS_ASSERT_EQUALS(A*B, (math::matrix::matrix<int, 3, 3>{{0,1,0},{1,0,1},{1,1,1}}));
-    TS_ASSERT_EQUALS(B*A, (math::matrix::matrix<int, 2, 2>{{0,1},{2,1}}));
-  }
-  
-  void test_matrix_vector_multiplication() const {
-    auto A = matr2i{{1,0},{1,2}};
-    auto x = math::vector::vector<int, 2>{1,2};
-    TS_ASSERT_EQUALS(A*x, (math::vector::vector<int, 2>{1,5}));
-  }
-  
-//  void test_matrix_composition() const {
-//    using namespace math::matrix;
-//    using vec4 = math::vector::vector<double, 4>;
-//    using vec3 = math::vector::vector<double, 3>;
-//    auto rot = rotation<4>(math::degree{90}, rotate::X_AXIS);
-//    auto mov = translation(vec3{2.0, 2.5, 1.5});
-//    auto scl = scalar(vec3{2.0, math::vector::fill});
-//    vec4 epsilon{0.00001, math::vector::fill};
-//    TS_ASSERT_DELTA((mov * scl * rot * vec4{1,2,3,1}),
-//                     (vec4{4.0,-1.5,-4.5,1.0}),
-//                    epsilon);
-//  }
-  
-  void test_matrix_from_vector() const {
-    using vec3 = math::vector::vector<double, 3>;
-    vec3 v = vec3{1,2,3};
-    math::matrix::matrix<double, 3, 1> m{v};
-    TS_ASSERT_EQUALS(m(0,0), v[0]);
-    TS_ASSERT_EQUALS(m(1,0), v[1]);
-    TS_ASSERT_EQUALS(m(2,0), v[2]);
-  }
-  
-  void test_matrix_init_list_except() const {
-    TS_ASSERT_THROWS((math::matrix::matrix<double, 2, 1>{{1.0}}), std::logic_error);
-  }
-  
-  void test_assign_row() const {
-    matr2i A = math::matrix::identity<int, 2>();
-    matr2i const B = 2 * A;
-    A[0] = B[0];
-    TS_ASSERT_EQUALS(A, (matr2i{{2,0},{0,1}}));
-  }
-private:
-};

+ 251 - 69
matrix.xcodeproj/project.pbxproj

@@ -7,43 +7,105 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
-		CD0E428F1D9B39B1002FFED1 /* matrix_tc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD0E428C1D9B394E002FFED1 /* matrix_tc.cpp */; };
+		CD0C59BA20C4124700454F82 /* matrix_dummy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD0C59B920C4124700454F82 /* matrix_dummy.cpp */; };
+		CD0C59BB20C4124D00454F82 /* matrix.hpp in Headers */ = {isa = PBXBuildFile; fileRef = CD0E428D1D9B3955002FFED1 /* matrix.hpp */; };
+		CD0C59BC20C4124D00454F82 /* matrix_helpers.hpp in Headers */ = {isa = PBXBuildFile; fileRef = CD0E428E1D9B3955002FFED1 /* matrix_helpers.hpp */; };
+		CD0C59D620C412AD00454F82 /* libmatrix.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CD0C59B520C4123700454F82 /* libmatrix.dylib */; };
+		CD0C59DE20C412C400454F82 /* GoogleMock.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CD0C59C520C4127400454F82 /* GoogleMock.framework */; };
+		CD0C59DF20C412C800454F82 /* matrix_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD0C59CC20C4128F00454F82 /* matrix_test.cpp */; };
 /* End PBXBuildFile section */
 
-/* Begin PBXCopyFilesBuildPhase section */
-		CD0E42771D9B38A9002FFED1 /* CopyFiles */ = {
-			isa = PBXCopyFilesBuildPhase;
-			buildActionMask = 2147483647;
-			dstPath = /usr/share/man/man1/;
-			dstSubfolderSpec = 0;
-			files = (
-			);
-			runOnlyForDeploymentPostprocessing = 1;
+/* Begin PBXContainerItemProxy section */
+		CD0C59C420C4127400454F82 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = CD0C59BD20C4127400454F82 /* GoogleMock.xcodeproj */;
+			proxyType = 2;
+			remoteGlobalIDString = 05818F861A685AEA0072A469;
+			remoteInfo = GoogleMock;
+		};
+		CD0C59C620C4127400454F82 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = CD0C59BD20C4127400454F82 /* GoogleMock.xcodeproj */;
+			proxyType = 2;
+			remoteGlobalIDString = 05E96ABD1A68600C00204102;
+			remoteInfo = gmock;
+		};
+		CD0C59C820C4127400454F82 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = CD0C59BD20C4127400454F82 /* GoogleMock.xcodeproj */;
+			proxyType = 2;
+			remoteGlobalIDString = 05E96B1F1A68634900204102;
+			remoteInfo = gtest;
+		};
+		CD0C59CA20C4127400454F82 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = CD0C59BD20C4127400454F82 /* GoogleMock.xcodeproj */;
+			proxyType = 2;
+			remoteGlobalIDString = 05818F901A685AEA0072A469;
+			remoteInfo = GoogleMockTests;
+		};
+		CD0C59D720C412AD00454F82 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = CD0E42711D9B38A9002FFED1 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = CD0C59B420C4123700454F82;
+			remoteInfo = matrix;
 		};
-/* End PBXCopyFilesBuildPhase section */
+		CD0C59DC20C412BF00454F82 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = CD0C59BD20C4127400454F82 /* GoogleMock.xcodeproj */;
+			proxyType = 1;
+			remoteGlobalIDString = 05818F851A685AEA0072A469;
+			remoteInfo = GoogleMock;
+		};
+/* End PBXContainerItemProxy section */
 
 /* Begin PBXFileReference section */
-		CD0E42791D9B38A9002FFED1 /* matrix_tc */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = matrix_tc; sourceTree = BUILT_PRODUCTS_DIR; };
-		CD0E428B1D9B3943002FFED1 /* matrix.t.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = matrix.t.h; sourceTree = "<group>"; };
-		CD0E428C1D9B394E002FFED1 /* matrix_tc.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = matrix_tc.cpp; sourceTree = "<group>"; };
+		CD0C59B520C4123700454F82 /* libmatrix.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libmatrix.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
+		CD0C59B920C4124700454F82 /* matrix_dummy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = matrix_dummy.cpp; sourceTree = "<group>"; };
+		CD0C59BD20C4127400454F82 /* GoogleMock.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = GoogleMock.xcodeproj; path = "../../../gmock-xcode-master/GoogleMock.xcodeproj"; sourceTree = "<group>"; };
+		CD0C59CC20C4128F00454F82 /* matrix_test.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = matrix_test.cpp; sourceTree = "<group>"; };
+		CD0C59D120C412AD00454F82 /* matrix_test.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = matrix_test.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
+		CD0C59D520C412AD00454F82 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = matrix_test/Info.plist; sourceTree = "<group>"; };
 		CD0E428D1D9B3955002FFED1 /* matrix.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = matrix.hpp; sourceTree = "<group>"; };
 		CD0E428E1D9B3955002FFED1 /* matrix_helpers.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = matrix_helpers.hpp; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
-		CD0E42761D9B38A9002FFED1 /* Frameworks */ = {
+		CD0C59B220C4123700454F82 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		CD0C59CE20C412AD00454F82 /* Frameworks */ = {
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				CD0C59DE20C412C400454F82 /* GoogleMock.framework in Frameworks */,
+				CD0C59D620C412AD00454F82 /* libmatrix.dylib in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
 /* End PBXFrameworksBuildPhase section */
 
 /* Begin PBXGroup section */
+		CD0C59BE20C4127400454F82 /* Products */ = {
+			isa = PBXGroup;
+			children = (
+				CD0C59C520C4127400454F82 /* GoogleMock.framework */,
+				CD0C59C720C4127400454F82 /* gmock.framework */,
+				CD0C59C920C4127400454F82 /* gtest.framework */,
+				CD0C59CB20C4127400454F82 /* GoogleMockTests.xctest */,
+			);
+			name = Products;
+			sourceTree = "<group>";
+		};
 		CD0E42701D9B38A9002FFED1 = {
 			isa = PBXGroup;
 			children = (
+				CD0C59BD20C4127400454F82 /* GoogleMock.xcodeproj */,
 				CD78202F1E44F424001D22E5 /* src */,
 				CD7820301E44F42B001D22E5 /* test */,
 				CD0E427A1D9B38A9002FFED1 /* Products */,
@@ -53,7 +115,8 @@
 		CD0E427A1D9B38A9002FFED1 /* Products */ = {
 			isa = PBXGroup;
 			children = (
-				CD0E42791D9B38A9002FFED1 /* matrix_tc */,
+				CD0C59B520C4123700454F82 /* libmatrix.dylib */,
+				CD0C59D120C412AD00454F82 /* matrix_test.xctest */,
 			);
 			name = Products;
 			sourceTree = "<group>";
@@ -63,6 +126,7 @@
 			children = (
 				CD0E428D1D9B3955002FFED1 /* matrix.hpp */,
 				CD0E428E1D9B3955002FFED1 /* matrix_helpers.hpp */,
+				CD0C59B920C4124700454F82 /* matrix_dummy.cpp */,
 			);
 			name = src;
 			sourceTree = "<group>";
@@ -70,32 +134,62 @@
 		CD7820301E44F42B001D22E5 /* test */ = {
 			isa = PBXGroup;
 			children = (
-				CD0E428B1D9B3943002FFED1 /* matrix.t.h */,
-				CD0E428C1D9B394E002FFED1 /* matrix_tc.cpp */,
+				CD0C59D520C412AD00454F82 /* Info.plist */,
+				CD0C59CC20C4128F00454F82 /* matrix_test.cpp */,
 			);
 			name = test;
 			sourceTree = "<group>";
 		};
 /* End PBXGroup section */
 
+/* Begin PBXHeadersBuildPhase section */
+		CD0C59B320C4123700454F82 /* Headers */ = {
+			isa = PBXHeadersBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				CD0C59BB20C4124D00454F82 /* matrix.hpp in Headers */,
+				CD0C59BC20C4124D00454F82 /* matrix_helpers.hpp in Headers */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXHeadersBuildPhase section */
+
 /* Begin PBXNativeTarget section */
-		CD0E42781D9B38A9002FFED1 /* matrix_tc */ = {
+		CD0C59B420C4123700454F82 /* matrix */ = {
 			isa = PBXNativeTarget;
-			buildConfigurationList = CD0E42801D9B38A9002FFED1 /* Build configuration list for PBXNativeTarget "matrix_tc" */;
+			buildConfigurationList = CD0C59B820C4123800454F82 /* Build configuration list for PBXNativeTarget "matrix" */;
 			buildPhases = (
-				CD0E42901D9B39BC002FFED1 /* Run Script */,
-				CD0E42751D9B38A9002FFED1 /* Sources */,
-				CD0E42761D9B38A9002FFED1 /* Frameworks */,
-				CD0E42771D9B38A9002FFED1 /* CopyFiles */,
+				CD0C59B120C4123700454F82 /* Sources */,
+				CD0C59B220C4123700454F82 /* Frameworks */,
+				CD0C59B320C4123700454F82 /* Headers */,
 			);
 			buildRules = (
 			);
 			dependencies = (
 			);
-			name = matrix_tc;
+			name = matrix;
 			productName = matrix;
-			productReference = CD0E42791D9B38A9002FFED1 /* matrix_tc */;
-			productType = "com.apple.product-type.tool";
+			productReference = CD0C59B520C4123700454F82 /* libmatrix.dylib */;
+			productType = "com.apple.product-type.library.dynamic";
+		};
+		CD0C59D020C412AD00454F82 /* matrix_test */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = CD0C59D920C412AD00454F82 /* Build configuration list for PBXNativeTarget "matrix_test" */;
+			buildPhases = (
+				CD0C59CD20C412AD00454F82 /* Sources */,
+				CD0C59CE20C412AD00454F82 /* Frameworks */,
+				CD0C59CF20C412AD00454F82 /* Resources */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+				CD0C59DD20C412BF00454F82 /* PBXTargetDependency */,
+				CD0C59D820C412AD00454F82 /* PBXTargetDependency */,
+			);
+			name = matrix_test;
+			productName = matrix_test;
+			productReference = CD0C59D120C412AD00454F82 /* matrix_test.xctest */;
+			productType = "com.apple.product-type.bundle.unit-test";
 		};
 /* End PBXNativeTarget section */
 
@@ -106,7 +200,10 @@
 				LastUpgradeCheck = 0720;
 				ORGANIZATIONNAME = "Sam Jaffe";
 				TargetAttributes = {
-					CD0E42781D9B38A9002FFED1 = {
+					CD0C59B420C4123700454F82 = {
+						CreatedOnToolsVersion = 7.2.1;
+					};
+					CD0C59D020C412AD00454F82 = {
 						CreatedOnToolsVersion = 7.2.1;
 					};
 				};
@@ -121,44 +218,136 @@
 			mainGroup = CD0E42701D9B38A9002FFED1;
 			productRefGroup = CD0E427A1D9B38A9002FFED1 /* Products */;
 			projectDirPath = "";
+			projectReferences = (
+				{
+					ProductGroup = CD0C59BE20C4127400454F82 /* Products */;
+					ProjectRef = CD0C59BD20C4127400454F82 /* GoogleMock.xcodeproj */;
+				},
+			);
 			projectRoot = "";
 			targets = (
-				CD0E42781D9B38A9002FFED1 /* matrix_tc */,
+				CD0C59B420C4123700454F82 /* matrix */,
+				CD0C59D020C412AD00454F82 /* matrix_test */,
 			);
 		};
 /* End PBXProject section */
 
-/* Begin PBXShellScriptBuildPhase section */
-		CD0E42901D9B39BC002FFED1 /* Run Script */ = {
-			isa = PBXShellScriptBuildPhase;
+/* Begin PBXReferenceProxy section */
+		CD0C59C520C4127400454F82 /* GoogleMock.framework */ = {
+			isa = PBXReferenceProxy;
+			fileType = wrapper.framework;
+			path = GoogleMock.framework;
+			remoteRef = CD0C59C420C4127400454F82 /* PBXContainerItemProxy */;
+			sourceTree = BUILT_PRODUCTS_DIR;
+		};
+		CD0C59C720C4127400454F82 /* gmock.framework */ = {
+			isa = PBXReferenceProxy;
+			fileType = wrapper.framework;
+			path = gmock.framework;
+			remoteRef = CD0C59C620C4127400454F82 /* PBXContainerItemProxy */;
+			sourceTree = BUILT_PRODUCTS_DIR;
+		};
+		CD0C59C920C4127400454F82 /* gtest.framework */ = {
+			isa = PBXReferenceProxy;
+			fileType = wrapper.framework;
+			path = gtest.framework;
+			remoteRef = CD0C59C820C4127400454F82 /* PBXContainerItemProxy */;
+			sourceTree = BUILT_PRODUCTS_DIR;
+		};
+		CD0C59CB20C4127400454F82 /* GoogleMockTests.xctest */ = {
+			isa = PBXReferenceProxy;
+			fileType = wrapper.cfbundle;
+			path = GoogleMockTests.xctest;
+			remoteRef = CD0C59CA20C4127400454F82 /* PBXContainerItemProxy */;
+			sourceTree = BUILT_PRODUCTS_DIR;
+		};
+/* End PBXReferenceProxy section */
+
+/* Begin PBXResourcesBuildPhase section */
+		CD0C59CF20C412AD00454F82 /* Resources */ = {
+			isa = PBXResourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
 			);
-			inputPaths = (
-				"$(SRCROOT)/matrix.t.h",
-			);
-			name = "Run Script";
-			outputPaths = (
-				"$(DERIVED_FILE_DIR)/matrix_tc.cpp",
-			);
 			runOnlyForDeploymentPostprocessing = 0;
-			shellPath = /bin/sh;
-			shellScript = "cxxtestgen --error-printer -o matrix_tc.cpp matrix.t.h";
 		};
-/* End PBXShellScriptBuildPhase section */
+/* End PBXResourcesBuildPhase section */
 
 /* Begin PBXSourcesBuildPhase section */
-		CD0E42751D9B38A9002FFED1 /* Sources */ = {
+		CD0C59B120C4123700454F82 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				CD0C59BA20C4124700454F82 /* matrix_dummy.cpp in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		CD0C59CD20C412AD00454F82 /* Sources */ = {
 			isa = PBXSourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
-				CD0E428F1D9B39B1002FFED1 /* matrix_tc.cpp in Sources */,
+				CD0C59DF20C412C800454F82 /* matrix_test.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
 /* End PBXSourcesBuildPhase section */
 
+/* Begin PBXTargetDependency section */
+		CD0C59D820C412AD00454F82 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = CD0C59B420C4123700454F82 /* matrix */;
+			targetProxy = CD0C59D720C412AD00454F82 /* PBXContainerItemProxy */;
+		};
+		CD0C59DD20C412BF00454F82 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			name = GoogleMock;
+			targetProxy = CD0C59DC20C412BF00454F82 /* PBXContainerItemProxy */;
+		};
+/* End PBXTargetDependency section */
+
 /* Begin XCBuildConfiguration section */
+		CD0C59B620C4123800454F82 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				DYLIB_COMPATIBILITY_VERSION = 1;
+				DYLIB_CURRENT_VERSION = 1;
+				EXECUTABLE_PREFIX = lib;
+				PRODUCT_NAME = "$(TARGET_NAME)";
+			};
+			name = Debug;
+		};
+		CD0C59B720C4123800454F82 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				DYLIB_COMPATIBILITY_VERSION = 1;
+				DYLIB_CURRENT_VERSION = 1;
+				EXECUTABLE_PREFIX = lib;
+				PRODUCT_NAME = "$(TARGET_NAME)";
+			};
+			name = Release;
+		};
+		CD0C59DA20C412AD00454F82 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				COMBINE_HIDPI_IMAGES = YES;
+				INFOPLIST_FILE = matrix_test/Info.plist;
+				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
+				PRODUCT_BUNDLE_IDENTIFIER = "leumasjaffe.matrix-test";
+				PRODUCT_NAME = "$(TARGET_NAME)";
+			};
+			name = Debug;
+		};
+		CD0C59DB20C412AD00454F82 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				COMBINE_HIDPI_IMAGES = YES;
+				INFOPLIST_FILE = matrix_test/Info.plist;
+				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
+				PRODUCT_BUNDLE_IDENTIFIER = "leumasjaffe.matrix-test";
+				PRODUCT_NAME = "$(TARGET_NAME)";
+			};
+			name = Release;
+		};
 		CD0E427E1D9B38A9002FFED1 /* Debug */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
@@ -199,6 +388,8 @@
 				MTL_ENABLE_DEBUG_INFO = YES;
 				ONLY_ACTIVE_ARCH = YES;
 				SDKROOT = macosx;
+				USER_HEADER_SEARCH_PATHS = "../../paradigm/declarative ../";
+				WARNING_CFLAGS = "-Wno-gnu-zero-variadic-macro-arguments";
 			};
 			name = Debug;
 		};
@@ -235,44 +426,35 @@
 				MACOSX_DEPLOYMENT_TARGET = 10.10;
 				MTL_ENABLE_DEBUG_INFO = NO;
 				SDKROOT = macosx;
-			};
-			name = Release;
-		};
-		CD0E42811D9B38A9002FFED1 /* Debug */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				HEADER_SEARCH_PATHS = "${HOME}/Documents/Programming/Resources/cxxtest-4.4/";
-				PRODUCT_NAME = "$(TARGET_NAME)";
-				USER_HEADER_SEARCH_PATHS = "../../**";
-			};
-			name = Debug;
-		};
-		CD0E42821D9B38A9002FFED1 /* Release */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				HEADER_SEARCH_PATHS = "${HOME}/Documents/Programming/Resources/cxxtest-4.4/";
-				PRODUCT_NAME = "$(TARGET_NAME)";
-				USER_HEADER_SEARCH_PATHS = "../../**";
+				USER_HEADER_SEARCH_PATHS = "../../paradigm/declarative ../";
+				WARNING_CFLAGS = "-Wno-gnu-zero-variadic-macro-arguments";
 			};
 			name = Release;
 		};
 /* End XCBuildConfiguration section */
 
 /* Begin XCConfigurationList section */
-		CD0E42741D9B38A9002FFED1 /* Build configuration list for PBXProject "matrix" */ = {
+		CD0C59B820C4123800454F82 /* Build configuration list for PBXNativeTarget "matrix" */ = {
 			isa = XCConfigurationList;
 			buildConfigurations = (
-				CD0E427E1D9B38A9002FFED1 /* Debug */,
-				CD0E427F1D9B38A9002FFED1 /* Release */,
+				CD0C59B620C4123800454F82 /* Debug */,
+				CD0C59B720C4123800454F82 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+		};
+		CD0C59D920C412AD00454F82 /* Build configuration list for PBXNativeTarget "matrix_test" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				CD0C59DA20C412AD00454F82 /* Debug */,
+				CD0C59DB20C412AD00454F82 /* Release */,
 			);
 			defaultConfigurationIsVisible = 0;
-			defaultConfigurationName = Release;
 		};
-		CD0E42801D9B38A9002FFED1 /* Build configuration list for PBXNativeTarget "matrix_tc" */ = {
+		CD0E42741D9B38A9002FFED1 /* Build configuration list for PBXProject "matrix" */ = {
 			isa = XCConfigurationList;
 			buildConfigurations = (
-				CD0E42811D9B38A9002FFED1 /* Debug */,
-				CD0E42821D9B38A9002FFED1 /* Release */,
+				CD0E427E1D9B38A9002FFED1 /* Debug */,
+				CD0E427F1D9B38A9002FFED1 /* Release */,
 			);
 			defaultConfigurationIsVisible = 0;
 			defaultConfigurationName = Release;

+ 12 - 0
matrix_dummy.cpp

@@ -0,0 +1,12 @@
+//
+//  matrix_dummy.cpp
+//  matrix
+//
+//  Created by Sam Jaffe on 6/3/18.
+//
+
+#include "matrix.hpp"
+
+namespace math { namespace matrix {
+  template class matrix<int, 2, 2>;
+} }

+ 102 - 0
matrix_test.cpp

@@ -0,0 +1,102 @@
+//
+//  matrix_test.cpp
+//  matrix
+//
+//  Created by Sam Jaffe on 6/3/18.
+//
+
+#include <gmock/gmock.h>
+
+#include "matrix.hpp"
+#include "matrix_helpers.hpp"
+
+using matr2i = math::matrix::matrix<int, 2, 2>;
+using matr2 = math::matrix::matrix<double, 2, 2>;
+
+TEST(Matrix, _matrix_equals) {
+  using math::matrix::identity;
+  EXPECT_THAT((identity<int, 2>()), matr2i({{{1,0},{0,1}}}));
+}
+
+TEST(Matrix, _matrix_sum) {
+  auto iden = math::matrix::identity<int, 2>();
+  auto result = matr2i({{{2,0},{0,2}}});
+  EXPECT_THAT(iden + iden, result);
+}
+
+TEST(Matrix, _matrix_default_zero) {
+  auto zero = matr2i({{{0,0},{0,0}}});
+  EXPECT_THAT(matr2i{}, zero);
+}
+
+TEST(Matrix, _matrix_subtract) {
+  auto zero = matr2i({{{0,0},{0,0}}});
+  auto iden = math::matrix::identity<int, 2>();
+  EXPECT_THAT(iden-iden, zero);
+}
+
+//  TEST(Matrix, _matrix_negate) {
+//    auto iden = math::matrix::identity<int, 2>();
+//    EXPECT_THAT(-iden, matr2i({{{-1,0},{0,-1}}}));
+//  }
+
+TEST(Matrix, _matrix_scaling) {
+  auto iden = math::matrix::identity<double, 2>();
+  EXPECT_THAT(2*iden, matr2({{{2.0,0.0},{0.0,2.0}}}));
+  EXPECT_THAT(iden*2, matr2({{{2.0,0.0},{0.0,2.0}}}));
+  EXPECT_THAT(iden/2.0, matr2({{{0.5,0.0},{0.0,0.5}}}));
+}
+
+TEST(Matrix, _matrix_multiplication_same_dim) {
+  auto A = matr2i({{{1,2},{2,3}}});
+  auto B = matr2i({{{1,0},{1,1}}});
+  EXPECT_THAT(A*B, matr2i({{{3,2},{5,3}}}));
+  EXPECT_THAT(B*A, matr2i({{{1,2},{3,5}}}));
+}
+
+TEST(Matrix, _matrix_multiplication_diff_dim) {
+  using matr2x2i = math::matrix::matrix<int, 2, 2>;
+  using matr2x3i = math::matrix::matrix<int, 2, 3>;
+  using matr3x2i = math::matrix::matrix<int, 3, 2>;
+  using matr3x3i = math::matrix::matrix<int, 3, 3>;
+  auto A = matr3x2i({{{1,0},{0,1},{1,1}}});
+  auto B = matr2x3i({{{0,1,0},{1,0,1}}});
+  EXPECT_THAT(A*B, matr3x3i({{{0,1,0},{1,0,1},{1,1,1}}}));
+  EXPECT_THAT(B*A, matr2x2i({{{0,1},{2,1}}}));
+}
+
+TEST(Matrix, _matrix_vector_multiplication) {
+  using vec2i = math::vector::vector<int, 2>;
+  auto A = matr2i({{{1,0},{1,2}}});
+  auto x = vec2i({1,2});
+  EXPECT_THAT(A*x, vec2i({1,5}));
+}
+
+//  TEST(Matrix, _matrix_composition) {
+//    using namespace math::matrix;
+//    using vec4 = math::vector::vector<double, 4>;
+//    using vec3 = math::vector::vector<double, 3>;
+//    auto rot = rotation<4>(math::degree{90}, rotate::X_AXIS);
+//    auto mov = translation(vec3{2.0, 2.5, 1.5}});
+//    auto scl = scalar(vec3{2.0, math::vector::fill}});
+//    vec4 epsilon{0.00001, math::vector::fill};
+//    TS_ASSERT_DELTA((mov * scl * rot * vec4{1,2,3,1}}),
+//                     (vec4{4.0,-1.5,-4.5,1.0}}),
+//                    epsilon);
+//  }
+
+TEST(Matrix, _matrix_from_vector) {
+  using vec3 = math::vector::vector<double, 3>;
+  vec3 v = vec3({1,2,3});
+  math::matrix::matrix<double, 3, 1> m{v};
+  EXPECT_THAT(m(0,0), v[0]);
+  EXPECT_THAT(m(1,0), v[1]);
+  EXPECT_THAT(m(2,0), v[2]);
+}
+
+TEST(Matrix, _assign_row) {
+  matr2i A = math::matrix::identity<int, 2>();
+  matr2i const B = 2 * A;
+  A[0] = B[0];
+  EXPECT_THAT(A, matr2i({{{2,0},{0,1}}}));
+}

+ 24 - 0
matrix_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>