mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
tests: unittests: add netopt module unit tests
This commit is contained in:
parent
d18cb7a9c3
commit
fa5046cd03
1
tests/unittests/tests-netopt/Makefile
Normal file
1
tests/unittests/tests-netopt/Makefile
Normal file
@ -0,0 +1 @@
|
||||
include $(RIOTBASE)/Makefile.base
|
1
tests/unittests/tests-netopt/Makefile.include
Normal file
1
tests/unittests/tests-netopt/Makefile.include
Normal file
@ -0,0 +1 @@
|
||||
USEMODULE += netopt
|
54
tests/unittests/tests-netopt/tests-netopt.c
Normal file
54
tests/unittests/tests-netopt/tests-netopt.c
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
*/
|
||||
#include <string.h>
|
||||
|
||||
#include "embUnit.h"
|
||||
|
||||
#include "net/netopt.h"
|
||||
|
||||
#include "unittests-constants.h"
|
||||
#include "tests-netopt.h"
|
||||
|
||||
void test_netopt2str(void)
|
||||
{
|
||||
/* here we just test if netopt2str has a value defined for any given
|
||||
* NETOPT option code */
|
||||
for (int i = 0; i < NETOPT_NUMOF; i++) {
|
||||
TEST_ASSERT(strcmp(netopt2str(i), "unknown"));
|
||||
}
|
||||
}
|
||||
|
||||
void test_netopt2str_unknown(void)
|
||||
{
|
||||
TEST_ASSERT_EQUAL_INT(0, strcmp(netopt2str(NETOPT_NUMOF), "unknown"));
|
||||
}
|
||||
|
||||
|
||||
Test *tests_netopt_tests(void)
|
||||
{
|
||||
EMB_UNIT_TESTFIXTURES(fixtures) {
|
||||
new_TestFixture(test_netopt2str),
|
||||
new_TestFixture(test_netopt2str_unknown),
|
||||
};
|
||||
|
||||
EMB_UNIT_TESTCALLER(netopt_tests, NULL, NULL, fixtures);
|
||||
|
||||
return (Test *)&netopt_tests;
|
||||
}
|
||||
|
||||
void tests_netopt(void)
|
||||
{
|
||||
TESTS_RUN(tests_netopt_tests());
|
||||
}
|
||||
/** @} */
|
37
tests/unittests/tests-netopt/tests-netopt.h
Normal file
37
tests/unittests/tests-netopt/tests-netopt.h
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup unittests
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Unittests for the ``netopt`` module
|
||||
*
|
||||
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||||
*/
|
||||
#ifndef TESTS_NETOPT_H_
|
||||
#define TESTS_NETOPT_H_
|
||||
|
||||
#include "embUnit.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief The entry point of this test suite.
|
||||
*/
|
||||
void tests_netopt(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* TESTS_NETOPT_H_ */
|
||||
/** @} */
|
Loading…
Reference in New Issue
Block a user