From aa2ee1506087eea8174eb16b7dff630c34dfd7e0 Mon Sep 17 00:00:00 2001 From: Ari Koivula Date: Tue, 24 Sep 2013 18:36:33 +0300 Subject: [PATCH] Add a simple test for picture_list. - Add solution/src to includes for all projects. - Add solution/../../seatest to includes for all projects. --- build/C_Properties.props | 8 +- .../HEVC_encoder_tests.vcxproj | 4 + .../HEVC_encoder_tests.vcxproj.filters | 8 ++ tests/picture_list_tests.c | 97 +++++++++++++++++++ tests/picture_list_tests.h | 7 ++ tests/tests_main.c | 26 +---- 6 files changed, 125 insertions(+), 25 deletions(-) create mode 100644 tests/picture_list_tests.c create mode 100644 tests/picture_list_tests.h diff --git a/build/C_Properties.props b/build/C_Properties.props index 5a2306c1..e88d2846 100644 --- a/build/C_Properties.props +++ b/build/C_Properties.props @@ -2,17 +2,23 @@ - + + $(Platform)-$(Configuration)\ + $(SolutionDir)..\bin\$(Configuration)\ + CompileAsC Level3 AssemblyAndSourceCode MultiThreadedDebugDLL + WIN32;WIN64;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\src;$(SolutionDir)..\..\seatest\src;%(AdditionalIncludeDirectories) Ws2_32.lib;%(AdditionalDependencies) true + Console diff --git a/build/HEVC_encoder_tests/HEVC_encoder_tests.vcxproj b/build/HEVC_encoder_tests/HEVC_encoder_tests.vcxproj index c12be7a1..c255e6c5 100644 --- a/build/HEVC_encoder_tests/HEVC_encoder_tests.vcxproj +++ b/build/HEVC_encoder_tests/HEVC_encoder_tests.vcxproj @@ -20,6 +20,7 @@ + @@ -27,6 +28,9 @@ {eea3bdd1-8a08-41c1-ba57-e05d5c2cd8ff} + + + {3CD1C68B-542C-46D8-9B8A-6C91C5A3F312} HEVC_encoder_tests diff --git a/build/HEVC_encoder_tests/HEVC_encoder_tests.vcxproj.filters b/build/HEVC_encoder_tests/HEVC_encoder_tests.vcxproj.filters index 92cb951f..852ea854 100644 --- a/build/HEVC_encoder_tests/HEVC_encoder_tests.vcxproj.filters +++ b/build/HEVC_encoder_tests/HEVC_encoder_tests.vcxproj.filters @@ -21,5 +21,13 @@ Source Files + + Source Files + + + + + Header Files + \ No newline at end of file diff --git a/tests/picture_list_tests.c b/tests/picture_list_tests.c new file mode 100644 index 00000000..07f5622b --- /dev/null +++ b/tests/picture_list_tests.c @@ -0,0 +1,97 @@ +#include "seatest.h" + +#include "picture.h" + +////////////////////////////////////////////////////////////////////////// +// GLOBALS +picture_list *g_pl; // picturelist used by all tests. + + +////////////////////////////////////////////////////////////////////////// +// SETUP, TEARDOWN AND HELPER FUNCTIONS + +/** + * Alloc and initialize picture. Initialize yuv-data with parameter init. + */ +picture * make_pic(unsigned lcu_width, unsigned lcu_height, char init) { + picture *pic = picture_init(LCU_WIDTH * lcu_width, LCU_WIDTH * lcu_height, + lcu_width, lcu_height); + unsigned luma_size = pic->width * pic->height; + unsigned chroma_size = luma_size >> 2; + + memset(pic->y_data, init, luma_size); + memset(pic->u_data, init, chroma_size); + memset(pic->v_data, init, chroma_size); + + return pic; +} + +/** + * Setup initial conditions for all tests. + * + * The conditions are that g_pl is a picture list of size 10 with 10 pictures. + * The pictures have their yuv-data initialized with their index in the list, + * meaning that the first picture is filled with 0 values and the second with + * 1 values. + */ +void picturelist_setup(void) +{ + unsigned lcu_width = 2; + unsigned lcu_height = 2; + unsigned i; + + g_pl = picture_list_init(10); + assert_true(g_pl->size == 10); + assert_true(g_pl->used_size == 0); + + for (i = 0; i < g_pl->size; ++i) { + picture *pic = make_pic(lcu_width, lcu_height, i); + picture_list_add(g_pl, pic); + } + assert_true(g_pl->used_size == 10); +} + +/** + * Deallocate all memory allocated by picturelist_setup. + */ +void picturelist_teardown(void) +{ + picture_list_destroy(g_pl); +} + +////////////////////////////////////////////////////////////////////////// +// TEST FUNCTIONS + +/** + * Check that pictures have been added to the list in the correct order and + * that they can be retrieved. + */ +void test_add(void) +{ + unsigned i; + for (i = 0; i < g_pl->used_size; ++i) { + picture *pic = g_pl->pics[i]; + unsigned luma_size = pic->width * pic->height; + unsigned chroma_size = luma_size >> 2; + + // Identify that the correct picture is in the correct place by checking + // that the data values are the same as the index. + assert_true(pic->y_data[0] == i); + assert_true(pic->u_data[0] == i); + assert_true(pic->v_data[0] == i); + assert_true(pic->y_data[luma_size - 1] == i); + assert_true(pic->u_data[chroma_size - 1] == i); + assert_true(pic->v_data[chroma_size - 1] == i); + } +} + +////////////////////////////////////////////////////////////////////////// +// TEST FIXTURES +void picture_list_tests(void) +{ + test_fixture_start(); + fixture_setup(picturelist_setup); + run_test(test_add); + fixture_teardown(picturelist_teardown); + test_fixture_end(); +} diff --git a/tests/picture_list_tests.h b/tests/picture_list_tests.h new file mode 100644 index 00000000..d315b210 --- /dev/null +++ b/tests/picture_list_tests.h @@ -0,0 +1,7 @@ +#ifndef PICTURE_LIST_TESTS_H_ +#define PICTURE_LIST_TESTS_H_ + +void picture_list_tests(void); + +#endif + diff --git a/tests/tests_main.c b/tests/tests_main.c index 8d91a82c..489e2d02 100644 --- a/tests/tests_main.c +++ b/tests/tests_main.c @@ -1,33 +1,11 @@ -#ifdef _MSC_VER -#define _CRT_SECURE_NO_WARNINGS -#endif - -#include - #include "seatest.h" -void test1(void) -{ - assert_bit_set(0, 0x01); - assert_bit_set(2, 0x04); -} +#include "picture_list_tests.h" -void test2(void) -{ - assert_bit_set(0, 0x00); -} - -void fixture1(void) -{ - test_fixture_start(); - run_test(test1); - run_test(test2); - test_fixture_end(); -} void all_tests(void) { - fixture1(); + picture_list_tests(); } int main()