Browse Source

Better name, less excess

Sam Jaffe 5 years ago
parent
commit
2a41d387f1
2 changed files with 12 additions and 12 deletions
  1. 4 4
      opaque_typedef.xcodeproj/project.pbxproj
  2. 8 8
      test/opaque_typedef_arithmatic_test.cxx

+ 4 - 4
opaque_typedef.xcodeproj/project.pbxproj

@@ -11,7 +11,7 @@
 		CD70491520C48B8C007C944C /* GoogleMock.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CD7048FB20C48B30007C944C /* GoogleMock.framework */; };
 		CDE8546724DF5051006FE7C7 /* opaque_typedef in Resources */ = {isa = PBXBuildFile; fileRef = CDE8546624DF5051006FE7C7 /* opaque_typedef */; };
 		CDE8547324DF80EE006FE7C7 /* opaque_typedef_comparable_test.cxx in Sources */ = {isa = PBXBuildFile; fileRef = CDE8547224DF80EE006FE7C7 /* opaque_typedef_comparable_test.cxx */; };
-		CDE8547524DF8110006FE7C7 /* opaque_typedef_arithmatic_test.cxx in Sources */ = {isa = PBXBuildFile; fileRef = CDE8547424DF8110006FE7C7 /* opaque_typedef_arithmatic_test.cxx */; };
+		CDE8547524DF8110006FE7C7 /* opaque_typedef_adhoc_arithmatic_test.cxx in Sources */ = {isa = PBXBuildFile; fileRef = CDE8547424DF8110006FE7C7 /* opaque_typedef_adhoc_arithmatic_test.cxx */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
@@ -59,7 +59,7 @@
 		CD70490B20C48B75007C944C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
 		CDE8546624DF5051006FE7C7 /* opaque_typedef */ = {isa = PBXFileReference; lastKnownFileType = folder; name = opaque_typedef; path = include/opaque_typedef; sourceTree = "<group>"; };
 		CDE8547224DF80EE006FE7C7 /* opaque_typedef_comparable_test.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = opaque_typedef_comparable_test.cxx; sourceTree = "<group>"; };
-		CDE8547424DF8110006FE7C7 /* opaque_typedef_arithmatic_test.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = opaque_typedef_arithmatic_test.cxx; sourceTree = "<group>"; };
+		CDE8547424DF8110006FE7C7 /* opaque_typedef_adhoc_arithmatic_test.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = opaque_typedef_adhoc_arithmatic_test.cxx; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -98,7 +98,7 @@
 			children = (
 				CD7048F020C48AE4007C944C /* opaque_typedef_conversion_test.cxx */,
 				CDE8547224DF80EE006FE7C7 /* opaque_typedef_comparable_test.cxx */,
-				CDE8547424DF8110006FE7C7 /* opaque_typedef_arithmatic_test.cxx */,
+				CDE8547424DF8110006FE7C7 /* opaque_typedef_adhoc_arithmatic_test.cxx */,
 			);
 			path = test;
 			sourceTree = "<group>";
@@ -228,7 +228,7 @@
 			isa = PBXSourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
-				CDE8547524DF8110006FE7C7 /* opaque_typedef_arithmatic_test.cxx in Sources */,
+				CDE8547524DF8110006FE7C7 /* opaque_typedef_adhoc_arithmatic_test.cxx in Sources */,
 				CDE8547324DF80EE006FE7C7 /* opaque_typedef_comparable_test.cxx in Sources */,
 				CD70491220C48B7C007C944C /* opaque_typedef_conversion_test.cxx in Sources */,
 			);

+ 8 - 8
test/opaque_typedef_arithmatic_test.cxx

@@ -15,20 +15,20 @@
 using namespace types;
 using testing::StaticAssertTypeEq;
 
-using meters = opaque_typedef<double, struct meters_tag, EqualityComparable>;
-using seconds = opaque_typedef<double, struct seconds_tag, EqualityComparable>;
-using mps = opaque_typedef<double, struct mps_tag, EqualityComparable>;
+using meters = opaque_typedef<double, struct meters_tag>;
+using seconds = opaque_typedef<double, struct seconds_tag>;
+using mps = opaque_typedef<double, struct mps_tag>;
 
 mps operator/(meters m, seconds s) {
   return mps{m.get() / s.get()};
 }
 
-void PrintTo(meters const & ot, std::ostream * os) {
-  (*os) << double(ot) << "m";
+std::ostream & operator<<(std::ostream & os, meters const & ot) {
+  return os << double(ot) << "m";
 }
 
-void PrintTo(seconds const & ot, std::ostream * os) {
-  (*os) << double(ot) << "s";
+std::ostream & operator<<(std::ostream & os, seconds const & ot) {
+  return os << double(ot) << "s";
 }
 
 void PrintTo(mps const & ot, std::ostream * os) {
@@ -45,5 +45,5 @@ TEST(OpaqueTypedefArithmaticTest, CanDefineExternalFunctionsForTypeMerging) {
   seconds s{0.5};
 
   EXPECT_TRUE((StaticAssertTypeEq<mps, decltype(m/s)>()));
-  EXPECT_THAT((m/s), mps(20.0));
+  EXPECT_THAT((m/s), mps(20.0)) << "     lhs: " << m << "\n     rhs: " <<  s;
 }