diff --git a/src/test/cunit.c b/src/test/cunit.c index b2913a4..5a8ef43 100644 --- a/src/test/cunit.c +++ b/src/test/cunit.c @@ -99,7 +99,11 @@ int main(void) (NULL == CU_add_test(pSuite, "test1 finding center ob obj", test_find_center1)) || (NULL == CU_add_test(pSuite, "test2 finding center ob obj", - test_find_center2)) + test_find_center2)) || + (NULL == CU_add_test(pSuite, "test1 getting normalized scale factor", + test_get_normalized_scale_factor1)) || + (NULL == CU_add_test(pSuite, "test2 getting normalized scale factor", + test_get_normalized_scale_factor2)) ) { CU_cleanup_registry(); diff --git a/src/test/cunit.h b/src/test/cunit.h index 9e7b9c8..8ecbf53 100644 --- a/src/test/cunit.h +++ b/src/test/cunit.h @@ -38,3 +38,6 @@ void test_parse_obj4(void); void test_find_center1(void); void test_find_center2(void); + +void test_get_normalized_scale_factor1(void); +void test_get_normalized_scale_factor2(void); diff --git a/src/test/cunit_half_edge.c b/src/test/cunit_half_edge.c index 42eae54..dc1590b 100644 --- a/src/test/cunit_half_edge.c +++ b/src/test/cunit_half_edge.c @@ -462,3 +462,36 @@ void test_find_center2(void) CU_ASSERT_PTR_NULL(newvert); } + +void test_get_normalized_scale_factor1(void) +{ + char const * const string = "" + "v 9.0 10.0 11.0\n" + "v 11.0 10.0 11.0\n" + "v 9.0 11.0 11.0\n" + "v 11.0 11.0 11.0\n" + "v 9.0 11.0 9.0\n" + "v 11.0 11.0 9.0\n" + "v 9.0 10.0 9.0\n" + "v 11.0 10.0 9.0\n" + "f 1 2 4 3\n" + "f 3 4 6 5\n" + "f 5 6 8 7\n" + "f 7 8 2 1\n" + "f 2 8 6 4\n" + "f 7 1 3 5\n"; + + HE_obj *obj = parse_obj(string); + HE_vert *newvert = find_center(obj); + float factor = get_normalized_scale_factor(obj); + + CU_ASSERT_PTR_NOT_NULL(obj); + CU_ASSERT_EQUAL(factor, 0.2f); +} + +void test_get_normalized_scale_factor2(void) +{ + float factor = get_normalized_scale_factor(NULL); + + CU_ASSERT_EQUAL(factor, -1); +}