Skip to content

Commit

Permalink
FHSS unit tests: Updated FHSS config tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarkko Paso committed May 2, 2018
1 parent 490384f commit c8f5c8d
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 1 deletion.
Expand Up @@ -58,3 +58,23 @@ TEST(fhss_config, test_ns_fhss_ws_remove_parent)
{
CHECK(test_ns_fhss_ws_remove_parent());
}

TEST(fhss_config, test_ns_fhss_set_neighbor_info_fp)
{
CHECK(test_ns_fhss_set_neighbor_info_fp());
}

TEST(fhss_config, test_ns_fhss_ws_configuration_get)
{
CHECK(test_ns_fhss_ws_configuration_get());
}

TEST(fhss_config, test_ns_fhss_ws_configuration_set)
{
CHECK(test_ns_fhss_ws_configuration_set());
}

TEST(fhss_config, test_ns_fhss_ws_set_hop_count)
{
CHECK(test_ns_fhss_ws_set_hop_count());
}
Expand Up @@ -20,6 +20,7 @@
#include "fhss_config.h"
#include "net_fhss.h"
#include "Service_Libs/fhss/fhss.h"
#include "Service_Libs/fhss/fhss_ws.h"
#include "Service_Libs/fhss/fhss_common.h"
#include "test_fhss_config.h"
#include "nsdynmemLIB_stub.h"
Expand Down Expand Up @@ -153,3 +154,76 @@ bool test_ns_fhss_ws_remove_parent()
}
return true;
}

bool test_ns_fhss_set_neighbor_info_fp()
{
fhss_api_t api;
struct fhss_ws ws;
// Test without api
fhss_common_stub.bool_value = false;
if (-1 != ns_fhss_set_neighbor_info_fp(NULL, NULL)) {
return false;
}
// Test success
fhss_common_stub.bool_value = true;
fhss_common_stub.fhss_struct.ws = &ws;
if (0 != ns_fhss_set_neighbor_info_fp(&api, NULL)) {
return false;
}
return true;
}

bool test_ns_fhss_ws_configuration_get()
{
fhss_api_t api;
struct fhss_ws ws;
// Test without api
fhss_common_stub.bool_value = false;
if (NULL != ns_fhss_ws_configuration_get(NULL)) {
return false;
}
// Test success
fhss_common_stub.bool_value = true;
fhss_common_stub.fhss_struct.ws = &ws;
if (&ws.fhss_configuration != ns_fhss_ws_configuration_get(&api)) {
return false;
}
return true;
}

bool test_ns_fhss_ws_configuration_set()
{
fhss_api_t api;
struct fhss_ws ws;
const fhss_ws_configuration_t fhss_configuration;
// Test without api
fhss_common_stub.bool_value = false;
if (-1 != ns_fhss_ws_configuration_set(NULL, NULL)) {
return false;
}
// Test success
fhss_common_stub.bool_value = true;
fhss_common_stub.fhss_struct.ws = &ws;
if (0 != ns_fhss_ws_configuration_set(&api, &fhss_configuration)) {
return false;
}
return true;
}

bool test_ns_fhss_ws_set_hop_count()
{
fhss_api_t api;
struct fhss_ws ws;
// Test without api
fhss_common_stub.bool_value = false;
if (-1 != ns_fhss_ws_set_hop_count(NULL, 0)) {
return false;
}
// Test success
fhss_common_stub.bool_value = true;
fhss_common_stub.fhss_struct.ws = &ws;
if (0 != ns_fhss_ws_set_hop_count(&api, 0)) {
return false;
}
return true;
}
Expand Up @@ -35,7 +35,14 @@ bool test_ns_fhss_configuration_set();
bool test_ns_fhss_ws_set_parent();
// Test removing WS parent
bool test_ns_fhss_ws_remove_parent();

// Test setting neighbor info function pointer
bool test_ns_fhss_set_neighbor_info_fp();
// Test getting WS configuration
bool test_ns_fhss_ws_configuration_get();
// Test setting WS configuration
bool test_ns_fhss_ws_configuration_set();
// Test setting hop count
bool test_ns_fhss_ws_set_hop_count();

#ifdef __cplusplus
}
Expand Down

0 comments on commit c8f5c8d

Please sign in to comment.