Skip to content

Commit c8f5c8d

Browse files
author
Jarkko Paso
committed
FHSS unit tests: Updated FHSS config tests.
1 parent 490384f commit c8f5c8d

File tree

3 files changed

+102
-1
lines changed

3 files changed

+102
-1
lines changed

test/nanostack/unittest/service_libs/fhss_config/fhssconfigtest.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,23 @@ TEST(fhss_config, test_ns_fhss_ws_remove_parent)
5858
{
5959
CHECK(test_ns_fhss_ws_remove_parent());
6060
}
61+
62+
TEST(fhss_config, test_ns_fhss_set_neighbor_info_fp)
63+
{
64+
CHECK(test_ns_fhss_set_neighbor_info_fp());
65+
}
66+
67+
TEST(fhss_config, test_ns_fhss_ws_configuration_get)
68+
{
69+
CHECK(test_ns_fhss_ws_configuration_get());
70+
}
71+
72+
TEST(fhss_config, test_ns_fhss_ws_configuration_set)
73+
{
74+
CHECK(test_ns_fhss_ws_configuration_set());
75+
}
76+
77+
TEST(fhss_config, test_ns_fhss_ws_set_hop_count)
78+
{
79+
CHECK(test_ns_fhss_ws_set_hop_count());
80+
}

test/nanostack/unittest/service_libs/fhss_config/test_fhss_config.c

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "fhss_config.h"
2121
#include "net_fhss.h"
2222
#include "Service_Libs/fhss/fhss.h"
23+
#include "Service_Libs/fhss/fhss_ws.h"
2324
#include "Service_Libs/fhss/fhss_common.h"
2425
#include "test_fhss_config.h"
2526
#include "nsdynmemLIB_stub.h"
@@ -153,3 +154,76 @@ bool test_ns_fhss_ws_remove_parent()
153154
}
154155
return true;
155156
}
157+
158+
bool test_ns_fhss_set_neighbor_info_fp()
159+
{
160+
fhss_api_t api;
161+
struct fhss_ws ws;
162+
// Test without api
163+
fhss_common_stub.bool_value = false;
164+
if (-1 != ns_fhss_set_neighbor_info_fp(NULL, NULL)) {
165+
return false;
166+
}
167+
// Test success
168+
fhss_common_stub.bool_value = true;
169+
fhss_common_stub.fhss_struct.ws = &ws;
170+
if (0 != ns_fhss_set_neighbor_info_fp(&api, NULL)) {
171+
return false;
172+
}
173+
return true;
174+
}
175+
176+
bool test_ns_fhss_ws_configuration_get()
177+
{
178+
fhss_api_t api;
179+
struct fhss_ws ws;
180+
// Test without api
181+
fhss_common_stub.bool_value = false;
182+
if (NULL != ns_fhss_ws_configuration_get(NULL)) {
183+
return false;
184+
}
185+
// Test success
186+
fhss_common_stub.bool_value = true;
187+
fhss_common_stub.fhss_struct.ws = &ws;
188+
if (&ws.fhss_configuration != ns_fhss_ws_configuration_get(&api)) {
189+
return false;
190+
}
191+
return true;
192+
}
193+
194+
bool test_ns_fhss_ws_configuration_set()
195+
{
196+
fhss_api_t api;
197+
struct fhss_ws ws;
198+
const fhss_ws_configuration_t fhss_configuration;
199+
// Test without api
200+
fhss_common_stub.bool_value = false;
201+
if (-1 != ns_fhss_ws_configuration_set(NULL, NULL)) {
202+
return false;
203+
}
204+
// Test success
205+
fhss_common_stub.bool_value = true;
206+
fhss_common_stub.fhss_struct.ws = &ws;
207+
if (0 != ns_fhss_ws_configuration_set(&api, &fhss_configuration)) {
208+
return false;
209+
}
210+
return true;
211+
}
212+
213+
bool test_ns_fhss_ws_set_hop_count()
214+
{
215+
fhss_api_t api;
216+
struct fhss_ws ws;
217+
// Test without api
218+
fhss_common_stub.bool_value = false;
219+
if (-1 != ns_fhss_ws_set_hop_count(NULL, 0)) {
220+
return false;
221+
}
222+
// Test success
223+
fhss_common_stub.bool_value = true;
224+
fhss_common_stub.fhss_struct.ws = &ws;
225+
if (0 != ns_fhss_ws_set_hop_count(&api, 0)) {
226+
return false;
227+
}
228+
return true;
229+
}

test/nanostack/unittest/service_libs/fhss_config/test_fhss_config.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,14 @@ bool test_ns_fhss_configuration_set();
3535
bool test_ns_fhss_ws_set_parent();
3636
// Test removing WS parent
3737
bool test_ns_fhss_ws_remove_parent();
38-
38+
// Test setting neighbor info function pointer
39+
bool test_ns_fhss_set_neighbor_info_fp();
40+
// Test getting WS configuration
41+
bool test_ns_fhss_ws_configuration_get();
42+
// Test setting WS configuration
43+
bool test_ns_fhss_ws_configuration_set();
44+
// Test setting hop count
45+
bool test_ns_fhss_ws_set_hop_count();
3946

4047
#ifdef __cplusplus
4148
}

0 commit comments

Comments
 (0)