|
7 | 7 | ******************************************************************************/
|
8 | 8 |
|
9 | 9 | #include <catch2/catch_test_macros.hpp>
|
| 10 | +#include <catch2/matchers/catch_matchers_vector.hpp> |
| 11 | + |
10 | 12 | #include <string.h>
|
11 | 13 |
|
12 | 14 | #include <memory>
|
@@ -260,73 +262,24 @@ SCENARIO("Test the decoding of command messages") {
|
260 | 262 | REQUIRE(err == MessageDecoder::Status::Complete);
|
261 | 263 | REQUIRE(memcmp(command.otaUpdateCmdDown.params.id, otaIdToMatch, ID_SIZE) == 0);
|
262 | 264 | REQUIRE(strcmp(command.otaUpdateCmdDown.params.url, urlToMatch) == 0);
|
263 |
| - // Initial SHA256 check |
264 |
| - REQUIRE(command.otaUpdateCmdDown.params.initialSha256[0] == (uint8_t)0x00); |
265 |
| - REQUIRE(command.otaUpdateCmdDown.params.initialSha256[1] == (uint8_t)0x00); |
266 |
| - REQUIRE(command.otaUpdateCmdDown.params.initialSha256[2] == (uint8_t)0x00); |
267 |
| - REQUIRE(command.otaUpdateCmdDown.params.initialSha256[3] == (uint8_t)0x00); |
268 |
| - REQUIRE(command.otaUpdateCmdDown.params.initialSha256[4] == (uint8_t)0x00); |
269 |
| - REQUIRE(command.otaUpdateCmdDown.params.initialSha256[5] == (uint8_t)0x00); |
270 |
| - REQUIRE(command.otaUpdateCmdDown.params.initialSha256[6] == (uint8_t)0x00); |
271 |
| - REQUIRE(command.otaUpdateCmdDown.params.initialSha256[7] == (uint8_t)0x00); |
272 |
| - REQUIRE(command.otaUpdateCmdDown.params.initialSha256[8] == (uint8_t)0x00); |
273 |
| - REQUIRE(command.otaUpdateCmdDown.params.initialSha256[9] == (uint8_t)0x00); |
274 |
| - REQUIRE(command.otaUpdateCmdDown.params.initialSha256[10] == (uint8_t)0x00); |
275 |
| - REQUIRE(command.otaUpdateCmdDown.params.initialSha256[11] == (uint8_t)0x00); |
276 |
| - REQUIRE(command.otaUpdateCmdDown.params.initialSha256[12] == (uint8_t)0x00); |
277 |
| - REQUIRE(command.otaUpdateCmdDown.params.initialSha256[13] == (uint8_t)0x00); |
278 |
| - REQUIRE(command.otaUpdateCmdDown.params.initialSha256[14] == (uint8_t)0x00); |
279 |
| - REQUIRE(command.otaUpdateCmdDown.params.initialSha256[15] == (uint8_t)0x00); |
280 |
| - REQUIRE(command.otaUpdateCmdDown.params.initialSha256[16] == (uint8_t)0x00); |
281 |
| - REQUIRE(command.otaUpdateCmdDown.params.initialSha256[17] == (uint8_t)0x00); |
282 |
| - REQUIRE(command.otaUpdateCmdDown.params.initialSha256[18] == (uint8_t)0x00); |
283 |
| - REQUIRE(command.otaUpdateCmdDown.params.initialSha256[19] == (uint8_t)0x00); |
284 |
| - REQUIRE(command.otaUpdateCmdDown.params.initialSha256[20] == (uint8_t)0x00); |
285 |
| - REQUIRE(command.otaUpdateCmdDown.params.initialSha256[21] == (uint8_t)0x00); |
286 |
| - REQUIRE(command.otaUpdateCmdDown.params.initialSha256[22] == (uint8_t)0x00); |
287 |
| - REQUIRE(command.otaUpdateCmdDown.params.initialSha256[23] == (uint8_t)0x00); |
288 |
| - REQUIRE(command.otaUpdateCmdDown.params.initialSha256[24] == (uint8_t)0x00); |
289 |
| - REQUIRE(command.otaUpdateCmdDown.params.initialSha256[25] == (uint8_t)0x00); |
290 |
| - REQUIRE(command.otaUpdateCmdDown.params.initialSha256[26] == (uint8_t)0x00); |
291 |
| - REQUIRE(command.otaUpdateCmdDown.params.initialSha256[27] == (uint8_t)0x00); |
292 |
| - REQUIRE(command.otaUpdateCmdDown.params.initialSha256[28] == (uint8_t)0x00); |
293 |
| - REQUIRE(command.otaUpdateCmdDown.params.initialSha256[29] == (uint8_t)0x00); |
294 |
| - REQUIRE(command.otaUpdateCmdDown.params.initialSha256[30] == (uint8_t)0x00); |
295 |
| - REQUIRE(command.otaUpdateCmdDown.params.initialSha256[31] == (uint8_t)0x00); |
296 |
| - |
297 |
| - // Final SHA256 check |
298 |
| - REQUIRE(command.otaUpdateCmdDown.params.finalSha256[0] == (uint8_t)0xdf); |
299 |
| - REQUIRE(command.otaUpdateCmdDown.params.finalSha256[1] == (uint8_t)0x1e); |
300 |
| - REQUIRE(command.otaUpdateCmdDown.params.finalSha256[2] == (uint8_t)0xac); |
301 |
| - REQUIRE(command.otaUpdateCmdDown.params.finalSha256[3] == (uint8_t)0x9c); |
302 |
| - REQUIRE(command.otaUpdateCmdDown.params.finalSha256[4] == (uint8_t)0x7b); |
303 |
| - REQUIRE(command.otaUpdateCmdDown.params.finalSha256[5] == (uint8_t)0xd6); |
304 |
| - REQUIRE(command.otaUpdateCmdDown.params.finalSha256[6] == (uint8_t)0x34); |
305 |
| - REQUIRE(command.otaUpdateCmdDown.params.finalSha256[7] == (uint8_t)0x73); |
306 |
| - REQUIRE(command.otaUpdateCmdDown.params.finalSha256[8] == (uint8_t)0xff); |
307 |
| - REQUIRE(command.otaUpdateCmdDown.params.finalSha256[9] == (uint8_t)0xfb); |
308 |
| - REQUIRE(command.otaUpdateCmdDown.params.finalSha256[10] == (uint8_t)0x11); |
309 |
| - REQUIRE(command.otaUpdateCmdDown.params.finalSha256[11] == (uint8_t)0x7f); |
310 |
| - REQUIRE(command.otaUpdateCmdDown.params.finalSha256[12] == (uint8_t)0x98); |
311 |
| - REQUIRE(command.otaUpdateCmdDown.params.finalSha256[13] == (uint8_t)0x73); |
312 |
| - REQUIRE(command.otaUpdateCmdDown.params.finalSha256[14] == (uint8_t)0x70); |
313 |
| - REQUIRE(command.otaUpdateCmdDown.params.finalSha256[15] == (uint8_t)0x3e); |
314 |
| - REQUIRE(command.otaUpdateCmdDown.params.finalSha256[16] == (uint8_t)0x4e); |
315 |
| - REQUIRE(command.otaUpdateCmdDown.params.finalSha256[17] == (uint8_t)0xc9); |
316 |
| - REQUIRE(command.otaUpdateCmdDown.params.finalSha256[18] == (uint8_t)0x55); |
317 |
| - REQUIRE(command.otaUpdateCmdDown.params.finalSha256[19] == (uint8_t)0x93); |
318 |
| - REQUIRE(command.otaUpdateCmdDown.params.finalSha256[20] == (uint8_t)0x1e); |
319 |
| - REQUIRE(command.otaUpdateCmdDown.params.finalSha256[21] == (uint8_t)0x26); |
320 |
| - REQUIRE(command.otaUpdateCmdDown.params.finalSha256[22] == (uint8_t)0x7f); |
321 |
| - REQUIRE(command.otaUpdateCmdDown.params.finalSha256[23] == (uint8_t)0x26); |
322 |
| - REQUIRE(command.otaUpdateCmdDown.params.finalSha256[24] == (uint8_t)0x26); |
323 |
| - REQUIRE(command.otaUpdateCmdDown.params.finalSha256[25] == (uint8_t)0x2b); |
324 |
| - REQUIRE(command.otaUpdateCmdDown.params.finalSha256[26] == (uint8_t)0x09); |
325 |
| - REQUIRE(command.otaUpdateCmdDown.params.finalSha256[27] == (uint8_t)0x49); |
326 |
| - REQUIRE(command.otaUpdateCmdDown.params.finalSha256[28] == (uint8_t)0xbc); |
327 |
| - REQUIRE(command.otaUpdateCmdDown.params.finalSha256[29] == (uint8_t)0x16); |
328 |
| - REQUIRE(command.otaUpdateCmdDown.params.finalSha256[30] == (uint8_t)0xdc); |
329 |
| - REQUIRE(command.otaUpdateCmdDown.params.finalSha256[31] == (uint8_t)0x49); |
| 265 | + |
| 266 | + std::vector<int> initialSha256(command.otaUpdateCmdDown.params.initialSha256, |
| 267 | + command.otaUpdateCmdDown.params.initialSha256+32); |
| 268 | + |
| 269 | + REQUIRE_THAT(initialSha256, |
| 270 | + Catch::Matchers::Equals(std::vector<int>{ |
| 271 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 272 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 |
| 273 | + })); |
| 274 | + |
| 275 | + std::vector<int> finalSha256(command.otaUpdateCmdDown.params.finalSha256, |
| 276 | + command.otaUpdateCmdDown.params.finalSha256+32); |
| 277 | + |
| 278 | + REQUIRE_THAT(finalSha256, |
| 279 | + Catch::Matchers::Equals(std::vector<int>{ |
| 280 | + 0xdf, 0x1e, 0xac, 0x9c, 0x7b, 0xd6, 0x34, 0x73, 0xff, 0xfb, 0x11, 0x7f, 0x98, 0x73, 0x70, 0x3e, |
| 281 | + 0x4e, 0xc9, 0x55, 0x93, 0x1e, 0x26, 0x7f, 0x26, 0x26, 0x2b, 0x09, 0x49, 0xbc, 0x16, 0xdc, 0x49 |
| 282 | + })); |
330 | 283 |
|
331 | 284 | REQUIRE(command.c.id == OtaUpdateCmdDownId);
|
332 | 285 | }
|
|
0 commit comments