@@ -212,49 +212,49 @@ - (void)testQRCodeParserWithOptionalData
212
212
}
213
213
214
214
// Test access by tag
215
- XCTAssertEqualObjects ([payload vendorElementWithTag: 130 ].stringValue , @" myData" );
216
- XCTAssertEqualObjects ([payload vendorElementWithTag: 131 ].integerValue , @12 );
215
+ XCTAssertEqualObjects ([payload vendorElementWithTag: @ 130 ].stringValue , @" myData" );
216
+ XCTAssertEqualObjects ([payload vendorElementWithTag: @ 131 ].integerValue , @12 );
217
217
}
218
218
219
219
- (void )testAddVendorElement
220
220
{
221
221
MTRSetupPayload * payload = [[MTRSetupPayload alloc ] initWithSetupPasscode: @314159 discriminator: @555 ];
222
222
XCTAssertEqual (payload.vendorElements .count , 0 );
223
- [payload addOrReplaceVendorElement: [[MTROptionalQRCodeInfo alloc ] initWithTag: 0xff int32Value: 42 ]];
223
+ [payload addOrReplaceVendorElement: [[MTROptionalQRCodeInfo alloc ] initWithTag: @ 0xff int32Value: 42 ]];
224
224
XCTAssertEqual (payload.vendorElements .count , 1 );
225
225
XCTAssertEqualObjects (payload.vendorElements .firstObject .integerValue , @42 );
226
- XCTAssertEqualObjects ([payload vendorElementWithTag: 0xff ].integerValue , @42 );
226
+ XCTAssertEqualObjects ([payload vendorElementWithTag: @ 0xff ].integerValue , @42 );
227
227
}
228
228
229
229
- (void )testVendorElementsEncodedToQRCode
230
230
{
231
231
MTRSetupPayload * payload = [[MTRSetupPayload alloc ] initWithSetupPasscode: @314159 discriminator: @555 ];
232
- [payload addOrReplaceVendorElement: [[MTROptionalQRCodeInfo alloc ] initWithTag: 0x80 stringValue: @" Hello" ]];
232
+ [payload addOrReplaceVendorElement: [[MTROptionalQRCodeInfo alloc ] initWithTag: @ 0x80 stringValue: @" Hello" ]];
233
233
MTRSetupPayload * decoded = [[MTRSetupPayload alloc ] initWithPayload: payload.qrCodeString];
234
234
XCTAssertNotNil (decoded);
235
- XCTAssertEqualObjects ([decoded vendorElementWithTag: 0x80 ].stringValue , @" Hello" );
235
+ XCTAssertEqualObjects ([decoded vendorElementWithTag: @ 0x80 ].stringValue , @" Hello" );
236
236
}
237
237
238
238
- (void )testRemoveVendorElements
239
239
{
240
240
MTRSetupPayload * payload = [[MTRSetupPayload alloc ] initWithPayload: @" MT:M5L90MP500K64J0A33P0SET70.QT52B.E23-WZE0WISA0DK5N1K8SQ1RYCU1O0" ];
241
241
XCTAssertNotNil (payload);
242
242
XCTAssertEqual (payload.vendorElements .count , 2 );
243
- [payload removeVendorElementWithTag: 0 ]; // no change, no vendor element present with this tag
243
+ [payload removeVendorElementWithTag: @ 128 ]; // no change, no vendor element present with this tag
244
244
XCTAssertEqual (payload.vendorElements .count , 2 );
245
- [payload removeVendorElementWithTag: 130 ];
245
+ [payload removeVendorElementWithTag: @ 130 ];
246
246
XCTAssertEqual (payload.vendorElements .count , 1 );
247
- [payload removeVendorElementWithTag: 131 ];
247
+ [payload removeVendorElementWithTag: @ 131 ];
248
248
XCTAssertEqual (payload.vendorElements .count , 0 );
249
249
}
250
250
251
251
- (void )testQrCodeInfoCopyAndEquality
252
252
{
253
- MTROptionalQRCodeInfo * a = [[MTROptionalQRCodeInfo alloc ] initWithTag: 1 stringValue: @" hello" ];
254
- MTROptionalQRCodeInfo * b = [[MTROptionalQRCodeInfo alloc ] initWithTag: 1 stringValue: @" hello" ];
255
- MTROptionalQRCodeInfo * c = [[MTROptionalQRCodeInfo alloc ] initWithTag: 0xff stringValue: @" hello" ];
256
- MTROptionalQRCodeInfo * d = [[MTROptionalQRCodeInfo alloc ] initWithTag: 1 int32Value: 42 ];
257
- MTROptionalQRCodeInfo * e = [[MTROptionalQRCodeInfo alloc ] initWithTag: 1 int32Value: 0xbad ];
253
+ MTROptionalQRCodeInfo * a = [[MTROptionalQRCodeInfo alloc ] initWithTag: @ 0x88 stringValue: @" hello" ];
254
+ MTROptionalQRCodeInfo * b = [[MTROptionalQRCodeInfo alloc ] initWithTag: @ 0x88 stringValue: @" hello" ];
255
+ MTROptionalQRCodeInfo * c = [[MTROptionalQRCodeInfo alloc ] initWithTag: @ 0xff stringValue: @" hello" ];
256
+ MTROptionalQRCodeInfo * d = [[MTROptionalQRCodeInfo alloc ] initWithTag: @ 0x88 int32Value: 42 ];
257
+ MTROptionalQRCodeInfo * e = [[MTROptionalQRCodeInfo alloc ] initWithTag: @ 0x88 int32Value: 0xbad ];
258
258
XCTAssertTrue ([a isEqual: a]);
259
259
XCTAssertTrue ([a isEqual: [a copy ]]);
260
260
XCTAssertTrue ([a isEqual: b]);
@@ -458,7 +458,7 @@ - (void)testCopyingAndEquality
458
458
XCTAssertTrue ([copy isEqual: payload]);
459
459
XCTAssertEqual (payload.hash , copy.hash );
460
460
461
- MTROptionalQRCodeInfo * element = [[MTROptionalQRCodeInfo alloc ] initWithTag: 0x80 stringValue: @" To infinity and beyond!" ];
461
+ MTROptionalQRCodeInfo * element = [[MTROptionalQRCodeInfo alloc ] initWithTag: @ 0x80 stringValue: @" To infinity and beyond!" ];
462
462
[copy addOrReplaceVendorElement: element];
463
463
XCTAssertFalse ([copy isEqual: payload]);
464
464
[payload addOrReplaceVendorElement: element];
@@ -479,4 +479,12 @@ - (void)testCanParseFutureDiscoveryMethod
479
479
XCTAssertEqual ([[MTRSetupPayload alloc ] initWithPayload: @" MT:-24J0Q.C.0KA0648G00" ].discoveryCapabilities , 0xfa );
480
480
}
481
481
482
+ - (void )testDescriptionShowsUnknownDiscoveryMethods
483
+ {
484
+ MTRSetupPayload * a = [[MTRSetupPayload alloc ] initWithSetupPasscode: @888 discriminator: @555 ];
485
+ MTRSetupPayload * b = [a copy ];
486
+ b.discoveryCapabilities |= 0x80 ;
487
+ XCTAssertNotEqualObjects (a.description , b.description );
488
+ }
489
+
482
490
@end
0 commit comments