Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
86e8f1fd
Commit
86e8f1fd
authored
May 27, 2016
by
Thomas Van Lenten
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1604 from jonwallg/repeated_types
fix expected class checking in GPBSetMessageRepeatedField
parents
0f27cab4
e72805ec
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
2 deletions
+29
-2
GPBUtilities.m
objectivec/GPBUtilities.m
+2
-2
GPBUtilitiesTests.m
objectivec/Tests/GPBUtilitiesTests.m
+27
-0
No files found.
objectivec/GPBUtilities.m
View file @
86e8f1fd
...
...
@@ -948,10 +948,10 @@ void GPBSetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field, id
case
GPBDataTypeString
:
case
GPBDataTypeMessage
:
case
GPBDataTypeGroup
:
expectedClass
=
[
NSMutable
Dictionar
y
class
];
expectedClass
=
[
NSMutable
Arra
y
class
];
break
;
case
GPBDataTypeEnum
:
expectedClass
=
[
GPB
Bool
Array
class
];
expectedClass
=
[
GPB
Enum
Array
class
];
break
;
}
if
(
array
&&
!
[
array
isKindOfClass
:
expectedClass
])
{
...
...
objectivec/Tests/GPBUtilitiesTests.m
View file @
86e8f1fd
...
...
@@ -170,4 +170,31 @@
// TODO(thomasvl): add test with extensions once those format with correct names.
-
(
void
)
testSetRepeatedFields
{
TestAllTypes
*
message
=
[
TestAllTypes
message
];
NSDictionary
*
repeatedFieldValues
=
@{
@"repeatedStringArray"
:
[@[
@"foo"
,
@"bar"
]
mutableCopy
],
@"repeatedBoolArray"
:
[
GPBBoolArray
arrayWithValue
:
YES
],
@"repeatedInt32Array"
:
[
GPBInt32Array
arrayWithValue
:
14
],
@"repeatedInt64Array"
:
[
GPBInt64Array
arrayWithValue
:
15
],
@"repeatedUint32Array"
:
[
GPBUInt32Array
arrayWithValue
:
16
],
@"repeatedUint64Array"
:
[
GPBUInt64Array
arrayWithValue
:
16
],
@"repeatedFloatArray"
:
[
GPBFloatArray
arrayWithValue
:
16
],
@"repeatedDoubleArray"
:
[
GPBDoubleArray
arrayWithValue
:
16
],
@"repeatedNestedEnumArray"
:
[
GPBEnumArray
arrayWithValidationFunction
:
TestAllTypes_NestedEnum_IsValidValue
rawValue
:
TestAllTypes_NestedEnum_Foo
],
};
for
(
NSString
*
fieldName
in
repeatedFieldValues
)
{
GPBFieldDescriptor
*
field
=
[
message
.
descriptor
fieldWithName
:
fieldName
];
XCTAssertNotNil
(
field
,
@"No field with name: %@"
,
fieldName
);
id
expectedValues
=
repeatedFieldValues
[
fieldName
];
GPBSetMessageRepeatedField
(
message
,
field
,
expectedValues
);
XCTAssertEqualObjects
(
expectedValues
,
[
message
valueForKeyPath
:
fieldName
]);
}
}
@end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment