Add a test for subtracting a vector from itself.
@@ -279,6 +279,32 @@ vector_vec_norm_0(CuTest *tc)
___TEARDOWN___
}
+void
+vector_vec_sub_same(CuTest *tc)
+{
+ ___SETUP___
+ tsReal vec[5], dist;
+
+ ___GIVEN___
+ vec[0] = (tsReal) 1.0;
+ vec[1] = (tsReal) 2.0;
+ vec[2] = (tsReal) 3.0;
+ vec[3] = (tsReal) 4.0;
+ vec[4] = (tsReal) 5.0;
+
+ ___WHEN___
+ ts_vec_sub(vec, vec, 3, vec);
+ dist = ts_distance_varargs(tc, 3, vec, 0.0, 0.0, 0.0);
+
+ ___THEN___
+ CuAssertDblEquals(tc, 0.0, dist, POINT_EPSILON);
+ /* Check for out-of-bounds */
+ CuAssertDblEquals(tc, 4.0, vec[3], POINT_EPSILON);
+ CuAssertDblEquals(tc, 5.0, vec[4], POINT_EPSILON);
+
+ ___TEARDOWN___
+}
+
CuSuite *
get_vector_suite()
{
@@ -294,5 +320,6 @@ get_vector_suite()
SUITE_ADD_TEST(suite, vector_vec_mag_2_3_4);
SUITE_ADD_TEST(suite, vector_vec_mag_dim_0);
SUITE_ADD_TEST(suite, vector_vec_norm_0);
+ SUITE_ADD_TEST(suite, vector_vec_sub_same);
return suite;
}
