1212#include < memory>
1313
1414#include < util/CBORTestUtil.h>
15+ #include < IoTCloudMessageEncoder.h>
1516#include < MessageDecoder.h>
1617
1718/* *****************************************************************************
@@ -39,11 +40,11 @@ SCENARIO("Test the decoding of command messages") {
3940
4041 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
4142 CBORMessageDecoder decoder;
42- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
43+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
4344 const char *thingIdToMatch = " e4494d55-872a-4fd2-9646-92f87949394c" ;
4445
4546 THEN (" The decode is successful" ) {
46- REQUIRE (err == Decoder ::Status::Complete);
47+ REQUIRE (err == MessageDecoder ::Status::Complete);
4748 REQUIRE (strcmp (command.thingUpdateCmd .params .thing_id , thingIdToMatch) == 0 );
4849 REQUIRE (command.c .id == ThingUpdateCmdId);
4950 }
@@ -68,11 +69,11 @@ SCENARIO("Test the decoding of command messages") {
6869
6970 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
7071 CBORMessageDecoder decoder;
71- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
72+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
7273 const char *thingIdToMatch = " e4494d55-872a-4fd2-9646-92f87949394c" ;
7374
7475 THEN (" The decode is successful" ) {
75- REQUIRE (err == Decoder ::Status::Complete);
76+ REQUIRE (err == MessageDecoder ::Status::Complete);
7677 REQUIRE (strcmp (command.thingDetachCmd .params .thing_id , thingIdToMatch) == 0 );
7778 REQUIRE (command.c .id == ThingDetachCmdId);
7879 }
@@ -93,10 +94,10 @@ SCENARIO("Test the decoding of command messages") {
9394
9495 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
9596 CBORMessageDecoder decoder;
96- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
97+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
9798
9899 THEN (" The decode is unsuccessful" ) {
99- REQUIRE (err == Decoder ::Status::Error);
100+ REQUIRE (err == MessageDecoder ::Status::Error);
100101 }
101102 }
102103
@@ -114,10 +115,10 @@ SCENARIO("Test the decoding of command messages") {
114115
115116 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
116117 CBORMessageDecoder decoder;
117- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
118+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
118119
119120 THEN (" The decode is successful" ) {
120- REQUIRE (err == Decoder ::Status::Error);
121+ REQUIRE (err == MessageDecoder ::Status::Error);
121122 }
122123 }
123124
@@ -139,10 +140,10 @@ SCENARIO("Test the decoding of command messages") {
139140
140141 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
141142 CBORMessageDecoder decoder;
142- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
143+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
143144
144145 THEN (" The decode is successful" ) {
145- REQUIRE (err == Decoder ::Status::Complete);
146+ REQUIRE (err == MessageDecoder ::Status::Complete);
146147 REQUIRE (command.timezoneCommandDown .params .offset == (uint32_t )1708963873 );
147148 REQUIRE (command.timezoneCommandDown .params .until == (uint32_t )2024579473 );
148149 REQUIRE (command.c .id == TimezoneCommandDownId);
@@ -169,10 +170,10 @@ SCENARIO("Test the decoding of command messages") {
169170
170171 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
171172 CBORMessageDecoder decoder;
172- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
173+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
173174
174175 THEN (" The decode is successful" ) {
175- REQUIRE (err == Decoder ::Status::Complete);
176+ REQUIRE (err == MessageDecoder ::Status::Complete);
176177 REQUIRE (command.lastValuesUpdateCmd .params .length == 13 );
177178 REQUIRE (command.lastValuesUpdateCmd .params .last_values [0 ] == (uint8_t )0x00 );
178179 REQUIRE (command.lastValuesUpdateCmd .params .last_values [1 ] == (uint8_t )0x01 );
@@ -249,14 +250,14 @@ SCENARIO("Test the decoding of command messages") {
249250
250251 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
251252 CBORMessageDecoder decoder;
252- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
253+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
253254
254255 uint8_t otaIdToMatch[ID_SIZE] = { 0xC7 , 0x3C , 0xB0 , 0x45 , 0xF9 , 0xC2 , 0x43 , 0x45 ,
255256 0x85 , 0xAF , 0xFA , 0x36 , 0xA3 , 0x07 , 0xBF , 0xE7 };
256257 const char *urlToMatch = " https://boards-int.oniudra.cc/storage/firmware/v1/df1eac9c7bd63473fffb117f9873703e4ec955931e267f26262b0949bc16dc49" ;
257258
258259 THEN (" The decode is successful" ) {
259- REQUIRE (err == Decoder ::Status::Complete);
260+ REQUIRE (err == MessageDecoder ::Status::Complete);
260261 REQUIRE (memcmp (command.otaUpdateCmdDown .params .id , otaIdToMatch, ID_SIZE) == 0 );
261262 REQUIRE (strcmp (command.otaUpdateCmdDown .params .url , urlToMatch) == 0 );
262263 // Initial SHA256 check
@@ -388,10 +389,10 @@ SCENARIO("Test the decoding of command messages") {
388389
389390 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
390391 CBORMessageDecoder decoder;
391- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
392+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
392393
393394 THEN (" The decode is successful" ) {
394- REQUIRE (err == Decoder ::Status::Error);
395+ REQUIRE (err == MessageDecoder ::Status::Error);
395396 }
396397 }
397398
@@ -452,10 +453,10 @@ SCENARIO("Test the decoding of command messages") {
452453
453454 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
454455 CBORMessageDecoder decoder;
455- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
456+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
456457
457458 THEN (" The decode is successful" ) {
458- REQUIRE (err == Decoder ::Status::Error);
459+ REQUIRE (err == MessageDecoder ::Status::Error);
459460 }
460461 }
461462
@@ -511,10 +512,10 @@ SCENARIO("Test the decoding of command messages") {
511512
512513 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
513514 CBORMessageDecoder decoder;
514- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
515+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
515516
516517 THEN (" The decode is successful" ) {
517- REQUIRE (err == Decoder ::Status::Error);
518+ REQUIRE (err == MessageDecoder ::Status::Error);
518519 }
519520 }
520521
@@ -570,10 +571,10 @@ SCENARIO("Test the decoding of command messages") {
570571
571572 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
572573 CBORMessageDecoder decoder;
573- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
574+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
574575
575576 THEN (" The decode is successful" ) {
576- REQUIRE (err == Decoder ::Status::Error);
577+ REQUIRE (err == MessageDecoder ::Status::Error);
577578 }
578579 }
579580
@@ -596,10 +597,10 @@ SCENARIO("Test the decoding of command messages") {
596597
597598 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
598599 CBORMessageDecoder decoder;
599- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
600+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
600601
601602 THEN (" The decode is unsuccessful - OtaBeginUp is not supported" ) {
602- REQUIRE (err == Decoder ::Status::Error);
603+ REQUIRE (err == MessageDecoder ::Status::Error);
603604 }
604605 }
605606
@@ -619,10 +620,10 @@ SCENARIO("Test the decoding of command messages") {
619620
620621 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
621622 CBORMessageDecoder decoder;
622- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
623+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
623624
624625 THEN (" The decode is unsuccessful - ThingBeginCmd is not supported" ) {
625- REQUIRE (err == Decoder ::Status::Error);
626+ REQUIRE (err == MessageDecoder ::Status::Error);
626627 }
627628 }
628629
@@ -639,10 +640,10 @@ SCENARIO("Test the decoding of command messages") {
639640
640641 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
641642 CBORMessageDecoder decoder;
642- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
643+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
643644
644645 THEN (" The decode is unsuccessful - LastValuesBeginCmd is not supported" ) {
645- REQUIRE (err == Decoder ::Status::Error);
646+ REQUIRE (err == MessageDecoder ::Status::Error);
646647 }
647648 }
648649
@@ -662,10 +663,10 @@ SCENARIO("Test the decoding of command messages") {
662663
663664 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
664665 CBORMessageDecoder decoder;
665- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
666+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
666667
667668 THEN (" The decode is unsuccessful - DeviceBeginCmd is not supported" ) {
668- REQUIRE (err == Decoder ::Status::Error);
669+ REQUIRE (err == MessageDecoder ::Status::Error);
669670 }
670671 }
671672
@@ -690,10 +691,10 @@ SCENARIO("Test the decoding of command messages") {
690691
691692 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
692693 CBORMessageDecoder decoder;
693- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
694+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
694695
695696 THEN (" The decode is unsuccessful - OtaProgressCmdUp is not supported" ) {
696- REQUIRE (err == Decoder ::Status::Error);
697+ REQUIRE (err == MessageDecoder ::Status::Error);
697698 }
698699 }
699700
@@ -710,10 +711,10 @@ SCENARIO("Test the decoding of command messages") {
710711
711712 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
712713 CBORMessageDecoder decoder;
713- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
714+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
714715
715716 THEN (" The decode is unsuccessful - TimezoneCommandUp is not supported" ) {
716- REQUIRE (err == Decoder ::Status::Error);
717+ REQUIRE (err == MessageDecoder ::Status::Error);
717718 }
718719 }
719720
@@ -735,10 +736,10 @@ SCENARIO("Test the decoding of command messages") {
735736
736737 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
737738 CBORMessageDecoder decoder;
738- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
739+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
739740
740741 THEN (" The decode is unsuccessful" ) {
741- REQUIRE (err == Decoder ::Status::Error);
742+ REQUIRE (err == MessageDecoder ::Status::Error);
742743 }
743744 }
744745
@@ -759,10 +760,10 @@ SCENARIO("Test the decoding of command messages") {
759760
760761 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
761762 CBORMessageDecoder decoder;
762- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
763+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
763764
764765 THEN (" The decode is unsuccessful" ) {
765- REQUIRE (err == Decoder ::Status::Error);
766+ REQUIRE (err == MessageDecoder ::Status::Error);
766767 }
767768 }
768769
@@ -776,10 +777,10 @@ SCENARIO("Test the decoding of command messages") {
776777
777778 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
778779 CBORMessageDecoder decoder;
779- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
780+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
780781
781782 THEN (" The decode is unsuccessful" ) {
782- REQUIRE (err == Decoder ::Status::Error);
783+ REQUIRE (err == MessageDecoder ::Status::Error);
783784 }
784785 }
785786
0 commit comments