1212#include < memory>
1313
1414#include < util/CBORTestUtil.h>
15- #include < CborDecoder .h>
15+ #include < IoTCloudMessageEncoder .h>
1616#include < MessageDecoder.h>
1717
1818/* *****************************************************************************
@@ -40,11 +40,11 @@ SCENARIO("Test the decoding of command messages") {
4040
4141 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
4242 CBORMessageDecoder decoder;
43- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
43+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
4444 const char *thingIdToMatch = " e4494d55-872a-4fd2-9646-92f87949394c" ;
4545
4646 THEN (" The decode is successful" ) {
47- REQUIRE (err == Decoder ::Status::Complete);
47+ REQUIRE (err == MessageDecoder ::Status::Complete);
4848 REQUIRE (strcmp (command.thingUpdateCmd .params .thing_id , thingIdToMatch) == 0 );
4949 REQUIRE (command.c .id == ThingUpdateCmdId);
5050 }
@@ -69,11 +69,11 @@ SCENARIO("Test the decoding of command messages") {
6969
7070 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
7171 CBORMessageDecoder decoder;
72- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
72+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
7373 const char *thingIdToMatch = " e4494d55-872a-4fd2-9646-92f87949394c" ;
7474
7575 THEN (" The decode is successful" ) {
76- REQUIRE (err == Decoder ::Status::Complete);
76+ REQUIRE (err == MessageDecoder ::Status::Complete);
7777 REQUIRE (strcmp (command.thingDetachCmd .params .thing_id , thingIdToMatch) == 0 );
7878 REQUIRE (command.c .id == ThingDetachCmdId);
7979 }
@@ -94,10 +94,10 @@ SCENARIO("Test the decoding of command messages") {
9494
9595 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
9696 CBORMessageDecoder decoder;
97- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
97+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
9898
9999 THEN (" The decode is unsuccessful" ) {
100- REQUIRE (err == Decoder ::Status::Error);
100+ REQUIRE (err == MessageDecoder ::Status::Error);
101101 }
102102 }
103103
@@ -115,10 +115,10 @@ SCENARIO("Test the decoding of command messages") {
115115
116116 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
117117 CBORMessageDecoder decoder;
118- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
118+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
119119
120120 THEN (" The decode is successful" ) {
121- REQUIRE (err == Decoder ::Status::Error);
121+ REQUIRE (err == MessageDecoder ::Status::Error);
122122 }
123123 }
124124
@@ -140,10 +140,10 @@ SCENARIO("Test the decoding of command messages") {
140140
141141 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
142142 CBORMessageDecoder decoder;
143- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
143+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
144144
145145 THEN (" The decode is successful" ) {
146- REQUIRE (err == Decoder ::Status::Complete);
146+ REQUIRE (err == MessageDecoder ::Status::Complete);
147147 REQUIRE (command.timezoneCommandDown .params .offset == (uint32_t )1708963873 );
148148 REQUIRE (command.timezoneCommandDown .params .until == (uint32_t )2024579473 );
149149 REQUIRE (command.c .id == TimezoneCommandDownId);
@@ -170,10 +170,10 @@ SCENARIO("Test the decoding of command messages") {
170170
171171 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
172172 CBORMessageDecoder decoder;
173- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
173+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
174174
175175 THEN (" The decode is successful" ) {
176- REQUIRE (err == Decoder ::Status::Complete);
176+ REQUIRE (err == MessageDecoder ::Status::Complete);
177177 REQUIRE (command.lastValuesUpdateCmd .params .length == 13 );
178178 REQUIRE (command.lastValuesUpdateCmd .params .last_values [0 ] == (uint8_t )0x00 );
179179 REQUIRE (command.lastValuesUpdateCmd .params .last_values [1 ] == (uint8_t )0x01 );
@@ -250,14 +250,14 @@ SCENARIO("Test the decoding of command messages") {
250250
251251 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
252252 CBORMessageDecoder decoder;
253- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
253+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
254254
255255 uint8_t otaIdToMatch[ID_SIZE] = { 0xC7 , 0x3C , 0xB0 , 0x45 , 0xF9 , 0xC2 , 0x43 , 0x45 ,
256256 0x85 , 0xAF , 0xFA , 0x36 , 0xA3 , 0x07 , 0xBF , 0xE7 };
257257 const char *urlToMatch = " https://boards-int.oniudra.cc/storage/firmware/v1/df1eac9c7bd63473fffb117f9873703e4ec955931e267f26262b0949bc16dc49" ;
258258
259259 THEN (" The decode is successful" ) {
260- REQUIRE (err == Decoder ::Status::Complete);
260+ REQUIRE (err == MessageDecoder ::Status::Complete);
261261 REQUIRE (memcmp (command.otaUpdateCmdDown .params .id , otaIdToMatch, ID_SIZE) == 0 );
262262 REQUIRE (strcmp (command.otaUpdateCmdDown .params .url , urlToMatch) == 0 );
263263 // Initial SHA256 check
@@ -389,10 +389,10 @@ SCENARIO("Test the decoding of command messages") {
389389
390390 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
391391 CBORMessageDecoder decoder;
392- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
392+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
393393
394394 THEN (" The decode is successful" ) {
395- REQUIRE (err == Decoder ::Status::Error);
395+ REQUIRE (err == MessageDecoder ::Status::Error);
396396 }
397397 }
398398
@@ -453,10 +453,10 @@ SCENARIO("Test the decoding of command messages") {
453453
454454 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
455455 CBORMessageDecoder decoder;
456- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
456+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
457457
458458 THEN (" The decode is successful" ) {
459- REQUIRE (err == Decoder ::Status::Error);
459+ REQUIRE (err == MessageDecoder ::Status::Error);
460460 }
461461 }
462462
@@ -512,10 +512,10 @@ SCENARIO("Test the decoding of command messages") {
512512
513513 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
514514 CBORMessageDecoder decoder;
515- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
515+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
516516
517517 THEN (" The decode is successful" ) {
518- REQUIRE (err == Decoder ::Status::Error);
518+ REQUIRE (err == MessageDecoder ::Status::Error);
519519 }
520520 }
521521
@@ -571,10 +571,10 @@ SCENARIO("Test the decoding of command messages") {
571571
572572 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
573573 CBORMessageDecoder decoder;
574- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
574+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
575575
576576 THEN (" The decode is successful" ) {
577- REQUIRE (err == Decoder ::Status::Error);
577+ REQUIRE (err == MessageDecoder ::Status::Error);
578578 }
579579 }
580580
@@ -597,10 +597,10 @@ SCENARIO("Test the decoding of command messages") {
597597
598598 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
599599 CBORMessageDecoder decoder;
600- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
600+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
601601
602602 THEN (" The decode is unsuccessful - OtaBeginUp is not supported" ) {
603- REQUIRE (err == Decoder ::Status::Error);
603+ REQUIRE (err == MessageDecoder ::Status::Error);
604604 }
605605 }
606606
@@ -620,10 +620,10 @@ SCENARIO("Test the decoding of command messages") {
620620
621621 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
622622 CBORMessageDecoder decoder;
623- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
623+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
624624
625625 THEN (" The decode is unsuccessful - ThingBeginCmd is not supported" ) {
626- REQUIRE (err == Decoder ::Status::Error);
626+ REQUIRE (err == MessageDecoder ::Status::Error);
627627 }
628628 }
629629
@@ -640,10 +640,10 @@ SCENARIO("Test the decoding of command messages") {
640640
641641 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
642642 CBORMessageDecoder decoder;
643- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
643+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
644644
645645 THEN (" The decode is unsuccessful - LastValuesBeginCmd is not supported" ) {
646- REQUIRE (err == Decoder ::Status::Error);
646+ REQUIRE (err == MessageDecoder ::Status::Error);
647647 }
648648 }
649649
@@ -663,10 +663,10 @@ SCENARIO("Test the decoding of command messages") {
663663
664664 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
665665 CBORMessageDecoder decoder;
666- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
666+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
667667
668668 THEN (" The decode is unsuccessful - DeviceBeginCmd is not supported" ) {
669- REQUIRE (err == Decoder ::Status::Error);
669+ REQUIRE (err == MessageDecoder ::Status::Error);
670670 }
671671 }
672672
@@ -691,10 +691,10 @@ SCENARIO("Test the decoding of command messages") {
691691
692692 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
693693 CBORMessageDecoder decoder;
694- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
694+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
695695
696696 THEN (" The decode is unsuccessful - OtaProgressCmdUp is not supported" ) {
697- REQUIRE (err == Decoder ::Status::Error);
697+ REQUIRE (err == MessageDecoder ::Status::Error);
698698 }
699699 }
700700
@@ -711,10 +711,10 @@ SCENARIO("Test the decoding of command messages") {
711711
712712 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
713713 CBORMessageDecoder decoder;
714- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
714+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
715715
716716 THEN (" The decode is unsuccessful - TimezoneCommandUp is not supported" ) {
717- REQUIRE (err == Decoder ::Status::Error);
717+ REQUIRE (err == MessageDecoder ::Status::Error);
718718 }
719719 }
720720
@@ -736,10 +736,10 @@ SCENARIO("Test the decoding of command messages") {
736736
737737 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
738738 CBORMessageDecoder decoder;
739- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
739+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
740740
741741 THEN (" The decode is unsuccessful" ) {
742- REQUIRE (err == Decoder ::Status::Error);
742+ REQUIRE (err == MessageDecoder ::Status::Error);
743743 }
744744 }
745745
@@ -760,10 +760,10 @@ SCENARIO("Test the decoding of command messages") {
760760
761761 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
762762 CBORMessageDecoder decoder;
763- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
763+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
764764
765765 THEN (" The decode is unsuccessful" ) {
766- REQUIRE (err == Decoder ::Status::Error);
766+ REQUIRE (err == MessageDecoder ::Status::Error);
767767 }
768768 }
769769
@@ -777,10 +777,10 @@ SCENARIO("Test the decoding of command messages") {
777777
778778 size_t payload_length = sizeof (payload) / sizeof (uint8_t );
779779 CBORMessageDecoder decoder;
780- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
780+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
781781
782782 THEN (" The decode is unsuccessful" ) {
783- REQUIRE (err == Decoder ::Status::Error);
783+ REQUIRE (err == MessageDecoder ::Status::Error);
784784 }
785785 }
786786
0 commit comments