Commit d6c32a81 authored by Thomas Van Lenten's avatar Thomas Van Lenten Committed by GitHub

Merge pull request #3714 from thomasvl/objc_increase_test_coverage

Objc increase test coverage
parents 4207066c a274c67c
...@@ -1027,10 +1027,6 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) { ...@@ -1027,10 +1027,6 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
return GPBExtensionIsRepeated(description_); return GPBExtensionIsRepeated(description_);
} }
- (BOOL)isMap {
return (description_->options & GPBFieldMapKeyMask) != 0;
}
- (BOOL)isPackable { - (BOOL)isPackable {
return GPBExtensionIsPacked(description_); return GPBExtensionIsPacked(description_);
} }
......
...@@ -97,6 +97,7 @@ ...@@ -97,6 +97,7 @@
if (self == object) return YES; if (self == object) return YES;
if (![object isKindOfClass:[GPBUnknownField class]]) return NO; if (![object isKindOfClass:[GPBUnknownField class]]) return NO;
GPBUnknownField *field = (GPBUnknownField *)object; GPBUnknownField *field = (GPBUnknownField *)object;
if (number_ != field->number_) return NO;
BOOL equalVarint = BOOL equalVarint =
(mutableVarintList_.count == 0 && field->mutableVarintList_.count == 0) || (mutableVarintList_.count == 0 && field->mutableVarintList_.count == 0) ||
[mutableVarintList_ isEqual:field->mutableVarintList_]; [mutableVarintList_ isEqual:field->mutableVarintList_];
...@@ -202,8 +203,9 @@ ...@@ -202,8 +203,9 @@
} }
- (NSString *)description { - (NSString *)description {
NSMutableString *description = [NSMutableString NSMutableString *description =
stringWithFormat:@"<%@ %p>: Field: %d {\n", [self class], self, number_]; [NSMutableString stringWithFormat:@"<%@ %p>: Field: %d {\n",
[self class], self, number_];
[mutableVarintList_ [mutableVarintList_
enumerateValuesWithBlock:^(uint64_t value, NSUInteger idx, BOOL *stop) { enumerateValuesWithBlock:^(uint64_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop) #pragma unused(idx, stop)
......
...@@ -562,7 +562,7 @@ ...@@ -562,7 +562,7 @@
attributes = { attributes = {
LastSwiftUpdateCheck = 0710; LastSwiftUpdateCheck = 0710;
LastTestingUpgradeCheck = 0600; LastTestingUpgradeCheck = 0600;
LastUpgradeCheck = 0800; LastUpgradeCheck = 0900;
TargetAttributes = { TargetAttributes = {
8BBEA4A5147C727100C4ADB7 = { 8BBEA4A5147C727100C4ADB7 = {
LastSwiftMigration = 0800; LastSwiftMigration = 0800;
...@@ -794,6 +794,8 @@ ...@@ -794,6 +794,8 @@
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES; CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES;
CLANG_STATIC_ANALYZER_MODE = deep; CLANG_STATIC_ANALYZER_MODE = deep;
CLANG_WARN_ASSIGN_ENUM = YES; CLANG_WARN_ASSIGN_ENUM = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_EMPTY_BODY = YES;
...@@ -803,6 +805,8 @@ ...@@ -803,6 +805,8 @@
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES; CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES; CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE; CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE;
...@@ -860,6 +864,8 @@ ...@@ -860,6 +864,8 @@
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES; CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES;
CLANG_STATIC_ANALYZER_MODE = deep; CLANG_STATIC_ANALYZER_MODE = deep;
CLANG_WARN_ASSIGN_ENUM = YES; CLANG_WARN_ASSIGN_ENUM = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_EMPTY_BODY = YES;
...@@ -869,6 +875,8 @@ ...@@ -869,6 +875,8 @@
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES; CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES; CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE; CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE;
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Scheme <Scheme
LastUpgradeVersion = "0800" LastUpgradeVersion = "0900"
version = "1.3"> version = "1.3">
<BuildAction <BuildAction
parallelizeBuildables = "YES" parallelizeBuildables = "YES"
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
buildConfiguration = "Release" buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES"> shouldUseLaunchSchemeArgsEnv = "YES">
<Testables> <Testables>
<TestableReference <TestableReference
...@@ -300,6 +301,7 @@ ...@@ -300,6 +301,7 @@
buildConfiguration = "Release" buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0" launchStyle = "0"
useCustomWorkingDirectory = "NO" useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO" ignoresPersistentStateOnLaunch = "NO"
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Scheme <Scheme
LastUpgradeVersion = "0800" LastUpgradeVersion = "0900"
version = "1.3"> version = "1.3">
<BuildAction <BuildAction
parallelizeBuildables = "YES" parallelizeBuildables = "YES"
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
buildConfiguration = "Debug" buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES" shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES"> codeCoverageEnabled = "YES">
<Testables> <Testables>
...@@ -89,6 +90,7 @@ ...@@ -89,6 +90,7 @@
buildConfiguration = "Debug" buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0" launchStyle = "0"
useCustomWorkingDirectory = "NO" useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO" ignoresPersistentStateOnLaunch = "NO"
......
...@@ -639,7 +639,7 @@ ...@@ -639,7 +639,7 @@
attributes = { attributes = {
LastSwiftUpdateCheck = 0710; LastSwiftUpdateCheck = 0710;
LastTestingUpgradeCheck = 0600; LastTestingUpgradeCheck = 0600;
LastUpgradeCheck = 0800; LastUpgradeCheck = 0900;
TargetAttributes = { TargetAttributes = {
8BBEA4A5147C727100C4ADB7 = { 8BBEA4A5147C727100C4ADB7 = {
LastSwiftMigration = 0800; LastSwiftMigration = 0800;
...@@ -956,6 +956,8 @@ ...@@ -956,6 +956,8 @@
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES; CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES;
CLANG_STATIC_ANALYZER_MODE = deep; CLANG_STATIC_ANALYZER_MODE = deep;
CLANG_WARN_ASSIGN_ENUM = YES; CLANG_WARN_ASSIGN_ENUM = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_EMPTY_BODY = YES;
...@@ -965,6 +967,8 @@ ...@@ -965,6 +967,8 @@
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES; CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES; CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE; CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE;
...@@ -1023,6 +1027,8 @@ ...@@ -1023,6 +1027,8 @@
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES; CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES;
CLANG_STATIC_ANALYZER_MODE = deep; CLANG_STATIC_ANALYZER_MODE = deep;
CLANG_WARN_ASSIGN_ENUM = YES; CLANG_WARN_ASSIGN_ENUM = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_EMPTY_BODY = YES;
...@@ -1032,6 +1038,8 @@ ...@@ -1032,6 +1038,8 @@
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES; CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES; CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE; CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE;
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Scheme <Scheme
LastUpgradeVersion = "0800" LastUpgradeVersion = "0900"
version = "1.3"> version = "1.3">
<BuildAction <BuildAction
parallelizeBuildables = "YES" parallelizeBuildables = "YES"
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
buildConfiguration = "Release" buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES"> shouldUseLaunchSchemeArgsEnv = "YES">
<Testables> <Testables>
<TestableReference <TestableReference
...@@ -309,6 +310,7 @@ ...@@ -309,6 +310,7 @@
buildConfiguration = "Release" buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0" launchStyle = "0"
useCustomWorkingDirectory = "NO" useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO" ignoresPersistentStateOnLaunch = "NO"
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Scheme <Scheme
LastUpgradeVersion = "0800" LastUpgradeVersion = "0900"
version = "1.3"> version = "1.3">
<BuildAction <BuildAction
parallelizeBuildables = "YES" parallelizeBuildables = "YES"
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
buildConfiguration = "Debug" buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES" shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES"> codeCoverageEnabled = "YES">
<Testables> <Testables>
...@@ -89,6 +90,7 @@ ...@@ -89,6 +90,7 @@
buildConfiguration = "Debug" buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0" launchStyle = "0"
useCustomWorkingDirectory = "NO" useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO" ignoresPersistentStateOnLaunch = "NO"
......
This diff is collapsed.
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#import <objc/runtime.h> #import <objc/runtime.h>
#import "GPBDescriptor.h" #import "GPBDescriptor_PackagePrivate.h"
#import "google/protobuf/Unittest.pbobjc.h" #import "google/protobuf/Unittest.pbobjc.h"
#import "google/protobuf/UnittestObjc.pbobjc.h" #import "google/protobuf/UnittestObjc.pbobjc.h"
#import "google/protobuf/Descriptor.pbobjc.h" #import "google/protobuf/Descriptor.pbobjc.h"
...@@ -83,6 +83,8 @@ ...@@ -83,6 +83,8 @@
XCTAssertNotNil(fieldDescriptorWithNumber.enumDescriptor); XCTAssertNotNil(fieldDescriptorWithNumber.enumDescriptor);
XCTAssertEqualObjects(fieldDescriptorWithNumber.enumDescriptor.name, XCTAssertEqualObjects(fieldDescriptorWithNumber.enumDescriptor.name,
@"TestAllTypes_NestedEnum"); @"TestAllTypes_NestedEnum");
XCTAssertEqual(fieldDescriptorWithName.number, fieldDescriptorWithNumber.number);
XCTAssertEqual(fieldDescriptorWithName.dataType, GPBDataTypeEnum);
// Foreign Enum // Foreign Enum
fieldDescriptorWithName = [descriptor fieldWithName:@"optionalForeignEnum"]; fieldDescriptorWithName = [descriptor fieldWithName:@"optionalForeignEnum"];
...@@ -93,6 +95,8 @@ ...@@ -93,6 +95,8 @@
XCTAssertNotNil(fieldDescriptorWithNumber.enumDescriptor); XCTAssertNotNil(fieldDescriptorWithNumber.enumDescriptor);
XCTAssertEqualObjects(fieldDescriptorWithNumber.enumDescriptor.name, XCTAssertEqualObjects(fieldDescriptorWithNumber.enumDescriptor.name,
@"ForeignEnum"); @"ForeignEnum");
XCTAssertEqual(fieldDescriptorWithName.number, fieldDescriptorWithNumber.number);
XCTAssertEqual(fieldDescriptorWithName.dataType, GPBDataTypeEnum);
// Import Enum // Import Enum
fieldDescriptorWithName = [descriptor fieldWithName:@"optionalImportEnum"]; fieldDescriptorWithName = [descriptor fieldWithName:@"optionalImportEnum"];
...@@ -103,6 +107,8 @@ ...@@ -103,6 +107,8 @@
XCTAssertNotNil(fieldDescriptorWithNumber.enumDescriptor); XCTAssertNotNil(fieldDescriptorWithNumber.enumDescriptor);
XCTAssertEqualObjects(fieldDescriptorWithNumber.enumDescriptor.name, XCTAssertEqualObjects(fieldDescriptorWithNumber.enumDescriptor.name,
@"ImportEnum"); @"ImportEnum");
XCTAssertEqual(fieldDescriptorWithName.number, fieldDescriptorWithNumber.number);
XCTAssertEqual(fieldDescriptorWithName.dataType, GPBDataTypeEnum);
// Nested Message // Nested Message
fieldDescriptorWithName = [descriptor fieldWithName:@"optionalNestedMessage"]; fieldDescriptorWithName = [descriptor fieldWithName:@"optionalNestedMessage"];
...@@ -111,6 +117,8 @@ ...@@ -111,6 +117,8 @@
XCTAssertNotNil(fieldDescriptorWithNumber); XCTAssertNotNil(fieldDescriptorWithNumber);
XCTAssertEqual(fieldDescriptorWithName, fieldDescriptorWithNumber); XCTAssertEqual(fieldDescriptorWithName, fieldDescriptorWithNumber);
XCTAssertNil(fieldDescriptorWithNumber.enumDescriptor); XCTAssertNil(fieldDescriptorWithNumber.enumDescriptor);
XCTAssertEqual(fieldDescriptorWithName.number, fieldDescriptorWithNumber.number);
XCTAssertEqual(fieldDescriptorWithName.dataType, GPBDataTypeMessage);
// Foreign Message // Foreign Message
fieldDescriptorWithName = fieldDescriptorWithName =
...@@ -120,6 +128,8 @@ ...@@ -120,6 +128,8 @@
XCTAssertNotNil(fieldDescriptorWithNumber); XCTAssertNotNil(fieldDescriptorWithNumber);
XCTAssertEqual(fieldDescriptorWithName, fieldDescriptorWithNumber); XCTAssertEqual(fieldDescriptorWithName, fieldDescriptorWithNumber);
XCTAssertNil(fieldDescriptorWithNumber.enumDescriptor); XCTAssertNil(fieldDescriptorWithNumber.enumDescriptor);
XCTAssertEqual(fieldDescriptorWithName.number, fieldDescriptorWithNumber.number);
XCTAssertEqual(fieldDescriptorWithName.dataType, GPBDataTypeMessage);
// Import Message // Import Message
fieldDescriptorWithName = [descriptor fieldWithName:@"optionalImportMessage"]; fieldDescriptorWithName = [descriptor fieldWithName:@"optionalImportMessage"];
...@@ -128,6 +138,12 @@ ...@@ -128,6 +138,12 @@
XCTAssertNotNil(fieldDescriptorWithNumber); XCTAssertNotNil(fieldDescriptorWithNumber);
XCTAssertEqual(fieldDescriptorWithName, fieldDescriptorWithNumber); XCTAssertEqual(fieldDescriptorWithName, fieldDescriptorWithNumber);
XCTAssertNil(fieldDescriptorWithNumber.enumDescriptor); 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 { - (void)testEnumDescriptor {
...@@ -159,6 +175,7 @@ ...@@ -159,6 +175,7 @@
XCTAssertNotNil(enumName); XCTAssertNotNil(enumName);
XCTAssertTrue([descriptor getValue:&value forEnumTextFormatName:@"FOO"]); XCTAssertTrue([descriptor getValue:&value forEnumTextFormatName:@"FOO"]);
XCTAssertEqual(value, TestAllTypes_NestedEnum_Foo); XCTAssertEqual(value, TestAllTypes_NestedEnum_Foo);
XCTAssertNil([descriptor textFormatNameForValue:99999]);
// Bad values // Bad values
enumName = [descriptor enumNameForValue:0]; enumName = [descriptor enumNameForValue:0];
...@@ -253,4 +270,102 @@ ...@@ -253,4 +270,102 @@
XCTAssertNil(bazString.containingOneof); 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 @end
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment