46 lines
909 B
C
46 lines
909 B
C
#include "unity.h"
|
|
#include "net/nl_names.h"
|
|
|
|
void setUp(void) {}
|
|
void tearDown(void) {}
|
|
|
|
static const uint8_t MAC[6] = {0x28, 0x6D, 0xCD, 0x5C, 0x68, 0x1F};
|
|
|
|
static void test_suffix(void)
|
|
{
|
|
char s[5];
|
|
nl_names_mac_suffix(MAC, s);
|
|
TEST_ASSERT_EQUAL_STRING("681f", s);
|
|
}
|
|
|
|
static void test_hostname(void)
|
|
{
|
|
char h[24];
|
|
nl_names_hostname(MAC, h, sizeof h);
|
|
TEST_ASSERT_EQUAL_STRING("ninlight-681f", h);
|
|
}
|
|
|
|
static void test_hostname_truncates_safely(void)
|
|
{
|
|
char h[8];
|
|
nl_names_hostname(MAC, h, sizeof h);
|
|
TEST_ASSERT_EQUAL_STRING("ninligh", h);
|
|
}
|
|
|
|
static void test_mac_str(void)
|
|
{
|
|
char m[18];
|
|
nl_names_mac_str(MAC, m);
|
|
TEST_ASSERT_EQUAL_STRING("28:6d:cd:5c:68:1f", m);
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
UNITY_BEGIN();
|
|
RUN_TEST(test_suffix);
|
|
RUN_TEST(test_hostname);
|
|
RUN_TEST(test_hostname_truncates_safely);
|
|
RUN_TEST(test_mac_str);
|
|
return UNITY_END();
|
|
}
|