diff --git a/tests/unittests/tests-netopt/Makefile b/tests/unittests/tests-netopt/Makefile new file mode 100644 index 0000000000..48422e909a --- /dev/null +++ b/tests/unittests/tests-netopt/Makefile @@ -0,0 +1 @@ +include $(RIOTBASE)/Makefile.base diff --git a/tests/unittests/tests-netopt/Makefile.include b/tests/unittests/tests-netopt/Makefile.include new file mode 100644 index 0000000000..8351bb5b3f --- /dev/null +++ b/tests/unittests/tests-netopt/Makefile.include @@ -0,0 +1 @@ +USEMODULE += netopt diff --git a/tests/unittests/tests-netopt/tests-netopt.c b/tests/unittests/tests-netopt/tests-netopt.c new file mode 100644 index 0000000000..1830511d3b --- /dev/null +++ b/tests/unittests/tests-netopt/tests-netopt.c @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2015 Kaspar Schleiser + * + * 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 + +#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()); +} +/** @} */ diff --git a/tests/unittests/tests-netopt/tests-netopt.h b/tests/unittests/tests-netopt/tests-netopt.h new file mode 100644 index 0000000000..9c187f3792 --- /dev/null +++ b/tests/unittests/tests-netopt/tests-netopt.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2015 Kaspar Schleiser + * + * 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 + */ +#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_ */ +/** @} */