12
12
#include < memory>
13
13
14
14
#include < util/CBORTestUtil.h>
15
- #include < CborDecoder .h>
15
+ #include < IoTCloudMessageEncoder .h>
16
16
#include < MessageDecoder.h>
17
17
18
18
/* *****************************************************************************
@@ -40,11 +40,11 @@ SCENARIO("Test the decoding of command messages") {
40
40
41
41
size_t payload_length = sizeof (payload) / sizeof (uint8_t );
42
42
CBORMessageDecoder decoder;
43
- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
43
+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
44
44
const char *thingIdToMatch = " e4494d55-872a-4fd2-9646-92f87949394c" ;
45
45
46
46
THEN (" The decode is successful" ) {
47
- REQUIRE (err == Decoder ::Status::Complete);
47
+ REQUIRE (err == MessageDecoder ::Status::Complete);
48
48
REQUIRE (strcmp (command.thingUpdateCmd .params .thing_id , thingIdToMatch) == 0 );
49
49
REQUIRE (command.c .id == ThingUpdateCmdId);
50
50
}
@@ -69,11 +69,11 @@ SCENARIO("Test the decoding of command messages") {
69
69
70
70
size_t payload_length = sizeof (payload) / sizeof (uint8_t );
71
71
CBORMessageDecoder decoder;
72
- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
72
+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
73
73
const char *thingIdToMatch = " e4494d55-872a-4fd2-9646-92f87949394c" ;
74
74
75
75
THEN (" The decode is successful" ) {
76
- REQUIRE (err == Decoder ::Status::Complete);
76
+ REQUIRE (err == MessageDecoder ::Status::Complete);
77
77
REQUIRE (strcmp (command.thingDetachCmd .params .thing_id , thingIdToMatch) == 0 );
78
78
REQUIRE (command.c .id == ThingDetachCmdId);
79
79
}
@@ -94,10 +94,10 @@ SCENARIO("Test the decoding of command messages") {
94
94
95
95
size_t payload_length = sizeof (payload) / sizeof (uint8_t );
96
96
CBORMessageDecoder decoder;
97
- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
97
+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
98
98
99
99
THEN (" The decode is unsuccessful" ) {
100
- REQUIRE (err == Decoder ::Status::Error);
100
+ REQUIRE (err == MessageDecoder ::Status::Error);
101
101
}
102
102
}
103
103
@@ -115,10 +115,10 @@ SCENARIO("Test the decoding of command messages") {
115
115
116
116
size_t payload_length = sizeof (payload) / sizeof (uint8_t );
117
117
CBORMessageDecoder decoder;
118
- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
118
+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
119
119
120
120
THEN (" The decode is successful" ) {
121
- REQUIRE (err == Decoder ::Status::Error);
121
+ REQUIRE (err == MessageDecoder ::Status::Error);
122
122
}
123
123
}
124
124
@@ -140,10 +140,10 @@ SCENARIO("Test the decoding of command messages") {
140
140
141
141
size_t payload_length = sizeof (payload) / sizeof (uint8_t );
142
142
CBORMessageDecoder decoder;
143
- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
143
+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
144
144
145
145
THEN (" The decode is successful" ) {
146
- REQUIRE (err == Decoder ::Status::Complete);
146
+ REQUIRE (err == MessageDecoder ::Status::Complete);
147
147
REQUIRE (command.timezoneCommandDown .params .offset == (uint32_t )1708963873 );
148
148
REQUIRE (command.timezoneCommandDown .params .until == (uint32_t )2024579473 );
149
149
REQUIRE (command.c .id == TimezoneCommandDownId);
@@ -170,10 +170,10 @@ SCENARIO("Test the decoding of command messages") {
170
170
171
171
size_t payload_length = sizeof (payload) / sizeof (uint8_t );
172
172
CBORMessageDecoder decoder;
173
- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
173
+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
174
174
175
175
THEN (" The decode is successful" ) {
176
- REQUIRE (err == Decoder ::Status::Complete);
176
+ REQUIRE (err == MessageDecoder ::Status::Complete);
177
177
REQUIRE (command.lastValuesUpdateCmd .params .length == 13 );
178
178
REQUIRE (command.lastValuesUpdateCmd .params .last_values [0 ] == (uint8_t )0x00 );
179
179
REQUIRE (command.lastValuesUpdateCmd .params .last_values [1 ] == (uint8_t )0x01 );
@@ -250,14 +250,14 @@ SCENARIO("Test the decoding of command messages") {
250
250
251
251
size_t payload_length = sizeof (payload) / sizeof (uint8_t );
252
252
CBORMessageDecoder decoder;
253
- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
253
+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
254
254
255
255
uint8_t otaIdToMatch[ID_SIZE] = { 0xC7 , 0x3C , 0xB0 , 0x45 , 0xF9 , 0xC2 , 0x43 , 0x45 ,
256
256
0x85 , 0xAF , 0xFA , 0x36 , 0xA3 , 0x07 , 0xBF , 0xE7 };
257
257
const char *urlToMatch = " https://boards-int.oniudra.cc/storage/firmware/v1/df1eac9c7bd63473fffb117f9873703e4ec955931e267f26262b0949bc16dc49" ;
258
258
259
259
THEN (" The decode is successful" ) {
260
- REQUIRE (err == Decoder ::Status::Complete);
260
+ REQUIRE (err == MessageDecoder ::Status::Complete);
261
261
REQUIRE (memcmp (command.otaUpdateCmdDown .params .id , otaIdToMatch, ID_SIZE) == 0 );
262
262
REQUIRE (strcmp (command.otaUpdateCmdDown .params .url , urlToMatch) == 0 );
263
263
// Initial SHA256 check
@@ -389,10 +389,10 @@ SCENARIO("Test the decoding of command messages") {
389
389
390
390
size_t payload_length = sizeof (payload) / sizeof (uint8_t );
391
391
CBORMessageDecoder decoder;
392
- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
392
+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
393
393
394
394
THEN (" The decode is successful" ) {
395
- REQUIRE (err == Decoder ::Status::Error);
395
+ REQUIRE (err == MessageDecoder ::Status::Error);
396
396
}
397
397
}
398
398
@@ -453,10 +453,10 @@ SCENARIO("Test the decoding of command messages") {
453
453
454
454
size_t payload_length = sizeof (payload) / sizeof (uint8_t );
455
455
CBORMessageDecoder decoder;
456
- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
456
+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
457
457
458
458
THEN (" The decode is successful" ) {
459
- REQUIRE (err == Decoder ::Status::Error);
459
+ REQUIRE (err == MessageDecoder ::Status::Error);
460
460
}
461
461
}
462
462
@@ -512,10 +512,10 @@ SCENARIO("Test the decoding of command messages") {
512
512
513
513
size_t payload_length = sizeof (payload) / sizeof (uint8_t );
514
514
CBORMessageDecoder decoder;
515
- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
515
+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
516
516
517
517
THEN (" The decode is successful" ) {
518
- REQUIRE (err == Decoder ::Status::Error);
518
+ REQUIRE (err == MessageDecoder ::Status::Error);
519
519
}
520
520
}
521
521
@@ -571,10 +571,10 @@ SCENARIO("Test the decoding of command messages") {
571
571
572
572
size_t payload_length = sizeof (payload) / sizeof (uint8_t );
573
573
CBORMessageDecoder decoder;
574
- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
574
+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
575
575
576
576
THEN (" The decode is successful" ) {
577
- REQUIRE (err == Decoder ::Status::Error);
577
+ REQUIRE (err == MessageDecoder ::Status::Error);
578
578
}
579
579
}
580
580
@@ -597,10 +597,10 @@ SCENARIO("Test the decoding of command messages") {
597
597
598
598
size_t payload_length = sizeof (payload) / sizeof (uint8_t );
599
599
CBORMessageDecoder decoder;
600
- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
600
+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
601
601
602
602
THEN (" The decode is unsuccessful - OtaBeginUp is not supported" ) {
603
- REQUIRE (err == Decoder ::Status::Error);
603
+ REQUIRE (err == MessageDecoder ::Status::Error);
604
604
}
605
605
}
606
606
@@ -620,10 +620,10 @@ SCENARIO("Test the decoding of command messages") {
620
620
621
621
size_t payload_length = sizeof (payload) / sizeof (uint8_t );
622
622
CBORMessageDecoder decoder;
623
- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
623
+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
624
624
625
625
THEN (" The decode is unsuccessful - ThingBeginCmd is not supported" ) {
626
- REQUIRE (err == Decoder ::Status::Error);
626
+ REQUIRE (err == MessageDecoder ::Status::Error);
627
627
}
628
628
}
629
629
@@ -640,10 +640,10 @@ SCENARIO("Test the decoding of command messages") {
640
640
641
641
size_t payload_length = sizeof (payload) / sizeof (uint8_t );
642
642
CBORMessageDecoder decoder;
643
- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
643
+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
644
644
645
645
THEN (" The decode is unsuccessful - LastValuesBeginCmd is not supported" ) {
646
- REQUIRE (err == Decoder ::Status::Error);
646
+ REQUIRE (err == MessageDecoder ::Status::Error);
647
647
}
648
648
}
649
649
@@ -663,10 +663,10 @@ SCENARIO("Test the decoding of command messages") {
663
663
664
664
size_t payload_length = sizeof (payload) / sizeof (uint8_t );
665
665
CBORMessageDecoder decoder;
666
- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
666
+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
667
667
668
668
THEN (" The decode is unsuccessful - DeviceBeginCmd is not supported" ) {
669
- REQUIRE (err == Decoder ::Status::Error);
669
+ REQUIRE (err == MessageDecoder ::Status::Error);
670
670
}
671
671
}
672
672
@@ -691,10 +691,10 @@ SCENARIO("Test the decoding of command messages") {
691
691
692
692
size_t payload_length = sizeof (payload) / sizeof (uint8_t );
693
693
CBORMessageDecoder decoder;
694
- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
694
+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
695
695
696
696
THEN (" The decode is unsuccessful - OtaProgressCmdUp is not supported" ) {
697
- REQUIRE (err == Decoder ::Status::Error);
697
+ REQUIRE (err == MessageDecoder ::Status::Error);
698
698
}
699
699
}
700
700
@@ -711,10 +711,10 @@ SCENARIO("Test the decoding of command messages") {
711
711
712
712
size_t payload_length = sizeof (payload) / sizeof (uint8_t );
713
713
CBORMessageDecoder decoder;
714
- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
714
+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
715
715
716
716
THEN (" The decode is unsuccessful - TimezoneCommandUp is not supported" ) {
717
- REQUIRE (err == Decoder ::Status::Error);
717
+ REQUIRE (err == MessageDecoder ::Status::Error);
718
718
}
719
719
}
720
720
@@ -736,10 +736,10 @@ SCENARIO("Test the decoding of command messages") {
736
736
737
737
size_t payload_length = sizeof (payload) / sizeof (uint8_t );
738
738
CBORMessageDecoder decoder;
739
- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
739
+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
740
740
741
741
THEN (" The decode is unsuccessful" ) {
742
- REQUIRE (err == Decoder ::Status::Error);
742
+ REQUIRE (err == MessageDecoder ::Status::Error);
743
743
}
744
744
}
745
745
@@ -760,10 +760,10 @@ SCENARIO("Test the decoding of command messages") {
760
760
761
761
size_t payload_length = sizeof (payload) / sizeof (uint8_t );
762
762
CBORMessageDecoder decoder;
763
- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
763
+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
764
764
765
765
THEN (" The decode is unsuccessful" ) {
766
- REQUIRE (err == Decoder ::Status::Error);
766
+ REQUIRE (err == MessageDecoder ::Status::Error);
767
767
}
768
768
}
769
769
@@ -777,10 +777,10 @@ SCENARIO("Test the decoding of command messages") {
777
777
778
778
size_t payload_length = sizeof (payload) / sizeof (uint8_t );
779
779
CBORMessageDecoder decoder;
780
- Decoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
780
+ MessageDecoder ::Status err = decoder.decode ((Message*)&command, payload, payload_length);
781
781
782
782
THEN (" The decode is unsuccessful" ) {
783
- REQUIRE (err == Decoder ::Status::Error);
783
+ REQUIRE (err == MessageDecoder ::Status::Error);
784
784
}
785
785
}
786
786
0 commit comments