From b155d825bed3110eda9d70e376d114796e6c9edb Mon Sep 17 00:00:00 2001 From: Ari Koivula Date: Fri, 11 Oct 2013 14:08:56 +0300 Subject: [PATCH] Add tests for movement vectors that are completely out of frame. --- tests/sad_tests.cpp | 76 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-) diff --git a/tests/sad_tests.cpp b/tests/sad_tests.cpp index 1452708b..b7e99f1f 100644 --- a/tests/sad_tests.cpp +++ b/tests/sad_tests.cpp @@ -64,7 +64,7 @@ void sad_teardown(void) } ////////////////////////////////////////////////////////////////////////// -// TESTS +// OVERLAPPING BOUNDARY TESTS void test_topleft(void) { assert_ulong_equal( @@ -128,6 +128,65 @@ void test_bottomright(void) TEST_SAD(3, 3)); } +////////////////////////////////////////////////////////////////////////// +// OUT OF FRAME TESTS + +void test_topleft_out(void) +{ + assert_ulong_equal( + 1*(8*8) - 64, + TEST_SAD(-8, -8)); +} + +void test_top_out(void) +{ + assert_ulong_equal( + (1+3)*8 + 2*(6*8) - 64, + TEST_SAD(0, -8)); +} + +void test_topright_out(void) +{ + assert_ulong_equal( + 3*(8*8) - 64, + TEST_SAD(8, -8)); +} + +void test_left_out(void) +{ + assert_ulong_equal( + (1+7)*8 + 4*(6*8) - 64, + TEST_SAD(-8, 0)); +} + +void test_right_out(void) +{ + assert_ulong_equal( + (3+9)*8 + 6*(6*8) - 64, + TEST_SAD(8, 0)); +} + +void test_bottomleft_out(void) +{ + assert_ulong_equal( + 7*(8*8) - 64, + TEST_SAD(-8, 8)); +} + +void test_bottom_out(void) +{ + assert_ulong_equal( + (7+9)*8 + 8*(6*8) - 64, + TEST_SAD(0, 8)); +} + +void test_bottomright_out(void) +{ + assert_ulong_equal( + 9*(8*8) - 64, + TEST_SAD(8, 8)); +} + ////////////////////////////////////////////////////////////////////////// // TEST FIXTURES void sad_tests(void) @@ -135,6 +194,8 @@ void sad_tests(void) test_fixture_start(); fixture_setup(sad_setup); + + // Tests for movement vectors that overlap frame. run_test(test_topleft); run_test(test_top); run_test(test_topright); @@ -147,6 +208,19 @@ void sad_tests(void) run_test(test_bottom); run_test(test_bottomright); + // Tests for movement vectors that are outside the frame. + run_test(test_topleft_out); + run_test(test_top_out); + run_test(test_topright_out); + + run_test(test_left_out); + run_test(test_right_out); + + run_test(test_bottomleft_out); + run_test(test_bottom_out); + run_test(test_bottomright_out); + + fixture_teardown(sad_teardown); test_fixture_end(); }