Skip to content

Commit

Permalink
Unit tests: DH1CF channel function tests implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarkko Paso committed Jan 10, 2018
1 parent fbd5568 commit 5d0f44e
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
Expand Up @@ -48,3 +48,13 @@ TEST(channel_functions, test_tr51_calculate_hopping_sequence)
{
CHECK(test_tr51_calculate_hopping_sequence());
}

TEST(channel_functions, test_dh1cf_get_uc_channel_index)
{
CHECK(test_dh1cf_get_uc_channel_index());
}

TEST(channel_functions, test_dh1cf_get_bc_channel_index)
{
CHECK(test_dh1cf_get_bc_channel_index());
}
Expand Up @@ -54,6 +54,7 @@ const int32_t test_HopSequenceTable [129] = { 4,93,31,84,55,3,116,123,
77,48,100,51,14,21,94,23,
22 };


bool test_tr51_get_rand()
{
tr51_seed_rand(1);
Expand Down Expand Up @@ -143,3 +144,53 @@ bool test_tr51_calculate_hopping_sequence()

return true;
}

bool test_dh1cf_get_uc_channel_index()
{
int32_t test_dh1cf_channel_table_1[10] = {19, 128, 3, 53, 79, 24, 68, 118, 7, 51};
uint8_t mac_1[8] = {0x00, 0x13, 0x50, 0x04, 0x00, 0x00, 0x05, 0xf8};
int i;
// Test generating channel table for specific MAC addresses and slot numbers
for (i=0; i<10; i++) {
if (test_dh1cf_channel_table_1[i] != dh1cf_get_uc_channel_index(10738+i, mac_1, 129)) {
return false;
}
}

int32_t test_dh1cf_channel_table_2[10] = {82, 47, 102, 83, 89, 5, 23, 121, 70, 98};
uint8_t mac_2[8] = {0x00, 0x13, 0x50, 0x04, 0x00, 0x00, 0x06, 0x02};

for (i=0; i<10; i++) {
if (test_dh1cf_channel_table_2[i] != dh1cf_get_uc_channel_index(16446+i, mac_2, 129)) {
return false;
}
}
return true;
}

bool test_dh1cf_get_bc_channel_index()
{
int32_t test_dh1cf_channel_table_1[10] = {107, 46, 75, 88, 27, 23, 114, 86, 75, 115};
int i;
// Test generating channel table for specific broadcast schedule identifiers and slot numbers
for (i=0; i<10; i++) {
if (test_dh1cf_channel_table_1[i] != dh1cf_get_bc_channel_index(10738+i, 1, 129)) {
return false;
}
}
int32_t test_dh1cf_channel_table_2[10] = {112, 122, 121, 22, 54, 91, 116, 14, 102, 68};
for (i=0; i<10; i++) {
if (test_dh1cf_channel_table_2[i] != dh1cf_get_bc_channel_index(10738+i, 2, 129)) {
return false;
}
}

int32_t test_dh1cf_channel_table_3[10] = {60, 96, 3, 120, 8, 109, 80, 42, 96, 91};
for (i=0; i<10; i++) {
if (test_dh1cf_channel_table_3[i] != dh1cf_get_bc_channel_index(10738+i, 100, 129)) {
return false;
}

}
return true;
}
Expand Up @@ -27,6 +27,8 @@ bool test_tr51_get_rand();
bool test_tr51_calculate_channel_table();
bool test_tr51_compute_cfd();
bool test_tr51_calculate_hopping_sequence();
bool test_dh1cf_get_uc_channel_index();
bool test_dh1cf_get_bc_channel_index();

#ifdef __cplusplus
}
Expand Down

0 comments on commit 5d0f44e

Please sign in to comment.