engine_control/source/test/firmware/kernel/ringbuffer/cunit_ringbuffer.c
2016-07-23 07:59:54 +02:00

68 lines
1.1 KiB
C
Executable File

#include <CUnit/CUnit.h>
#include <CUnit/Basic.h>
#if 0
#include <CUnit/Automated.h>
#endif
#include "ringbuffer.h"
static int init_suite(void)
{
return 0;
}
static int clean_suite(void)
{
return 0;
}
/* DUT */
static char mem[10];
static struct ringbuffer rb = {
mem,
mem,
mem,
sizeof(mem),
0
};
static void test_ringbuffer_size(void)
{
char str[] = "0123456789ABCDEFGHI";
CU_ASSERT(sizeof(mem) == ringbuffer_write(&rb, str, sizeof(str)));
}
int main(void)
{
/* test suite section */
CU_pSuite suite = NULL;
if(CUE_SUCCESS != CU_initialize_registry())
goto exit_2;
suite = CU_add_suite("list test suite", init_suite, clean_suite);
if(NULL == suite)
goto exit_1;
/* test case section */
if(
NULL == CU_add_test(suite, "ringbuffer size", test_ringbuffer_size)
)
goto exit_1;
/* basic interface using tests */
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
CU_basic_show_failures(CU_get_failure_list());
#if 0
/* automated interface using tests */
CU_automated_run_tests();
CU_list_tests_to_file();
#endif
exit_1:
CU_cleanup_registry();
exit_2:
return CU_get_error();
}