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
a274c67c
Commit
a274c67c
authored
Oct 03, 2017
by
Thomas Van Lenten
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Build out more complete code coverage in the tests.
parent
94771235
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
120 additions
and
7 deletions
+120
-7
GPBDescriptor.m
objectivec/GPBDescriptor.m
+0
-4
GPBUnknownField.m
objectivec/GPBUnknownField.m
+4
-2
GPBArrayTests.m
objectivec/Tests/GPBArrayTests.m
+0
-0
GPBDescriptorTests.m
objectivec/Tests/GPBDescriptorTests.m
+116
-1
GPBUnknownFieldSetTest.m
objectivec/Tests/GPBUnknownFieldSetTest.m
+0
-0
No files found.
objectivec/GPBDescriptor.m
View file @
a274c67c
...
...
@@ -1027,10 +1027,6 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
return
GPBExtensionIsRepeated
(
description_
);
}
-
(
BOOL
)
isMap
{
return
(
description_
->
options
&
GPBFieldMapKeyMask
)
!=
0
;
}
-
(
BOOL
)
isPackable
{
return
GPBExtensionIsPacked
(
description_
);
}
...
...
objectivec/GPBUnknownField.m
View file @
a274c67c
...
...
@@ -97,6 +97,7 @@
if
(
self
==
object
)
return
YES
;
if
(
!
[
object
isKindOfClass
:[
GPBUnknownField
class
]])
return
NO
;
GPBUnknownField
*
field
=
(
GPBUnknownField
*
)
object
;
if
(
number_
!=
field
->
number_
)
return
NO
;
BOOL
equalVarint
=
(
mutableVarintList_
.
count
==
0
&&
field
->
mutableVarintList_
.
count
==
0
)
||
[
mutableVarintList_
isEqual
:
field
->
mutableVarintList_
];
...
...
@@ -202,8 +203,9 @@
}
-
(
NSString
*
)
description
{
NSMutableString
*
description
=
[
NSMutableString
stringWithFormat
:
@"<%@ %p>: Field: %d {
\n
"
,
[
self
class
],
self
,
number_
];
NSMutableString
*
description
=
[
NSMutableString
stringWithFormat
:
@"<%@ %p>: Field: %d {
\n
"
,
[
self
class
],
self
,
number_
];
[
mutableVarintList_
enumerateValuesWithBlock
:
^
(
uint64_t
value
,
NSUInteger
idx
,
BOOL
*
stop
)
{
#pragma unused(idx, stop)
...
...
objectivec/Tests/GPBArrayTests.m
View file @
a274c67c
This diff is collapsed.
Click to expand it.
objectivec/Tests/GPBDescriptorTests.m
View file @
a274c67c
...
...
@@ -32,7 +32,7 @@
#import <objc/runtime.h>
#import "GPBDescriptor.h"
#import "GPBDescriptor
_PackagePrivate
.h"
#import "google/protobuf/Unittest.pbobjc.h"
#import "google/protobuf/UnittestObjc.pbobjc.h"
#import "google/protobuf/Descriptor.pbobjc.h"
...
...
@@ -83,6 +83,8 @@
XCTAssertNotNil
(
fieldDescriptorWithNumber
.
enumDescriptor
);
XCTAssertEqualObjects
(
fieldDescriptorWithNumber
.
enumDescriptor
.
name
,
@"TestAllTypes_NestedEnum"
);
XCTAssertEqual
(
fieldDescriptorWithName
.
number
,
fieldDescriptorWithNumber
.
number
);
XCTAssertEqual
(
fieldDescriptorWithName
.
dataType
,
GPBDataTypeEnum
);
// Foreign Enum
fieldDescriptorWithName
=
[
descriptor
fieldWithName
:
@"optionalForeignEnum"
];
...
...
@@ -93,6 +95,8 @@
XCTAssertNotNil
(
fieldDescriptorWithNumber
.
enumDescriptor
);
XCTAssertEqualObjects
(
fieldDescriptorWithNumber
.
enumDescriptor
.
name
,
@"ForeignEnum"
);
XCTAssertEqual
(
fieldDescriptorWithName
.
number
,
fieldDescriptorWithNumber
.
number
);
XCTAssertEqual
(
fieldDescriptorWithName
.
dataType
,
GPBDataTypeEnum
);
// Import Enum
fieldDescriptorWithName
=
[
descriptor
fieldWithName
:
@"optionalImportEnum"
];
...
...
@@ -103,6 +107,8 @@
XCTAssertNotNil
(
fieldDescriptorWithNumber
.
enumDescriptor
);
XCTAssertEqualObjects
(
fieldDescriptorWithNumber
.
enumDescriptor
.
name
,
@"ImportEnum"
);
XCTAssertEqual
(
fieldDescriptorWithName
.
number
,
fieldDescriptorWithNumber
.
number
);
XCTAssertEqual
(
fieldDescriptorWithName
.
dataType
,
GPBDataTypeEnum
);
// Nested Message
fieldDescriptorWithName
=
[
descriptor
fieldWithName
:
@"optionalNestedMessage"
];
...
...
@@ -111,6 +117,8 @@
XCTAssertNotNil
(
fieldDescriptorWithNumber
);
XCTAssertEqual
(
fieldDescriptorWithName
,
fieldDescriptorWithNumber
);
XCTAssertNil
(
fieldDescriptorWithNumber
.
enumDescriptor
);
XCTAssertEqual
(
fieldDescriptorWithName
.
number
,
fieldDescriptorWithNumber
.
number
);
XCTAssertEqual
(
fieldDescriptorWithName
.
dataType
,
GPBDataTypeMessage
);
// Foreign Message
fieldDescriptorWithName
=
...
...
@@ -120,6 +128,8 @@
XCTAssertNotNil
(
fieldDescriptorWithNumber
);
XCTAssertEqual
(
fieldDescriptorWithName
,
fieldDescriptorWithNumber
);
XCTAssertNil
(
fieldDescriptorWithNumber
.
enumDescriptor
);
XCTAssertEqual
(
fieldDescriptorWithName
.
number
,
fieldDescriptorWithNumber
.
number
);
XCTAssertEqual
(
fieldDescriptorWithName
.
dataType
,
GPBDataTypeMessage
);
// Import Message
fieldDescriptorWithName
=
[
descriptor
fieldWithName
:
@"optionalImportMessage"
];
...
...
@@ -128,6 +138,12 @@
XCTAssertNotNil
(
fieldDescriptorWithNumber
);
XCTAssertEqual
(
fieldDescriptorWithName
,
fieldDescriptorWithNumber
);
XCTAssertNil
(
fieldDescriptorWithNumber
.
enumDescriptor
);
XCTAssertEqual
(
fieldDescriptorWithName
.
number
,
fieldDescriptorWithNumber
.
number
);
XCTAssertEqual
(
fieldDescriptorWithName
.
dataType
,
GPBDataTypeMessage
);
// Some failed lookups.
XCTAssertNil
([
descriptor
fieldWithName
:
@"NOT THERE"
]);
XCTAssertNil
([
descriptor
fieldWithNumber
:
9876543
]);
}
-
(
void
)
testEnumDescriptor
{
...
...
@@ -159,6 +175,7 @@
XCTAssertNotNil
(
enumName
);
XCTAssertTrue
([
descriptor
getValue
:
&
value
forEnumTextFormatName
:
@"FOO"
]);
XCTAssertEqual
(
value
,
TestAllTypes_NestedEnum_Foo
);
XCTAssertNil
([
descriptor
textFormatNameForValue
:
99999
]);
// Bad values
enumName
=
[
descriptor
enumNameForValue
:
0
];
...
...
@@ -253,4 +270,102 @@
XCTAssertNil
(
bazString
.
containingOneof
);
}
-
(
void
)
testExtensiondDescriptor
{
Class
msgClass
=
[
TestAllExtensions
class
];
Class
packedMsgClass
=
[
TestPackedExtensions
class
];
// Int
GPBExtensionDescriptor
*
descriptor
=
[
UnittestRoot
optionalInt32Extension
];
XCTAssertNotNil
(
descriptor
);
XCTAssertEqual
(
descriptor
.
containingMessageClass
,
msgClass
);
// ptr equality
XCTAssertFalse
(
descriptor
.
isPackable
);
XCTAssertEqualObjects
(
descriptor
.
defaultValue
,
@0
);
XCTAssertNil
(
descriptor
.
enumDescriptor
);
descriptor
=
[
UnittestRoot
defaultInt32Extension
];
XCTAssertNotNil
(
descriptor
);
XCTAssertEqual
(
descriptor
.
containingMessageClass
,
msgClass
);
// ptr equality
XCTAssertFalse
(
descriptor
.
isPackable
);
XCTAssertEqualObjects
(
descriptor
.
defaultValue
,
@41
);
XCTAssertNil
(
descriptor
.
enumDescriptor
);
// Enum
descriptor
=
[
UnittestRoot
optionalNestedEnumExtension
];
XCTAssertNotNil
(
descriptor
);
XCTAssertEqual
(
descriptor
.
containingMessageClass
,
msgClass
);
// ptr equality
XCTAssertFalse
(
descriptor
.
isPackable
);
XCTAssertEqual
(
descriptor
.
defaultValue
,
@1
);
XCTAssertEqualObjects
(
descriptor
.
enumDescriptor
.
name
,
@"TestAllTypes_NestedEnum"
);
descriptor
=
[
UnittestRoot
defaultNestedEnumExtension
];
XCTAssertNotNil
(
descriptor
);
XCTAssertEqual
(
descriptor
.
containingMessageClass
,
msgClass
);
// ptr equality
XCTAssertFalse
(
descriptor
.
isPackable
);
XCTAssertEqual
(
descriptor
.
defaultValue
,
@2
);
XCTAssertEqualObjects
(
descriptor
.
enumDescriptor
.
name
,
@"TestAllTypes_NestedEnum"
);
// Message
descriptor
=
[
UnittestRoot
optionalNestedMessageExtension
];
XCTAssertNotNil
(
descriptor
);
XCTAssertEqual
(
descriptor
.
containingMessageClass
,
msgClass
);
// ptr equality
XCTAssertFalse
(
descriptor
.
isPackable
);
XCTAssertNil
(
descriptor
.
defaultValue
);
XCTAssertNil
(
descriptor
.
enumDescriptor
);
// Repeated Int
descriptor
=
[
UnittestRoot
repeatedInt32Extension
];
XCTAssertNotNil
(
descriptor
);
XCTAssertEqual
(
descriptor
.
containingMessageClass
,
msgClass
);
// ptr equality
XCTAssertFalse
(
descriptor
.
isPackable
);
XCTAssertNil
(
descriptor
.
defaultValue
);
XCTAssertNil
(
descriptor
.
enumDescriptor
);
descriptor
=
[
UnittestRoot
packedInt32Extension
];
XCTAssertNotNil
(
descriptor
);
XCTAssertEqual
(
descriptor
.
containingMessageClass
,
packedMsgClass
);
// ptr equality
XCTAssertTrue
(
descriptor
.
isPackable
);
XCTAssertNil
(
descriptor
.
defaultValue
);
XCTAssertNil
(
descriptor
.
enumDescriptor
);
// Repeated Enum
descriptor
=
[
UnittestRoot
repeatedNestedEnumExtension
];
XCTAssertNotNil
(
descriptor
);
XCTAssertEqual
(
descriptor
.
containingMessageClass
,
msgClass
);
// ptr equality
XCTAssertFalse
(
descriptor
.
isPackable
);
XCTAssertNil
(
descriptor
.
defaultValue
);
XCTAssertEqualObjects
(
descriptor
.
enumDescriptor
.
name
,
@"TestAllTypes_NestedEnum"
);
descriptor
=
[
UnittestRoot
packedEnumExtension
];
XCTAssertNotNil
(
descriptor
);
XCTAssertEqual
(
descriptor
.
containingMessageClass
,
packedMsgClass
);
// ptr equality
XCTAssertTrue
(
descriptor
.
isPackable
);
XCTAssertNil
(
descriptor
.
defaultValue
);
XCTAssertEqualObjects
(
descriptor
.
enumDescriptor
.
name
,
@"ForeignEnum"
);
// Repeated Message
descriptor
=
[
UnittestRoot
repeatedNestedMessageExtension
];
XCTAssertNotNil
(
descriptor
);
XCTAssertEqual
(
descriptor
.
containingMessageClass
,
msgClass
);
// ptr equality
XCTAssertFalse
(
descriptor
.
isPackable
);
XCTAssertNil
(
descriptor
.
defaultValue
);
XCTAssertNil
(
descriptor
.
enumDescriptor
);
// Compare (used internally for serialization).
GPBExtensionDescriptor
*
ext1
=
[
UnittestRoot
optionalInt32Extension
];
XCTAssertEqual
(
ext1
.
fieldNumber
,
1u
);
GPBExtensionDescriptor
*
ext2
=
[
UnittestRoot
optionalInt64Extension
];
XCTAssertEqual
(
ext2
.
fieldNumber
,
2u
);
XCTAssertEqual
([
ext1
compareByFieldNumber
:
ext2
],
NSOrderedAscending
);
XCTAssertEqual
([
ext2
compareByFieldNumber
:
ext1
],
NSOrderedDescending
);
XCTAssertEqual
([
ext1
compareByFieldNumber
:
ext1
],
NSOrderedSame
);
}
@end
objectivec/Tests/GPBUnknownFieldSetTest.m
View file @
a274c67c
This diff is collapsed.
Click to expand it.
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