Skip to content

Commit 45231c0

Browse files
cmake tests removing params
1 parent 2260338 commit 45231c0

File tree

2 files changed

+98
-98
lines changed

2 files changed

+98
-98
lines changed

extras/test/src/test_command_decode.cpp

Lines changed: 85 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ SCENARIO("Test the decoding of command messages") {
4444

4545
THEN("The decode is successful") {
4646
REQUIRE(err == Decoder::Status::Complete);
47-
REQUIRE(strcmp(command.thingUpdateCmd.params.thing_id, thingIdToMatch) == 0);
47+
REQUIRE(strcmp(command.thingUpdateCmd.thing_id, thingIdToMatch) == 0);
4848
REQUIRE(command.c.id == ThingUpdateCmdId);
4949
}
5050
}
@@ -73,7 +73,7 @@ SCENARIO("Test the decoding of command messages") {
7373

7474
THEN("The decode is successful") {
7575
REQUIRE(err == Decoder::Status::Complete);
76-
REQUIRE(strcmp(command.thingDetachCmd.params.thing_id, thingIdToMatch) == 0);
76+
REQUIRE(strcmp(command.thingDetachCmd.thing_id, thingIdToMatch) == 0);
7777
REQUIRE(command.c.id == ThingDetachCmdId);
7878
}
7979
}
@@ -143,8 +143,8 @@ SCENARIO("Test the decoding of command messages") {
143143

144144
THEN("The decode is successful") {
145145
REQUIRE(err == Decoder::Status::Complete);
146-
REQUIRE(command.timezoneCommandDown.params.offset == (uint32_t)1708963873);
147-
REQUIRE(command.timezoneCommandDown.params.until == (uint32_t)2024579473);
146+
REQUIRE(command.timezoneCommandDown.offset == (uint32_t)1708963873);
147+
REQUIRE(command.timezoneCommandDown.until == (uint32_t)2024579473);
148148
REQUIRE(command.c.id == TimezoneCommandDownId);
149149
}
150150
}
@@ -173,23 +173,23 @@ SCENARIO("Test the decoding of command messages") {
173173

174174
THEN("The decode is successful") {
175175
REQUIRE(err == Decoder::Status::Complete);
176-
REQUIRE(command.lastValuesUpdateCmd.params.length == 13);
177-
REQUIRE(command.lastValuesUpdateCmd.params.last_values[0] == (uint8_t)0x00);
178-
REQUIRE(command.lastValuesUpdateCmd.params.last_values[1] == (uint8_t)0x01);
179-
REQUIRE(command.lastValuesUpdateCmd.params.last_values[2] == (uint8_t)0x02);
180-
REQUIRE(command.lastValuesUpdateCmd.params.last_values[3] == (uint8_t)0x03);
181-
REQUIRE(command.lastValuesUpdateCmd.params.last_values[4] == (uint8_t)0x04);
182-
REQUIRE(command.lastValuesUpdateCmd.params.last_values[5] == (uint8_t)0x05);
183-
REQUIRE(command.lastValuesUpdateCmd.params.last_values[6] == (uint8_t)0x06);
184-
REQUIRE(command.lastValuesUpdateCmd.params.last_values[7] == (uint8_t)0x07);
185-
REQUIRE(command.lastValuesUpdateCmd.params.last_values[8] == (uint8_t)0x08);
186-
REQUIRE(command.lastValuesUpdateCmd.params.last_values[9] == (uint8_t)0x09);
187-
REQUIRE(command.lastValuesUpdateCmd.params.last_values[10] == (uint8_t)0x10);
188-
REQUIRE(command.lastValuesUpdateCmd.params.last_values[11] == (uint8_t)0x11);
189-
REQUIRE(command.lastValuesUpdateCmd.params.last_values[12] == (uint8_t)0x12);
176+
REQUIRE(command.lastValuesUpdateCmd.length == 13);
177+
REQUIRE(command.lastValuesUpdateCmd.last_values[0] == (uint8_t)0x00);
178+
REQUIRE(command.lastValuesUpdateCmd.last_values[1] == (uint8_t)0x01);
179+
REQUIRE(command.lastValuesUpdateCmd.last_values[2] == (uint8_t)0x02);
180+
REQUIRE(command.lastValuesUpdateCmd.last_values[3] == (uint8_t)0x03);
181+
REQUIRE(command.lastValuesUpdateCmd.last_values[4] == (uint8_t)0x04);
182+
REQUIRE(command.lastValuesUpdateCmd.last_values[5] == (uint8_t)0x05);
183+
REQUIRE(command.lastValuesUpdateCmd.last_values[6] == (uint8_t)0x06);
184+
REQUIRE(command.lastValuesUpdateCmd.last_values[7] == (uint8_t)0x07);
185+
REQUIRE(command.lastValuesUpdateCmd.last_values[8] == (uint8_t)0x08);
186+
REQUIRE(command.lastValuesUpdateCmd.last_values[9] == (uint8_t)0x09);
187+
REQUIRE(command.lastValuesUpdateCmd.last_values[10] == (uint8_t)0x10);
188+
REQUIRE(command.lastValuesUpdateCmd.last_values[11] == (uint8_t)0x11);
189+
REQUIRE(command.lastValuesUpdateCmd.last_values[12] == (uint8_t)0x12);
190190
REQUIRE(command.c.id == LastValuesUpdateCmdId);
191191
}
192-
free(command.lastValuesUpdateCmd.params.last_values);
192+
free(command.lastValuesUpdateCmd.last_values);
193193
}
194194

195195
/****************************************************************************/
@@ -257,75 +257,75 @@ SCENARIO("Test the decoding of command messages") {
257257

258258
THEN("The decode is successful") {
259259
REQUIRE(err == Decoder::Status::Complete);
260-
REQUIRE(memcmp(command.otaUpdateCmdDown.params.id, otaIdToMatch, ID_SIZE) == 0);
261-
REQUIRE(strcmp(command.otaUpdateCmdDown.params.url, urlToMatch) == 0);
260+
REQUIRE(memcmp(command.otaUpdateCmdDown.id, otaIdToMatch, ID_SIZE) == 0);
261+
REQUIRE(strcmp(command.otaUpdateCmdDown.url, urlToMatch) == 0);
262262
// Initial SHA256 check
263-
REQUIRE(command.otaUpdateCmdDown.params.initialSha256[0] == (uint8_t)0x00);
264-
REQUIRE(command.otaUpdateCmdDown.params.initialSha256[1] == (uint8_t)0x00);
265-
REQUIRE(command.otaUpdateCmdDown.params.initialSha256[2] == (uint8_t)0x00);
266-
REQUIRE(command.otaUpdateCmdDown.params.initialSha256[3] == (uint8_t)0x00);
267-
REQUIRE(command.otaUpdateCmdDown.params.initialSha256[4] == (uint8_t)0x00);
268-
REQUIRE(command.otaUpdateCmdDown.params.initialSha256[5] == (uint8_t)0x00);
269-
REQUIRE(command.otaUpdateCmdDown.params.initialSha256[6] == (uint8_t)0x00);
270-
REQUIRE(command.otaUpdateCmdDown.params.initialSha256[7] == (uint8_t)0x00);
271-
REQUIRE(command.otaUpdateCmdDown.params.initialSha256[8] == (uint8_t)0x00);
272-
REQUIRE(command.otaUpdateCmdDown.params.initialSha256[9] == (uint8_t)0x00);
273-
REQUIRE(command.otaUpdateCmdDown.params.initialSha256[10] == (uint8_t)0x00);
274-
REQUIRE(command.otaUpdateCmdDown.params.initialSha256[11] == (uint8_t)0x00);
275-
REQUIRE(command.otaUpdateCmdDown.params.initialSha256[12] == (uint8_t)0x00);
276-
REQUIRE(command.otaUpdateCmdDown.params.initialSha256[13] == (uint8_t)0x00);
277-
REQUIRE(command.otaUpdateCmdDown.params.initialSha256[14] == (uint8_t)0x00);
278-
REQUIRE(command.otaUpdateCmdDown.params.initialSha256[15] == (uint8_t)0x00);
279-
REQUIRE(command.otaUpdateCmdDown.params.initialSha256[16] == (uint8_t)0x00);
280-
REQUIRE(command.otaUpdateCmdDown.params.initialSha256[17] == (uint8_t)0x00);
281-
REQUIRE(command.otaUpdateCmdDown.params.initialSha256[18] == (uint8_t)0x00);
282-
REQUIRE(command.otaUpdateCmdDown.params.initialSha256[19] == (uint8_t)0x00);
283-
REQUIRE(command.otaUpdateCmdDown.params.initialSha256[20] == (uint8_t)0x00);
284-
REQUIRE(command.otaUpdateCmdDown.params.initialSha256[21] == (uint8_t)0x00);
285-
REQUIRE(command.otaUpdateCmdDown.params.initialSha256[22] == (uint8_t)0x00);
286-
REQUIRE(command.otaUpdateCmdDown.params.initialSha256[23] == (uint8_t)0x00);
287-
REQUIRE(command.otaUpdateCmdDown.params.initialSha256[24] == (uint8_t)0x00);
288-
REQUIRE(command.otaUpdateCmdDown.params.initialSha256[25] == (uint8_t)0x00);
289-
REQUIRE(command.otaUpdateCmdDown.params.initialSha256[26] == (uint8_t)0x00);
290-
REQUIRE(command.otaUpdateCmdDown.params.initialSha256[27] == (uint8_t)0x00);
291-
REQUIRE(command.otaUpdateCmdDown.params.initialSha256[28] == (uint8_t)0x00);
292-
REQUIRE(command.otaUpdateCmdDown.params.initialSha256[29] == (uint8_t)0x00);
293-
REQUIRE(command.otaUpdateCmdDown.params.initialSha256[30] == (uint8_t)0x00);
294-
REQUIRE(command.otaUpdateCmdDown.params.initialSha256[31] == (uint8_t)0x00);
263+
REQUIRE(command.otaUpdateCmdDown.initialSha256[0] == (uint8_t)0x00);
264+
REQUIRE(command.otaUpdateCmdDown.initialSha256[1] == (uint8_t)0x00);
265+
REQUIRE(command.otaUpdateCmdDown.initialSha256[2] == (uint8_t)0x00);
266+
REQUIRE(command.otaUpdateCmdDown.initialSha256[3] == (uint8_t)0x00);
267+
REQUIRE(command.otaUpdateCmdDown.initialSha256[4] == (uint8_t)0x00);
268+
REQUIRE(command.otaUpdateCmdDown.initialSha256[5] == (uint8_t)0x00);
269+
REQUIRE(command.otaUpdateCmdDown.initialSha256[6] == (uint8_t)0x00);
270+
REQUIRE(command.otaUpdateCmdDown.initialSha256[7] == (uint8_t)0x00);
271+
REQUIRE(command.otaUpdateCmdDown.initialSha256[8] == (uint8_t)0x00);
272+
REQUIRE(command.otaUpdateCmdDown.initialSha256[9] == (uint8_t)0x00);
273+
REQUIRE(command.otaUpdateCmdDown.initialSha256[10] == (uint8_t)0x00);
274+
REQUIRE(command.otaUpdateCmdDown.initialSha256[11] == (uint8_t)0x00);
275+
REQUIRE(command.otaUpdateCmdDown.initialSha256[12] == (uint8_t)0x00);
276+
REQUIRE(command.otaUpdateCmdDown.initialSha256[13] == (uint8_t)0x00);
277+
REQUIRE(command.otaUpdateCmdDown.initialSha256[14] == (uint8_t)0x00);
278+
REQUIRE(command.otaUpdateCmdDown.initialSha256[15] == (uint8_t)0x00);
279+
REQUIRE(command.otaUpdateCmdDown.initialSha256[16] == (uint8_t)0x00);
280+
REQUIRE(command.otaUpdateCmdDown.initialSha256[17] == (uint8_t)0x00);
281+
REQUIRE(command.otaUpdateCmdDown.initialSha256[18] == (uint8_t)0x00);
282+
REQUIRE(command.otaUpdateCmdDown.initialSha256[19] == (uint8_t)0x00);
283+
REQUIRE(command.otaUpdateCmdDown.initialSha256[20] == (uint8_t)0x00);
284+
REQUIRE(command.otaUpdateCmdDown.initialSha256[21] == (uint8_t)0x00);
285+
REQUIRE(command.otaUpdateCmdDown.initialSha256[22] == (uint8_t)0x00);
286+
REQUIRE(command.otaUpdateCmdDown.initialSha256[23] == (uint8_t)0x00);
287+
REQUIRE(command.otaUpdateCmdDown.initialSha256[24] == (uint8_t)0x00);
288+
REQUIRE(command.otaUpdateCmdDown.initialSha256[25] == (uint8_t)0x00);
289+
REQUIRE(command.otaUpdateCmdDown.initialSha256[26] == (uint8_t)0x00);
290+
REQUIRE(command.otaUpdateCmdDown.initialSha256[27] == (uint8_t)0x00);
291+
REQUIRE(command.otaUpdateCmdDown.initialSha256[28] == (uint8_t)0x00);
292+
REQUIRE(command.otaUpdateCmdDown.initialSha256[29] == (uint8_t)0x00);
293+
REQUIRE(command.otaUpdateCmdDown.initialSha256[30] == (uint8_t)0x00);
294+
REQUIRE(command.otaUpdateCmdDown.initialSha256[31] == (uint8_t)0x00);
295295

296296
// Final SHA256 check
297-
REQUIRE(command.otaUpdateCmdDown.params.finalSha256[0] == (uint8_t)0xdf);
298-
REQUIRE(command.otaUpdateCmdDown.params.finalSha256[1] == (uint8_t)0x1e);
299-
REQUIRE(command.otaUpdateCmdDown.params.finalSha256[2] == (uint8_t)0xac);
300-
REQUIRE(command.otaUpdateCmdDown.params.finalSha256[3] == (uint8_t)0x9c);
301-
REQUIRE(command.otaUpdateCmdDown.params.finalSha256[4] == (uint8_t)0x7b);
302-
REQUIRE(command.otaUpdateCmdDown.params.finalSha256[5] == (uint8_t)0xd6);
303-
REQUIRE(command.otaUpdateCmdDown.params.finalSha256[6] == (uint8_t)0x34);
304-
REQUIRE(command.otaUpdateCmdDown.params.finalSha256[7] == (uint8_t)0x73);
305-
REQUIRE(command.otaUpdateCmdDown.params.finalSha256[8] == (uint8_t)0xff);
306-
REQUIRE(command.otaUpdateCmdDown.params.finalSha256[9] == (uint8_t)0xfb);
307-
REQUIRE(command.otaUpdateCmdDown.params.finalSha256[10] == (uint8_t)0x11);
308-
REQUIRE(command.otaUpdateCmdDown.params.finalSha256[11] == (uint8_t)0x7f);
309-
REQUIRE(command.otaUpdateCmdDown.params.finalSha256[12] == (uint8_t)0x98);
310-
REQUIRE(command.otaUpdateCmdDown.params.finalSha256[13] == (uint8_t)0x73);
311-
REQUIRE(command.otaUpdateCmdDown.params.finalSha256[14] == (uint8_t)0x70);
312-
REQUIRE(command.otaUpdateCmdDown.params.finalSha256[15] == (uint8_t)0x3e);
313-
REQUIRE(command.otaUpdateCmdDown.params.finalSha256[16] == (uint8_t)0x4e);
314-
REQUIRE(command.otaUpdateCmdDown.params.finalSha256[17] == (uint8_t)0xc9);
315-
REQUIRE(command.otaUpdateCmdDown.params.finalSha256[18] == (uint8_t)0x55);
316-
REQUIRE(command.otaUpdateCmdDown.params.finalSha256[19] == (uint8_t)0x93);
317-
REQUIRE(command.otaUpdateCmdDown.params.finalSha256[20] == (uint8_t)0x1e);
318-
REQUIRE(command.otaUpdateCmdDown.params.finalSha256[21] == (uint8_t)0x26);
319-
REQUIRE(command.otaUpdateCmdDown.params.finalSha256[22] == (uint8_t)0x7f);
320-
REQUIRE(command.otaUpdateCmdDown.params.finalSha256[23] == (uint8_t)0x26);
321-
REQUIRE(command.otaUpdateCmdDown.params.finalSha256[24] == (uint8_t)0x26);
322-
REQUIRE(command.otaUpdateCmdDown.params.finalSha256[25] == (uint8_t)0x2b);
323-
REQUIRE(command.otaUpdateCmdDown.params.finalSha256[26] == (uint8_t)0x09);
324-
REQUIRE(command.otaUpdateCmdDown.params.finalSha256[27] == (uint8_t)0x49);
325-
REQUIRE(command.otaUpdateCmdDown.params.finalSha256[28] == (uint8_t)0xbc);
326-
REQUIRE(command.otaUpdateCmdDown.params.finalSha256[29] == (uint8_t)0x16);
327-
REQUIRE(command.otaUpdateCmdDown.params.finalSha256[30] == (uint8_t)0xdc);
328-
REQUIRE(command.otaUpdateCmdDown.params.finalSha256[31] == (uint8_t)0x49);
297+
REQUIRE(command.otaUpdateCmdDown.finalSha256[0] == (uint8_t)0xdf);
298+
REQUIRE(command.otaUpdateCmdDown.finalSha256[1] == (uint8_t)0x1e);
299+
REQUIRE(command.otaUpdateCmdDown.finalSha256[2] == (uint8_t)0xac);
300+
REQUIRE(command.otaUpdateCmdDown.finalSha256[3] == (uint8_t)0x9c);
301+
REQUIRE(command.otaUpdateCmdDown.finalSha256[4] == (uint8_t)0x7b);
302+
REQUIRE(command.otaUpdateCmdDown.finalSha256[5] == (uint8_t)0xd6);
303+
REQUIRE(command.otaUpdateCmdDown.finalSha256[6] == (uint8_t)0x34);
304+
REQUIRE(command.otaUpdateCmdDown.finalSha256[7] == (uint8_t)0x73);
305+
REQUIRE(command.otaUpdateCmdDown.finalSha256[8] == (uint8_t)0xff);
306+
REQUIRE(command.otaUpdateCmdDown.finalSha256[9] == (uint8_t)0xfb);
307+
REQUIRE(command.otaUpdateCmdDown.finalSha256[10] == (uint8_t)0x11);
308+
REQUIRE(command.otaUpdateCmdDown.finalSha256[11] == (uint8_t)0x7f);
309+
REQUIRE(command.otaUpdateCmdDown.finalSha256[12] == (uint8_t)0x98);
310+
REQUIRE(command.otaUpdateCmdDown.finalSha256[13] == (uint8_t)0x73);
311+
REQUIRE(command.otaUpdateCmdDown.finalSha256[14] == (uint8_t)0x70);
312+
REQUIRE(command.otaUpdateCmdDown.finalSha256[15] == (uint8_t)0x3e);
313+
REQUIRE(command.otaUpdateCmdDown.finalSha256[16] == (uint8_t)0x4e);
314+
REQUIRE(command.otaUpdateCmdDown.finalSha256[17] == (uint8_t)0xc9);
315+
REQUIRE(command.otaUpdateCmdDown.finalSha256[18] == (uint8_t)0x55);
316+
REQUIRE(command.otaUpdateCmdDown.finalSha256[19] == (uint8_t)0x93);
317+
REQUIRE(command.otaUpdateCmdDown.finalSha256[20] == (uint8_t)0x1e);
318+
REQUIRE(command.otaUpdateCmdDown.finalSha256[21] == (uint8_t)0x26);
319+
REQUIRE(command.otaUpdateCmdDown.finalSha256[22] == (uint8_t)0x7f);
320+
REQUIRE(command.otaUpdateCmdDown.finalSha256[23] == (uint8_t)0x26);
321+
REQUIRE(command.otaUpdateCmdDown.finalSha256[24] == (uint8_t)0x26);
322+
REQUIRE(command.otaUpdateCmdDown.finalSha256[25] == (uint8_t)0x2b);
323+
REQUIRE(command.otaUpdateCmdDown.finalSha256[26] == (uint8_t)0x09);
324+
REQUIRE(command.otaUpdateCmdDown.finalSha256[27] == (uint8_t)0x49);
325+
REQUIRE(command.otaUpdateCmdDown.finalSha256[28] == (uint8_t)0xbc);
326+
REQUIRE(command.otaUpdateCmdDown.finalSha256[29] == (uint8_t)0x16);
327+
REQUIRE(command.otaUpdateCmdDown.finalSha256[30] == (uint8_t)0xdc);
328+
REQUIRE(command.otaUpdateCmdDown.finalSha256[31] == (uint8_t)0x49);
329329

330330
REQUIRE(command.c.id == OtaUpdateCmdDownId);
331331
}

extras/test/src/test_command_encode.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ SCENARIO("Test the encoding of command messages") {
2424
{
2525
OtaBeginUp command;
2626
uint8_t sha[SHA256_SIZE] = {0x01, 0x02, 0x03, 0x04};
27-
memcpy(command.params.sha, sha, SHA256_SIZE);
27+
memcpy(command.sha, sha, SHA256_SIZE);
2828

2929
command.c.id = CommandId::OtaBeginUpId;
3030

@@ -61,7 +61,7 @@ SCENARIO("Test the encoding of command messages") {
6161
{
6262
ThingBeginCmd command;
6363
String thing_id = "thing_id";
64-
strcpy(command.params.thing_id, thing_id.c_str());
64+
strcpy(command.thing_id, thing_id.c_str());
6565

6666
command.c.id = CommandId::ThingBeginCmdId;
6767

@@ -122,7 +122,7 @@ SCENARIO("Test the encoding of command messages") {
122122
{
123123
DeviceBeginCmd command;
124124
String lib_version = "2.0.0";
125-
strcpy(command.params.lib_version, lib_version.c_str());
125+
strcpy(command.lib_version, lib_version.c_str());
126126

127127
command.c.id = CommandId::DeviceBeginCmdId;
128128

@@ -154,13 +154,13 @@ SCENARIO("Test the encoding of command messages") {
154154
WHEN("Encode the OtaProgressCmdUp message")
155155
{
156156
OtaProgressCmdUp command;
157-
command.params.time = 2;
157+
command.time = 2;
158158

159159
uint8_t id[ID_SIZE] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf};
160-
memcpy(command.params.id, id, ID_SIZE);
161-
command.params.state = 1;
162-
command.params.state_data = -1;
163-
command.params.time = 100;
160+
memcpy(command.id, id, ID_SIZE);
161+
command.state = 1;
162+
command.state_data = -1;
163+
command.time = 100;
164164

165165
command.c.id = CommandId::OtaProgressCmdUpId;
166166

@@ -227,7 +227,7 @@ SCENARIO("Test the encoding of command messages") {
227227
command.c.id = CommandId::ThingUpdateCmdId;
228228

229229
String thing_id = "e4494d55-872a-4fd2-9646-92f87949394c";
230-
strcpy(command.params.thing_id, thing_id.c_str());
230+
strcpy(command.thing_id, thing_id.c_str());
231231

232232
uint8_t buffer[512];
233233
size_t bytes_encoded = sizeof(buffer);
@@ -247,8 +247,8 @@ SCENARIO("Test the encoding of command messages") {
247247
TimezoneCommandDown command;
248248
command.c.id = CommandId::TimezoneCommandDownId;
249249

250-
command.params.offset = 1708963873;
251-
command.params.until = 2024579473;
250+
command.offset = 1708963873;
251+
command.until = 2024579473;
252252

253253
uint8_t buffer[512];
254254
size_t bytes_encoded = sizeof(buffer);
@@ -268,10 +268,10 @@ SCENARIO("Test the encoding of command messages") {
268268
LastValuesUpdateCmd command;
269269
command.c.id = CommandId::LastValuesUpdateCmdId;
270270

271-
command.params.length = 13;
271+
command.length = 13;
272272
uint8_t last_values[13] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
273273
0x08, 0x09, 0x10, 0x11, 0x12};
274-
command.params.last_values = last_values;
274+
command.last_values = last_values;
275275

276276
uint8_t buffer[512];
277277
size_t bytes_encoded = sizeof(buffer);

0 commit comments

Comments
 (0)