@@ -46,7 +46,14 @@ bool CheckGenerator(const PayloadContents & payload, std::string expectedResult,
46
46
std::string result;
47
47
ManualSetupPayloadGenerator generator (payload);
48
48
generator.SetAllowInvalidPayload (allowInvalidPayload);
49
- generator.payloadDecimalStringRepresentation (result);
49
+
50
+ CHIP_ERROR err = generator.payloadDecimalStringRepresentation (result);
51
+
52
+ if (err != CHIP_NO_ERROR)
53
+ {
54
+ printf (" Failed to generate decimal representation with error: %s\n " , ErrorStr (err));
55
+ return false ;
56
+ }
50
57
51
58
if (!expectedResult.empty ())
52
59
{
@@ -103,18 +110,6 @@ void TestDecimalRepresentation_FullPayloadWithZeros(nlTestSuite * inSuite, void
103
110
NL_TEST_ASSERT (inSuite, CheckGenerator (payload, expectedResult));
104
111
}
105
112
106
- void TestDecimalRepresentation_FullPayloadWithoutZeros (nlTestSuite * inSuite, void * inContext)
107
- {
108
- PayloadContents payload = GetDefaultPayload ();
109
- payload.commissioningFlow = CommissioningFlow::kCustom ;
110
- payload.vendorID = 45367 ;
111
- payload.productID = 14526 ;
112
-
113
- std::string expectedResult = " 64129507534536714526" ;
114
-
115
- NL_TEST_ASSERT (inSuite, CheckGenerator (payload, expectedResult));
116
- }
117
-
118
113
void TestDecimalRepresentation_FullPayloadWithoutZeros_DoesNotRequireCustomFlow (nlTestSuite * inSuite, void * inContext)
119
114
{
120
115
PayloadContents payload = GetDefaultPayload ();
@@ -126,29 +121,16 @@ void TestDecimalRepresentation_FullPayloadWithoutZeros_DoesNotRequireCustomFlow(
126
121
NL_TEST_ASSERT (inSuite, CheckGenerator (payload, expectedResult));
127
122
}
128
123
129
- void TestDecimalRepresentation_AllZeros (nlTestSuite * inSuite, void * inContext)
130
- {
131
- PayloadContents payload;
132
- payload.setUpPINCode = 0 ;
133
- payload.discriminator .SetLongValue (0 );
134
-
135
- std::string expectedResult;
136
-
137
- NL_TEST_ASSERT (inSuite, CheckGenerator (payload, expectedResult));
138
- }
139
-
140
- void TestDecimalRepresentation_AllOnes (nlTestSuite * inSuite, void * inContext)
124
+ void TestDecimalRepresentation_FullPayloadWithoutZeros (nlTestSuite * inSuite, void * inContext)
141
125
{
142
- PayloadContents payload;
143
- payload.setUpPINCode = 0x7FFFFFF ;
144
- payload.discriminator .SetLongValue (0xFFF );
126
+ PayloadContents payload = GetDefaultPayload ();
145
127
payload.commissioningFlow = CommissioningFlow::kCustom ;
146
- payload.vendorID = 65535 ;
147
- payload.productID = 65535 ;
128
+ payload.vendorID = 45367 ;
129
+ payload.productID = 14526 ;
148
130
149
- std::string expectedResult = " 76553581916553565535 " ;
131
+ std::string expectedResult = " 64129507534536714526 " ;
150
132
151
- NL_TEST_ASSERT (inSuite, CheckGenerator (payload, expectedResult, /* allowInvalidPayload */ true ));
133
+ NL_TEST_ASSERT (inSuite, CheckGenerator (payload, expectedResult));
152
134
}
153
135
154
136
void assertPayloadValues (nlTestSuite * inSuite, CHIP_ERROR actualError, CHIP_ERROR expectedError, const PayloadContents & payload,
@@ -204,6 +186,31 @@ void TestGenerateAndParser_ManualSetupCodeWithLongDiscriminator(nlTestSuite * in
204
186
}
205
187
}
206
188
189
+ void TestDecimalRepresentation_AllZeros (nlTestSuite * inSuite, void * inContext)
190
+ {
191
+ PayloadContents payload;
192
+ payload.setUpPINCode = 0 ;
193
+ payload.discriminator .SetLongValue (0 );
194
+
195
+ std::string expectedResult;
196
+
197
+ NL_TEST_ASSERT (inSuite, CheckGenerator (payload, expectedResult) == false );
198
+ }
199
+
200
+ void TestDecimalRepresentation_AllOnes (nlTestSuite * inSuite, void * inContext)
201
+ {
202
+ PayloadContents payload;
203
+ payload.setUpPINCode = 0x7FFFFFF ;
204
+ payload.discriminator .SetLongValue (0xFFF );
205
+ payload.commissioningFlow = CommissioningFlow::kCustom ;
206
+ payload.vendorID = 65535 ;
207
+ payload.productID = 65535 ;
208
+
209
+ std::string expectedResult = " 76553581916553565535" ;
210
+
211
+ NL_TEST_ASSERT (inSuite, CheckGenerator (payload, expectedResult, /* allowInvalidPayload*/ true ));
212
+ }
213
+
207
214
char ComputeCheckChar (const std::string & str)
208
215
{
209
216
// Strip out dashes, if any, from the string before computing the checksum.
0 commit comments