Add a simple test for picture_list.

- Add solution/src to includes for all projects.
- Add solution/../../seatest to includes for all projects.
This commit is contained in:
Ari Koivula 2013-09-24 18:36:33 +03:00
parent 91e3d76aef
commit aa2ee15060
6 changed files with 125 additions and 25 deletions

View file

@ -2,17 +2,23 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<PropertyGroup>
<IntDir>$(Platform)-$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)..\bin\$(Configuration)\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<CompileAs>CompileAsC</CompileAs>
<WarningLevel>Level3</WarningLevel>
<AssemblerOutput>AssemblyAndSourceCode</AssemblerOutput>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PreprocessorDefinitions>WIN32;WIN64;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)..\src;$(SolutionDir)..\..\seatest\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<AdditionalDependencies>Ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemGroup />

View file

@ -20,6 +20,7 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\seatest\src\seatest.c" />
<ClCompile Include="..\..\tests\picture_list_tests.c" />
<ClCompile Include="..\..\tests\tests_main.c" />
</ItemGroup>
<ItemGroup>
@ -27,6 +28,9 @@
<Project>{eea3bdd1-8a08-41c1-ba57-e05d5c2cd8ff}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\tests\picture_list_tests.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{3CD1C68B-542C-46D8-9B8A-6C91C5A3F312}</ProjectGuid>
<RootNamespace>HEVC_encoder_tests</RootNamespace>

View file

@ -21,5 +21,13 @@
<ClCompile Include="..\..\tests\tests_main.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\tests\picture_list_tests.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\tests\picture_list_tests.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View file

@ -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();
}

View file

@ -0,0 +1,7 @@
#ifndef PICTURE_LIST_TESTS_H_
#define PICTURE_LIST_TESTS_H_
void picture_list_tests(void);
#endif

View file

@ -1,33 +1,11 @@
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <stdio.h>
#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()