Forráskód Böngészése

Adding tests to reach 100% test coverage.

Sam Jaffe 5 éve
szülő
commit
8c95548604
1 módosított fájl, 38 hozzáadás és 1 törlés
  1. 38 1
      test/vector_test.cxx

+ 38 - 1
test/vector_test.cxx

@@ -23,10 +23,31 @@ using vec4i = math::vector::vector<int, 4>;
 
 vec2i iota2i() { return iota<int, 2>(); }
 vec3i iota3i() { return iota<int, 3>(); }
+vec4i iota4i() { return iota<int, 4>(); }
 
 TEST(Vector, Equality) {
   EXPECT_THAT((iota3i()), vec3i({1, 2, 3}));
-  EXPECT_THAT((iota3i()), ::testing::Not(vec3i({0, 2, 3})));
+  EXPECT_THAT((iota3i()), ::testing::Ne(vec3i({0, 2, 3})));
+}
+
+TEST(Vector, Comparison) {
+  vec3i const iota = iota3i();
+  vec3i const low_lt({0, 2, 3});
+  vec3i const mid_lt({1, 1, 3});
+  vec3i const high_lt({1, 2, 2});
+  vec3i const low_gt({2, 2, 3});
+  vec3i const mid_gt({1, 3, 3});
+  vec3i const high_gt({1, 2, 4});
+  EXPECT_THAT(iota, ::testing::Gt(low_lt));
+  EXPECT_THAT(iota, ::testing::Gt(mid_lt));
+  EXPECT_THAT(iota, ::testing::Gt(high_lt));
+  EXPECT_THAT(iota, ::testing::Ge(low_lt));
+  EXPECT_THAT(iota, ::testing::Ge(iota));
+  EXPECT_THAT(iota, ::testing::Lt(low_gt));
+  EXPECT_THAT(iota, ::testing::Lt(mid_gt));
+  EXPECT_THAT(iota, ::testing::Lt(high_gt));
+  EXPECT_THAT(iota, ::testing::Le(low_gt));
+  EXPECT_THAT(iota, ::testing::Le(iota));
 }
 
 TEST(Vector, DefaultConstructorIsAllZero) {
@@ -48,6 +69,22 @@ TEST(Vector, CanAccessVectorElements) {
   EXPECT_THAT(viota[2], 3);
 }
 
+TEST(Vector, CanAccessVectorElementsWithNames) {
+  math::vector::vector<int, 4> viota = iota4i();
+  EXPECT_THAT(viota.x(), 1);
+  EXPECT_THAT(viota.y(), 2);
+  EXPECT_THAT(viota.z(), 3);
+  EXPECT_THAT(viota.w(), 4);
+}
+
+TEST(Vector, CanAccessVectorElementsWithColorNames) {
+  math::vector::vector<int, 4> viota = iota4i();
+  EXPECT_THAT(viota.r(), 1);
+  EXPECT_THAT(viota.g(), 2);
+  EXPECT_THAT(viota.b(), 3);
+  EXPECT_THAT(viota.a(), 4);
+}
+
 TEST(Vector, AccessingOutOfRangeThrows) {
   EXPECT_THROW(iota3i().at(3), std::out_of_range);
 }