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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 NSData *expectedData = | 163 NSData *expectedData = |
164 [self getDataFileNamed:fileName dataToWrite:resultData]; | 164 [self getDataFileNamed:fileName dataToWrite:resultData]; |
165 NSString *expected = [[NSString alloc] initWithData:expectedData | 165 NSString *expected = [[NSString alloc] initWithData:expectedData |
166 encoding:NSUTF8StringEncoding]; | 166 encoding:NSUTF8StringEncoding]; |
167 XCTAssertEqualObjects(expected, result); | 167 XCTAssertEqualObjects(expected, result); |
168 [expected release]; | 168 [expected release]; |
169 } | 169 } |
170 | 170 |
171 // TODO(thomasvl): add test with extensions once those format with correct names
. | 171 // TODO(thomasvl): add test with extensions once those format with correct names
. |
172 | 172 |
| 173 - (void)testSetRepeatedFields { |
| 174 TestAllTypes *message = [TestAllTypes message]; |
| 175 |
| 176 NSDictionary *repeatedFieldValues = @{ |
| 177 @"repeatedStringArray" : [@[@"foo", @"bar"] mutableCopy], |
| 178 @"repeatedBoolArray" : [GPBBoolArray arrayWithValue:YES], |
| 179 @"repeatedInt32Array" : [GPBInt32Array arrayWithValue:14], |
| 180 @"repeatedInt64Array" : [GPBInt64Array arrayWithValue:15], |
| 181 @"repeatedUint32Array" : [GPBUInt32Array arrayWithValue:16], |
| 182 @"repeatedUint64Array" : [GPBUInt64Array arrayWithValue:16], |
| 183 @"repeatedFloatArray" : [GPBFloatArray arrayWithValue:16], |
| 184 @"repeatedDoubleArray" : [GPBDoubleArray arrayWithValue:16], |
| 185 @"repeatedNestedEnumArray" : |
| 186 [GPBEnumArray arrayWithValidationFunction:TestAllTypes_NestedEnum_IsVali
dValue |
| 187 rawValue:TestAllTypes_NestedEnum_Foo], |
| 188 }; |
| 189 for (NSString *fieldName in repeatedFieldValues) { |
| 190 GPBFieldDescriptor *field = |
| 191 [message.descriptor fieldWithName:fieldName]; |
| 192 XCTAssertNotNil(field, @"No field with name: %@", fieldName); |
| 193 id expectedValues = repeatedFieldValues[fieldName]; |
| 194 GPBSetMessageRepeatedField(message, field, expectedValues); |
| 195 XCTAssertEqualObjects(expectedValues, |
| 196 [message valueForKeyPath:fieldName]); |
| 197 } |
| 198 } |
| 199 |
173 @end | 200 @end |
OLD | NEW |