mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
unittests: added tests for bluetil_addr
This commit is contained in:
parent
81ff7ff65a
commit
ce5a08cd2c
1
tests/unittests/tests-bluetil/Makefile
Normal file
1
tests/unittests/tests-bluetil/Makefile
Normal file
@ -0,0 +1 @@
|
||||
include $(RIOTBASE)/Makefile.base
|
1
tests/unittests/tests-bluetil/Makefile.include
Normal file
1
tests/unittests/tests-bluetil/Makefile.include
Normal file
@ -0,0 +1 @@
|
||||
USEMODULE += bluetil_addr
|
64
tests/unittests/tests-bluetil/tests-bluetil.c
Normal file
64
tests/unittests/tests-bluetil/tests-bluetil.c
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Freie Universität Berlin
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "embUnit.h"
|
||||
#include "tests-bluetil.h"
|
||||
|
||||
#include "net/bluetil/addr.h"
|
||||
|
||||
#define ENABLE_DEBUG (0)
|
||||
#include "debug.h"
|
||||
|
||||
const uint8_t addr[][6] = {
|
||||
{ 0xfe, 0xaf, 0xfe, 0xaf, 0xfe, 0xaf },
|
||||
{ 0x03, 0x02, 0x01, 0xef, 0xcd, 0xab },
|
||||
{ 255, 255, 255, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, 0 },
|
||||
};
|
||||
|
||||
static void test_bluetil_addr(void)
|
||||
{
|
||||
char astr[BLUETIL_ADDR_STRLEN];
|
||||
char istr[BLUETIL_IPV6_IID_STRLEN];
|
||||
|
||||
bluetil_addr_sprint(astr, addr[0]);
|
||||
TEST_ASSERT_EQUAL_STRING("AF:FE:AF:FE:AF:FE", astr);
|
||||
bluetil_addr_ipv6_l2ll_sprint(istr, addr[0]);
|
||||
TEST_ASSERT_EQUAL_STRING("[FE80::FCAF:FEFF:FEAF:FEAF]", istr);
|
||||
|
||||
bluetil_addr_sprint(astr, addr[1]);
|
||||
TEST_ASSERT_EQUAL_STRING("AB:CD:EF:01:02:03", astr);
|
||||
bluetil_addr_ipv6_l2ll_sprint(istr, addr[1]);
|
||||
TEST_ASSERT_EQUAL_STRING("[FE80::0102:01FF:FEEF:CDAB]", istr);
|
||||
|
||||
bluetil_addr_sprint(astr, addr[2]);
|
||||
TEST_ASSERT_EQUAL_STRING("FF:FF:FF:FF:FF:FF", astr);
|
||||
bluetil_addr_ipv6_l2ll_sprint(istr, addr[2]);
|
||||
TEST_ASSERT_EQUAL_STRING("[FE80::FDFF:FFFF:FEFF:FFFF]", istr);
|
||||
|
||||
bluetil_addr_sprint(astr, addr[3]);
|
||||
TEST_ASSERT_EQUAL_STRING("00:00:00:00:00:00", astr);
|
||||
bluetil_addr_ipv6_l2ll_sprint(istr, addr[3]);
|
||||
TEST_ASSERT_EQUAL_STRING("[FE80::0200:00FF:FE00:0000]", istr);
|
||||
}
|
||||
|
||||
Test *tests_bluetil_tests(void)
|
||||
{
|
||||
EMB_UNIT_TESTFIXTURES(fixtures) {
|
||||
new_TestFixture(test_bluetil_addr),
|
||||
};
|
||||
|
||||
EMB_UNIT_TESTCALLER(bluetil_tests, NULL, NULL, fixtures);
|
||||
|
||||
return (Test *)&bluetil_tests;
|
||||
}
|
||||
|
||||
void tests_bluetil(void)
|
||||
{
|
||||
TESTS_RUN(tests_bluetil_tests());
|
||||
}
|
37
tests/unittests/tests-bluetil/tests-bluetil.h
Normal file
37
tests/unittests/tests-bluetil/tests-bluetil.h
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Freie Universität Berlin
|
||||
*
|
||||
* 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 bluetil module
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin>
|
||||
*/
|
||||
|
||||
#ifndef TESTS_BLUETIL_H
|
||||
#define TESTS_BLUETIL_H
|
||||
#include "embUnit/embUnit.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief The entry point of this test suite
|
||||
*/
|
||||
void tests_bluetil(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* TESTS_BLUETIL_H */
|
||||
/** @} */
|
Loading…
Reference in New Issue
Block a user