Commits

Anonymous committed 827507d

More constructor tests and an actual fix

Comments (0)

Files changed (2)

neglect/cpplib/include/neglect/_vector3.hpp

 
         // -- constructors
 
-        vector() : x(T()), y(T(), z(T()))
+        vector() : x(T()), y(T()), z(T())
         {
         }
 

neglect/tests/src/test_vectors.cpp

 
     NUT_TESTCASE(constructors)
     {
+        float x[2] = {3.0f, 6.0f};
         vector<float, 2> vec1;
         vector<float, 2> vec2(1.0f, 2.0f);
+        vector<float, 2> vec3(x);
 
         NUT_REQUIRE_EQUAL(vec1.size(), 2);
         NUT_REQUIRE_EQUAL(vec2.size(), 2);
+        NUT_REQUIRE_EQUAL(vec3.size(), 2);
 
         NUT_CHECK_EQUAL(vec1.x, 0.0f);
         NUT_CHECK_EQUAL(vec1.y, 0.0f);
         NUT_CHECK_EQUAL(vec2.x, 1.0f);
         NUT_CHECK_EQUAL(vec2.y, 2.0f);
+        NUT_CHECK_EQUAL(vec3.x, 3.0f);
+        NUT_CHECK_EQUAL(vec3.y, 6.0f);
     }
 
     NUT_TESTCASE(basic_math)
     }
 
 }
+
+NUT_TESTGROUP(vector3) {
+
+    NUT_TESTCASE(constructors)
+    {
+        float x[3] = {3.0f, 6.0f, 9.0f};
+        vector<float, 3> vec1;
+        vector<float, 3> vec2(1.0f, 2.0f, 3.0f);
+        vector<float, 3> vec3(x);
+
+        NUT_REQUIRE_EQUAL(vec1.size(), 3);
+        NUT_REQUIRE_EQUAL(vec2.size(), 3);
+        NUT_REQUIRE_EQUAL(vec3.size(), 3);
+
+        NUT_CHECK_EQUAL(vec1.x, 0.0f);
+        NUT_CHECK_EQUAL(vec1.y, 0.0f);
+        NUT_CHECK_EQUAL(vec1.z, 0.0f);
+        NUT_CHECK_EQUAL(vec2.x, 1.0f);
+        NUT_CHECK_EQUAL(vec2.y, 2.0f);
+        NUT_CHECK_EQUAL(vec2.z, 3.0f);
+        NUT_CHECK_EQUAL(vec3.x, 3.0f);
+        NUT_CHECK_EQUAL(vec3.y, 6.0f);
+        NUT_CHECK_EQUAL(vec3.z, 9.0f);
+    }
+}