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