mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 05:52:44 +01:00
tests/unittests/turo: Add turo unittest
This commit is contained in:
parent
38884d24b2
commit
e9b65306ea
4
tests/unittests/tests-turo/Makefile
Normal file
4
tests/unittests/tests-turo/Makefile
Normal file
@ -0,0 +1,4 @@
|
||||
# Since the asserts are a part of the check we need to enable them.
|
||||
DEVELHELP=1
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
1
tests/unittests/tests-turo/Makefile.include
Normal file
1
tests/unittests/tests-turo/Makefile.include
Normal file
@ -0,0 +1 @@
|
||||
USEMODULE += test_utils_result_output_check
|
86
tests/unittests/tests-turo/tests-turo.c
Normal file
86
tests/unittests/tests-turo/tests-turo.c
Normal file
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (C) 2021 HAW Hamburg
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
/**
|
||||
* @ingroup tests
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Unit tests for test_utils_result_output module
|
||||
*
|
||||
* @author Kevin Weiss <kevin.weiss@haw-hamburg.de>
|
||||
*/
|
||||
#include "embUnit.h"
|
||||
#include "kernel_defines.h"
|
||||
#include "test_utils/result_output.h"
|
||||
|
||||
void test_turo_impl(void)
|
||||
{
|
||||
turo_t ctx;
|
||||
turo_init(&ctx);
|
||||
turo_container_open(&ctx);
|
||||
turo_s32(&ctx, -1);
|
||||
turo_u32(&ctx, 0xFFFFFFFF);
|
||||
turo_s64(&ctx, -1);
|
||||
turo_u64(&ctx, 0xFFFFFFFFFFFFFFFF);
|
||||
turo_float(&ctx, 0.00001);
|
||||
turo_string(&ctx, "foo");
|
||||
turo_bool(&ctx, true);
|
||||
turo_dict_open(&ctx);
|
||||
turo_dict_key(&ctx, "bar");
|
||||
turo_u32(&ctx, 0);
|
||||
turo_dict_close(&ctx);
|
||||
turo_array_open(&ctx);
|
||||
turo_u32(&ctx, 0);
|
||||
turo_array_close(&ctx);
|
||||
turo_container_close(&ctx, 0);
|
||||
}
|
||||
|
||||
void test_turo_helpers(void)
|
||||
{
|
||||
turo_t ctx;
|
||||
turo_init(&ctx);
|
||||
turo_container_open(&ctx);
|
||||
uint8_t buf8[] = {1, 2, 3};
|
||||
int32_t buf32[] = {-1, 1, 0x7FFFFFFF};
|
||||
turo_array_u8(&ctx, buf8, sizeof(buf8));
|
||||
turo_array_s32(&ctx, buf32, ARRAY_SIZE(buf32));
|
||||
turo_dict_string(&ctx, "foo", "bar");
|
||||
turo_dict_s32(&ctx, "baz", 42);
|
||||
turo_container_close(&ctx, 0);
|
||||
}
|
||||
|
||||
void test_turo_simple(void)
|
||||
{
|
||||
turo_t ctx;
|
||||
turo_init(&ctx);
|
||||
turo_simple_s32(&ctx, 42);
|
||||
uint8_t buf8[] = {1, 2, 3};
|
||||
int32_t buf32[] = {-1, 1, 0x7FFFFFFF};
|
||||
turo_simple_array_u8(&ctx, buf8, sizeof(buf8));
|
||||
turo_simple_array_s32(&ctx, buf32, ARRAY_SIZE(buf32));
|
||||
turo_simple_dict_string(&ctx, "foo", "bar");
|
||||
turo_simple_dict_s32(&ctx, "baz", 42);
|
||||
turo_simple_exit_status(&ctx, -1);
|
||||
}
|
||||
|
||||
Test *tests_turo_all(void)
|
||||
{
|
||||
EMB_UNIT_TESTFIXTURES(fixtures) {
|
||||
new_TestFixture(test_turo_impl),
|
||||
new_TestFixture(test_turo_helpers),
|
||||
new_TestFixture(test_turo_simple),
|
||||
};
|
||||
|
||||
EMB_UNIT_TESTCALLER(turo_tests, NULL, NULL, fixtures);
|
||||
return (Test *)&turo_tests;
|
||||
}
|
||||
|
||||
void tests_turo(void)
|
||||
{
|
||||
TESTS_RUN(tests_turo_all());
|
||||
}
|
Loading…
Reference in New Issue
Block a user