Skip to content

Commit 75d2c02

Browse files
silabs-aydoganerzr
authored andcommitted
uic: zpc: UIC-3615: Add unit test for zpc_attribute_store module
(cherry picked from commit 56ccc7a52b2354ee2b2389d59880b58a41d54176) Forwarded: #11 Signed-off-by: Philippe Coval <philippe.coval@silabs.com>
1 parent 1bb69e5 commit 75d2c02

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed

applications/zpc/components/zpc_attribute_store/test/zwave_utils_test.c

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,126 @@ int suiteTearDown(int num_failures)
3939
/// Called before each and every test
4040
void setUp() {}
4141

42+
void test_get_nls_state_reported_happy_case()
43+
{
44+
zwave_node_id_t test_node_id = 119;
45+
attribute_store_node_t test_node_id_node = 1;
46+
attribute_store_node_t test_child_node = 2;
47+
48+
attribute_store_network_helper_get_zwave_node_id_node_ExpectAndReturn(
49+
test_node_id,
50+
test_node_id_node);
51+
52+
attribute_store_get_node_child_by_type_ExpectAndReturn(
53+
test_node_id_node,
54+
ATTRIBUTE_ZWAVE_NLS_STATE,
55+
0,
56+
test_child_node);
57+
58+
uint8_t nls_state = 0;
59+
attribute_store_read_value_ExpectAndReturn(test_child_node,
60+
REPORTED_ATTRIBUTE,
61+
NULL,
62+
sizeof(uint8_t),
63+
SL_STATUS_OK);
64+
attribute_store_read_value_IgnoreArg_read_value();
65+
attribute_store_read_value_ReturnMemThruPtr_read_value(&nls_state,
66+
sizeof(nls_state));
67+
68+
TEST_ASSERT_EQUAL(nls_state,
69+
zwave_get_nls_state(test_node_id, REPORTED_ATTRIBUTE));
70+
}
71+
72+
void test_get_nls_state_desired_happy_case()
73+
{
74+
zwave_node_id_t test_node_id = 119;
75+
attribute_store_node_t test_node_id_node = 1;
76+
attribute_store_node_t test_child_node = 2;
77+
78+
attribute_store_network_helper_get_zwave_node_id_node_ExpectAndReturn(
79+
test_node_id,
80+
test_node_id_node);
81+
82+
attribute_store_get_node_child_by_type_ExpectAndReturn(
83+
test_node_id_node,
84+
ATTRIBUTE_ZWAVE_NLS_STATE,
85+
0,
86+
test_child_node);
87+
88+
uint8_t nls_state = 0;
89+
attribute_store_read_value_ExpectAndReturn(test_child_node,
90+
DESIRED_ATTRIBUTE,
91+
NULL,
92+
sizeof(uint8_t),
93+
SL_STATUS_OK);
94+
attribute_store_read_value_IgnoreArg_read_value();
95+
attribute_store_read_value_ReturnMemThruPtr_read_value(&nls_state,
96+
sizeof(nls_state));
97+
98+
TEST_ASSERT_EQUAL(nls_state,
99+
zwave_get_nls_state(test_node_id, DESIRED_ATTRIBUTE));
100+
}
101+
102+
void test_get_nls_support_reported_happy_case()
103+
{
104+
zwave_node_id_t test_node_id = 119;
105+
attribute_store_node_t test_node_id_node = 1;
106+
attribute_store_node_t test_child_node = 2;
107+
108+
attribute_store_network_helper_get_zwave_node_id_node_ExpectAndReturn(
109+
test_node_id,
110+
test_node_id_node);
111+
112+
attribute_store_get_node_child_by_type_ExpectAndReturn(
113+
test_node_id_node,
114+
ATTRIBUTE_ZWAVE_NLS_SUPPORT,
115+
0,
116+
test_child_node);
117+
118+
uint8_t nls_state = 0;
119+
attribute_store_read_value_ExpectAndReturn(test_child_node,
120+
REPORTED_ATTRIBUTE,
121+
NULL,
122+
sizeof(uint8_t),
123+
SL_STATUS_OK);
124+
attribute_store_read_value_IgnoreArg_read_value();
125+
attribute_store_read_value_ReturnMemThruPtr_read_value(&nls_state,
126+
sizeof(nls_state));
127+
128+
TEST_ASSERT_EQUAL(nls_state,
129+
zwave_get_nls_support(test_node_id, REPORTED_ATTRIBUTE));
130+
}
131+
132+
void test_get_nls_support_desired_happy_case()
133+
{
134+
zwave_node_id_t test_node_id = 119;
135+
attribute_store_node_t test_node_id_node = 1;
136+
attribute_store_node_t test_child_node = 2;
137+
138+
attribute_store_network_helper_get_zwave_node_id_node_ExpectAndReturn(
139+
test_node_id,
140+
test_node_id_node);
141+
142+
attribute_store_get_node_child_by_type_ExpectAndReturn(
143+
test_node_id_node,
144+
ATTRIBUTE_ZWAVE_NLS_SUPPORT,
145+
0,
146+
test_child_node);
147+
148+
uint8_t nls_state = 0;
149+
attribute_store_read_value_ExpectAndReturn(test_child_node,
150+
DESIRED_ATTRIBUTE,
151+
NULL,
152+
sizeof(uint8_t),
153+
SL_STATUS_OK);
154+
attribute_store_read_value_IgnoreArg_read_value();
155+
attribute_store_read_value_ReturnMemThruPtr_read_value(&nls_state,
156+
sizeof(nls_state));
157+
158+
TEST_ASSERT_EQUAL(nls_state,
159+
zwave_get_nls_support(test_node_id, DESIRED_ATTRIBUTE));
160+
}
161+
42162
void test_get_operating_mode_happy_case_NL()
43163
{
44164
zwave_node_id_t test_node_id = 119;

0 commit comments

Comments
 (0)