#include "./vector2_is_zero.h" #include "./../../helpers.h" // ==================== FP32 ==================== // static const int _TEST_FP32_ZERO_VECTOR2_AMOUNT = 5; static const int _TEST_FP32_NONZERO_VECTOR2_AMOUNT = 7; static const BGC_FP32_Vector2 _TEST_FP32_ZERO_VECTOR2_LIST[] = { { 0.0f, 0.0f }, { 0.75f * BGC_FP32_EPSYLON, 0.0f }, { -0.75f * BGC_FP32_EPSYLON, 0.0f }, { 0.0f, 0.75f * BGC_FP32_EPSYLON }, { 0.0f, -0.75f * BGC_FP32_EPSYLON } }; static const BGC_FP32_Vector2 _TEST_FP32_NONZERO_VECTOR2_LIST[] = { { 0.0f, 1.0f }, { 1.25f * BGC_FP32_EPSYLON, 0.0f }, { -1.25f * BGC_FP32_EPSYLON, 0.0f }, { 0.0f, 1.25f * BGC_FP32_EPSYLON }, { 0.0f, -1.25f * BGC_FP32_EPSYLON }, { 1.25f * BGC_FP32_EPSYLON, 1.25f * BGC_FP32_EPSYLON }, { -1.25f * BGC_FP32_EPSYLON, -1.25f * BGC_FP32_EPSYLON } }; void test_vector2_is_zero_fp32() { print_testing_name("bgc_fp32_vector2_is_zero"); // Testing zero values: for (int i = 0; i < _TEST_FP32_ZERO_VECTOR2_AMOUNT; i++) { if (!bgc_fp32_vector2_is_zero(&_TEST_FP32_ZERO_VECTOR2_LIST[i])) { print_testing_error("A zero vector was not recongized"); return; } } // Testing non-zero values: for (int i = 0; i < _TEST_FP32_NONZERO_VECTOR2_AMOUNT; i++) { if (bgc_fp32_vector2_is_zero(&_TEST_FP32_NONZERO_VECTOR2_LIST[i])) { print_testing_error("A non-zero vector was recongized as a zero vector"); return; } } print_testing_success(); } // ==================== FP64 ==================== // static const int _TEST_FP64_ZERO_VECTOR2_AMOUNT = 5; static const int _TEST_FP64_NONZERO_VECTOR2_AMOUNT = 7; static const BGC_FP64_Vector2 _TEST_FP64_ZERO_VECTOR2_LIST[] = { { 0.0, 0.0 }, { 0.75 * BGC_FP64_EPSYLON, 0.0 }, { -0.75 * BGC_FP64_EPSYLON, 0.0 }, { 0.0, 0.75 * BGC_FP64_EPSYLON }, { 0.0, -0.75 * BGC_FP64_EPSYLON } }; static const BGC_FP64_Vector2 _TEST_FP64_NONZERO_VECTOR2_LIST[] = { { 0.0, 1.0 }, { 1.25 * BGC_FP64_EPSYLON, 0.0 }, { -1.25 * BGC_FP64_EPSYLON, 0.0 }, { 0.0, 1.25 * BGC_FP64_EPSYLON }, { 0.0, -1.25 * BGC_FP64_EPSYLON }, { 1.25 * BGC_FP64_EPSYLON, 1.25 * BGC_FP64_EPSYLON }, { -1.25 * BGC_FP64_EPSYLON, -1.25 * BGC_FP64_EPSYLON } }; void test_vector2_is_zero_fp64() { print_testing_name("bgc_fp64_vector2_is_zero"); // Testing zero values: for (int i = 0; i < _TEST_FP64_ZERO_VECTOR2_AMOUNT; i++) { if (!bgc_fp64_vector2_is_zero(&_TEST_FP64_ZERO_VECTOR2_LIST[i])) { print_testing_error("A zero vector was not recongized"); return; } } // Testing non-zero values: for (int i = 0; i < _TEST_FP64_NONZERO_VECTOR2_AMOUNT; i++) { if (bgc_fp64_vector2_is_zero(&_TEST_FP64_NONZERO_VECTOR2_LIST[i])) { print_testing_error("A non-zero vector was recongized as a zero vector"); return; } } print_testing_success(); } void test_vector2_is_zero() { test_vector2_is_zero_fp32(); test_vector2_is_zero_fp64(); }