OLD | NEW |
1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
4 // | 4 // |
5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
7 // met: | 7 // met: |
8 // | 8 // |
9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 @implementation UnknownFieldSetTest | 54 @implementation UnknownFieldSetTest |
55 | 55 |
56 - (void)setUp { | 56 - (void)setUp { |
57 allFields_ = [self allSetRepeatedCount:kGPBDefaultRepeatCount]; | 57 allFields_ = [self allSetRepeatedCount:kGPBDefaultRepeatCount]; |
58 allFieldsData_ = [allFields_ data]; | 58 allFieldsData_ = [allFields_ data]; |
59 emptyMessage_ = [TestEmptyMessage parseFromData:allFieldsData_ error:NULL]; | 59 emptyMessage_ = [TestEmptyMessage parseFromData:allFieldsData_ error:NULL]; |
60 unknownFields_ = emptyMessage_.unknownFields; | 60 unknownFields_ = emptyMessage_.unknownFields; |
61 } | 61 } |
62 | 62 |
| 63 - (GPBUnknownField *)getField:(int32_t)number { |
| 64 return [unknownFields_ getField:number]; |
| 65 } |
| 66 |
63 // Constructs a protocol buffer which contains fields with all the same | 67 // Constructs a protocol buffer which contains fields with all the same |
64 // numbers as allFieldsData except that each field is some other wire | 68 // numbers as allFieldsData except that each field is some other wire |
65 // type. | 69 // type. |
66 - (NSData*)getBizarroData { | 70 - (NSData*)getBizarroData { |
67 GPBUnknownFieldSet* bizarroFields = | 71 GPBUnknownFieldSet* bizarroFields = |
68 [[[GPBUnknownFieldSet alloc] init] autorelease]; | 72 [[[GPBUnknownFieldSet alloc] init] autorelease]; |
69 NSUInteger count = [unknownFields_ countOfFields]; | 73 NSUInteger count = [unknownFields_ countOfFields]; |
70 int32_t tags[count]; | 74 int32_t tags[count]; |
71 [unknownFields_ getTags:tags]; | 75 [unknownFields_ getTags:tags]; |
72 for (NSUInteger i = 0; i < count; ++i) { | 76 for (NSUInteger i = 0; i < count; ++i) { |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 [field1 addFixed32:2]; | 250 [field1 addFixed32:2]; |
247 [field1 addFixed64:3]; | 251 [field1 addFixed64:3]; |
248 [field1 addLengthDelimited:[NSData dataWithBytes:"hello" length:5]]; | 252 [field1 addLengthDelimited:[NSData dataWithBytes:"hello" length:5]]; |
249 [field1 addGroup:[[unknownFields_ copy] autorelease]]; | 253 [field1 addGroup:[[unknownFields_ copy] autorelease]]; |
250 GPBUnknownField* field2 = [[[GPBUnknownField alloc] initWithNumber:2] autorele
ase]; | 254 GPBUnknownField* field2 = [[[GPBUnknownField alloc] initWithNumber:2] autorele
ase]; |
251 [field2 mergeFromField:field1]; | 255 [field2 mergeFromField:field1]; |
252 XCTAssertEqualObjects(field1, field2); | 256 XCTAssertEqualObjects(field1, field2); |
253 } | 257 } |
254 | 258 |
255 @end | 259 @end |
OLD | NEW |