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
4d875278
Commit
4d875278
authored
Oct 03, 2016
by
Thomas Van Lenten
Committed by
GitHub
Oct 03, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2218 from thomasvl/xcode8_updates
Update the ObjC projects for Xcode 8
parents
350d4944
297449aa
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
205 additions
and
175 deletions
+205
-175
.travis.yml
.travis.yml
+1
-1
full_mac_build.sh
objectivec/DevTools/full_mac_build.sh
+25
-23
project.pbxproj
objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj
+15
-1
PerformanceTests.xcscheme
...codeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme
+1
-1
ProtocolBuffers.xcscheme
...xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme
+1
-1
project.pbxproj
objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj
+21
-7
PerformanceTests.xcscheme
...codeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme
+1
-1
ProtocolBuffers.xcscheme
...xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme
+1
-1
GPBSwiftTests.swift
objectivec/Tests/GPBSwiftTests.swift
+139
-139
No files found.
.travis.yml
View file @
4d875278
...
...
@@ -8,7 +8,7 @@ language: cpp
os
:
-
osx
# The Objective C build needs Xcode 7.0 or later.
osx_image
:
xcode
7.3
osx_image
:
xcode
8
script
:
-
./tests.sh $CONFIG
env
:
...
...
objectivec/DevTools/full_mac_build.sh
View file @
4d875278
...
...
@@ -228,34 +228,23 @@ if [[ "${DO_XCODE_IOS_TESTS}" == "yes" ]] ; then
# NOTE: Different Xcode have different simulated hardware/os support.
readonly
XCODE_VERSION_LINE
=
"
$(
xcodebuild
-version
|
grep
Xcode
\
)
"
readonly
XCODE_VERSION
=
"
${
XCODE_VERSION_LINE
/Xcode /
}
"
# drop the prefix.
IOS_SIMULATOR_NAME
=
"Simulator"
case
"
${
XCODE_VERSION
}
"
in
6.
*
)
echo
"ERROR: Xcode 6.3/6.4 no longer supported for building, please use
7
.0 or higher."
1>&2
echo
"ERROR: Xcode 6.3/6.4 no longer supported for building, please use
8
.0 or higher."
1>&2
exit
10
;;
7.1
*
)
XCODEBUILD_TEST_BASE_IOS+
=(
-destination
"platform=iOS Simulator,name=iPhone 4s,OS=8.1"
# 32bit
-destination
"platform=iOS Simulator,name=iPhone 6,OS=9.0"
# 64bit
-destination
"platform=iOS Simulator,name=iPad 2,OS=8.1"
# 32bit
-destination
"platform=iOS Simulator,name=iPad Air,OS=9.0"
# 64bit
)
7.
*
)
echo
"ERROR: The unittests include Swift code that is now Swift 3.0."
1>&2
echo
"ERROR: Xcode 8.0 or higher is required to build the test suite, but the library works with Xcode 7.x."
1>&2
exit
11
;;
7.2
*
)
8.0
*
)
# The 8.* device seem to hang and never start under Xcode 8.
XCODEBUILD_TEST_BASE_IOS+
=(
-destination
"platform=iOS Simulator,name=iPhone 4s,OS=8.1"
# 32bit
-destination
"platform=iOS Simulator,name=iPhone 6,OS=9.2"
# 64bit
-destination
"platform=iOS Simulator,name=iPad 2,OS=8.1"
# 32bit
-destination
"platform=iOS Simulator,name=iPad Air,OS=9.2"
# 64bit
)
;;
7.3
*
)
XCODEBUILD_TEST_BASE_IOS+
=(
-destination
"platform=iOS Simulator,name=iPhone 4s,OS=8.1"
# 32bit
-destination
"platform=iOS Simulator,name=iPhone 6,OS=9.3"
# 64bit
-destination
"platform=iOS Simulator,name=iPad 2,OS=8.1"
# 32bit
-destination
"platform=iOS Simulator,name=iPad Air,OS=9.3"
# 64bit
-destination
"platform=iOS Simulator,name=iPhone 4s,OS=9.0"
# 32bit
-destination
"platform=iOS Simulator,name=iPhone 7,OS=10.0"
# 64bit
-destination
"platform=iOS Simulator,name=iPad 2,OS=9.0"
# 32bit
-destination
"platform=iOS Simulator,name=iPad Pro (9.7 inch),OS=10.0"
# 64bit
)
;;
*
)
...
...
@@ -272,7 +261,7 @@ if [[ "${DO_XCODE_IOS_TESTS}" == "yes" ]] ; then
"
${
XCODEBUILD_TEST_BASE_IOS
[@]
}
"
-configuration
Release
test
fi
# Don't leave the simulator in the developer's face.
killall
"
${
IOS_SIMULATOR_NAME
}
"
killall
Simulator
fi
if
[[
"
${
DO_XCODE_OSX_TESTS
}
"
==
"yes"
]]
;
then
XCODEBUILD_TEST_BASE_OSX
=(
...
...
@@ -282,6 +271,19 @@ if [[ "${DO_XCODE_OSX_TESTS}" == "yes" ]] ; then
# Since the ObjC 2.0 Runtime is required, 32bit OS X isn't supported.
-destination
"platform=OS X,arch=x86_64"
# 64bit
)
readonly
XCODE_VERSION_LINE
=
"
$(
xcodebuild
-version
|
grep
Xcode
\
)
"
readonly
XCODE_VERSION
=
"
${
XCODE_VERSION_LINE
/Xcode /
}
"
# drop the prefix.
case
"
${
XCODE_VERSION
}
"
in
6.
*
)
echo
"ERROR: Xcode 6.3/6.4 no longer supported for building, please use 8.0 or higher."
1>&2
exit
10
;;
7.
*
)
echo
"ERROR: The unittests include Swift code that is now Swift 3.0."
1>&2
echo
"ERROR: Xcode 8.0 or higher is required to build the test suite, but the library works with Xcode 7.x."
1>&2
exit
11
;;
esac
if
[[
"
${
DO_XCODE_DEBUG
}
"
==
"yes"
]]
;
then
header
"Doing Xcode OS X build/tests - Debug"
"
${
XCODEBUILD_TEST_BASE_OSX
[@]
}
"
-configuration
Debug
test
...
...
objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj
View file @
4d875278
...
...
@@ -556,9 +556,10 @@
attributes
=
{
LastSwiftUpdateCheck
=
0710
;
LastTestingUpgradeCheck
=
0600
;
LastUpgradeCheck
=
0
71
0
;
LastUpgradeCheck
=
0
80
0
;
TargetAttributes
=
{
8BBEA4A5147C727100C4ADB7
=
{
LastSwiftMigration
=
0800
;
TestTargetID
=
8B9A5EA41831993600A9D33B
;
};
F45BBC141B0CE3C6002D064D
=
{
...
...
@@ -740,6 +741,7 @@
PRODUCT_NAME
=
UnitTests
;
SWIFT_OBJC_BRIDGING_HEADER
=
"Tests/UnitTests-Bridging-Header.h"
;
SWIFT_OPTIMIZATION_LEVEL
=
"-Onone"
;
SWIFT_VERSION
=
3.0
;
WARNING_CFLAGS
=
(
"$(inherited)"
,
"-Wno-documentation-unknown-command"
,
...
...
@@ -764,6 +766,7 @@
PRODUCT_BUNDLE_IDENTIFIER
=
"com.yourcompany.${PRODUCT_NAME:identifier}"
;
PRODUCT_NAME
=
UnitTests
;
SWIFT_OBJC_BRIDGING_HEADER
=
"Tests/UnitTests-Bridging-Header.h"
;
SWIFT_VERSION
=
3.0
;
WARNING_CFLAGS
=
(
"$(inherited)"
,
"-Wno-documentation-unknown-command"
,
...
...
@@ -785,16 +788,21 @@
CLANG_WARN_ASSIGN_ENUM
=
YES
;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS
=
YES
;
CLANG_WARN_DOCUMENTATION_COMMENTS
=
YES
;
CLANG_WARN_EMPTY_BODY
=
YES
;
CLANG_WARN_INFINITE_RECURSION
=
YES
;
CLANG_WARN_NULLABLE_TO_NONNULL_CONVERSION
=
YES
;
CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE
=
YES
;
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES
=
YES
;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF
=
YES
;
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS
=
YES
;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION
=
YES
;
CLANG_WARN_SUSPICIOUS_MOVE
=
YES
;
CLANG_WARN_UNREACHABLE_CODE
=
YES_AGGRESSIVE
;
CLANG_WARN__DUPLICATE_METHOD_MATCH
=
YES
;
ENABLE_STRICT_OBJC_MSGSEND
=
YES
;
ENABLE_TESTABILITY
=
YES
;
GCC_C_LANGUAGE_STANDARD
=
c99
;
GCC_NO_COMMON_BLOCKS
=
YES
;
GCC_OPTIMIZATION_LEVEL
=
0
;
GCC_PREPROCESSOR_DEFINITIONS
=
"DEBUG=1"
;
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS
=
YES
;
...
...
@@ -846,16 +854,21 @@
CLANG_WARN_ASSIGN_ENUM
=
YES
;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS
=
YES
;
CLANG_WARN_DOCUMENTATION_COMMENTS
=
YES
;
CLANG_WARN_EMPTY_BODY
=
YES
;
CLANG_WARN_INFINITE_RECURSION
=
YES
;
CLANG_WARN_NULLABLE_TO_NONNULL_CONVERSION
=
YES
;
CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE
=
YES
;
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES
=
YES
;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF
=
YES
;
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS
=
YES
;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION
=
YES
;
CLANG_WARN_SUSPICIOUS_MOVE
=
YES
;
CLANG_WARN_UNREACHABLE_CODE
=
YES_AGGRESSIVE
;
CLANG_WARN__DUPLICATE_METHOD_MATCH
=
YES
;
ENABLE_NS_ASSERTIONS
=
NO
;
ENABLE_STRICT_OBJC_MSGSEND
=
YES
;
GCC_C_LANGUAGE_STANDARD
=
c99
;
GCC_NO_COMMON_BLOCKS
=
YES
;
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS
=
YES
;
GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS
=
YES
;
GCC_TREAT_WARNINGS_AS_ERRORS
=
YES
;
...
...
@@ -881,6 +894,7 @@
MACOSX_DEPLOYMENT_TARGET
=
10.9
;
RUN_CLANG_STATIC_ANALYZER
=
YES
;
SDKROOT
=
macosx
;
SWIFT_OPTIMIZATION_LEVEL
=
"-Owholemodule"
;
WARNING_CFLAGS
=
(
"-Wdocumentation-unknown-command"
,
"-Wundef"
,
...
...
objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme
View file @
4d875278
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion =
"0
71
0"
LastUpgradeVersion =
"0
80
0"
version =
"1.3"
>
<BuildAction
parallelizeBuildables =
"YES"
...
...
objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme
View file @
4d875278
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion =
"0
71
0"
LastUpgradeVersion =
"0
80
0"
version =
"1.3"
>
<BuildAction
parallelizeBuildables =
"YES"
...
...
objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj
View file @
4d875278
...
...
@@ -633,9 +633,10 @@
attributes
=
{
LastSwiftUpdateCheck
=
0710
;
LastTestingUpgradeCheck
=
0600
;
LastUpgradeCheck
=
0
71
0
;
LastUpgradeCheck
=
0
80
0
;
TargetAttributes
=
{
8BBEA4A5147C727100C4ADB7
=
{
LastSwiftMigration
=
0800
;
TestTargetID
=
8B9A5EA41831993600A9D33B
;
};
F45BBC0E1B0CDB50002D064D
=
{
...
...
@@ -843,7 +844,7 @@
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME
=
LaunchImage
;
CLANG_ENABLE_OBJC_ARC
=
YES
;
INFOPLIST_FILE
=
"$(SRCROOT)/Tests/iOSTestHarness/Info.plist"
;
IPHONEOS_DEPLOYMENT_TARGET
=
7.1
;
IPHONEOS_DEPLOYMENT_TARGET
=
8.0
;
PRODUCT_BUNDLE_IDENTIFIER
=
"com.google.${PRODUCT_NAME:rfc1034identifier}"
;
PRODUCT_NAME
=
"$(TARGET_NAME)"
;
TARGETED_DEVICE_FAMILY
=
"1,2"
;
...
...
@@ -858,7 +859,7 @@
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME
=
LaunchImage
;
CLANG_ENABLE_OBJC_ARC
=
YES
;
INFOPLIST_FILE
=
"$(SRCROOT)/Tests/iOSTestHarness/Info.plist"
;
IPHONEOS_DEPLOYMENT_TARGET
=
7.1
;
IPHONEOS_DEPLOYMENT_TARGET
=
8.0
;
PRODUCT_BUNDLE_IDENTIFIER
=
"com.google.${PRODUCT_NAME:rfc1034identifier}"
;
PRODUCT_NAME
=
"$(TARGET_NAME)"
;
TARGETED_DEVICE_FAMILY
=
"1,2"
;
...
...
@@ -880,7 +881,7 @@
"$(SRCROOT)"
,
);
INFOPLIST_FILE
=
"Tests/UnitTests-Info.plist"
;
IPHONEOS_DEPLOYMENT_TARGET
=
7.1
;
IPHONEOS_DEPLOYMENT_TARGET
=
8.0
;
LD_RUNPATH_SEARCH_PATHS
=
"$(inherited) @executable_path/Frameworks @loader_path/Frameworks"
;
LIBRARY_SEARCH_PATHS
=
(
"$(inherited)"
,
...
...
@@ -890,6 +891,7 @@
PRODUCT_NAME
=
UnitTests
;
SWIFT_OBJC_BRIDGING_HEADER
=
"Tests/UnitTests-Bridging-Header.h"
;
SWIFT_OPTIMIZATION_LEVEL
=
"-Onone"
;
SWIFT_VERSION
=
3.0
;
TARGETED_DEVICE_FAMILY
=
"1,2"
;
TEST_HOST
=
"$(BUILT_PRODUCTS_DIR)/iOSTestHarness.app/iOSTestHarness"
;
WARNING_CFLAGS
=
(
...
...
@@ -915,7 +917,7 @@
"$(SRCROOT)"
,
);
INFOPLIST_FILE
=
"Tests/UnitTests-Info.plist"
;
IPHONEOS_DEPLOYMENT_TARGET
=
7.1
;
IPHONEOS_DEPLOYMENT_TARGET
=
8.0
;
LD_RUNPATH_SEARCH_PATHS
=
"$(inherited) @executable_path/Frameworks @loader_path/Frameworks"
;
LIBRARY_SEARCH_PATHS
=
(
"$(inherited)"
,
...
...
@@ -924,6 +926,7 @@
OTHER_LDFLAGS
=
"-ObjC"
;
PRODUCT_NAME
=
UnitTests
;
SWIFT_OBJC_BRIDGING_HEADER
=
"Tests/UnitTests-Bridging-Header.h"
;
SWIFT_VERSION
=
3.0
;
TARGETED_DEVICE_FAMILY
=
"1,2"
;
TEST_HOST
=
"$(BUILT_PRODUCTS_DIR)/iOSTestHarness.app/iOSTestHarness"
;
WARNING_CFLAGS
=
(
...
...
@@ -947,17 +950,22 @@
CLANG_WARN_ASSIGN_ENUM
=
YES
;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS
=
YES
;
CLANG_WARN_DOCUMENTATION_COMMENTS
=
YES
;
CLANG_WARN_EMPTY_BODY
=
YES
;
CLANG_WARN_INFINITE_RECURSION
=
YES
;
CLANG_WARN_NULLABLE_TO_NONNULL_CONVERSION
=
YES
;
CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE
=
YES
;
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES
=
YES
;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF
=
YES
;
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS
=
YES
;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION
=
YES
;
CLANG_WARN_SUSPICIOUS_MOVE
=
YES
;
CLANG_WARN_UNREACHABLE_CODE
=
YES_AGGRESSIVE
;
CLANG_WARN__DUPLICATE_METHOD_MATCH
=
YES
;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]"
=
"iPhone Developer"
;
ENABLE_STRICT_OBJC_MSGSEND
=
YES
;
ENABLE_TESTABILITY
=
YES
;
GCC_C_LANGUAGE_STANDARD
=
c99
;
GCC_NO_COMMON_BLOCKS
=
YES
;
GCC_OPTIMIZATION_LEVEL
=
0
;
GCC_PREPROCESSOR_DEFINITIONS
=
"DEBUG=1"
;
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS
=
YES
;
...
...
@@ -982,7 +990,7 @@
GCC_WARN_UNUSED_PARAMETER
=
YES
;
GCC_WARN_UNUSED_VARIABLE
=
YES
;
GENERATE_PROFILING_CODE
=
NO
;
IPHONEOS_DEPLOYMENT_TARGET
=
6.1
;
IPHONEOS_DEPLOYMENT_TARGET
=
8.0
;
ONLY_ACTIVE_ARCH
=
YES
;
RUN_CLANG_STATIC_ANALYZER
=
YES
;
SDKROOT
=
iphoneos
;
...
...
@@ -1009,17 +1017,22 @@
CLANG_WARN_ASSIGN_ENUM
=
YES
;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS
=
YES
;
CLANG_WARN_DOCUMENTATION_COMMENTS
=
YES
;
CLANG_WARN_EMPTY_BODY
=
YES
;
CLANG_WARN_INFINITE_RECURSION
=
YES
;
CLANG_WARN_NULLABLE_TO_NONNULL_CONVERSION
=
YES
;
CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE
=
YES
;
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES
=
YES
;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF
=
YES
;
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS
=
YES
;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION
=
YES
;
CLANG_WARN_SUSPICIOUS_MOVE
=
YES
;
CLANG_WARN_UNREACHABLE_CODE
=
YES_AGGRESSIVE
;
CLANG_WARN__DUPLICATE_METHOD_MATCH
=
YES
;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]"
=
"iPhone Developer"
;
ENABLE_NS_ASSERTIONS
=
NO
;
ENABLE_STRICT_OBJC_MSGSEND
=
YES
;
GCC_C_LANGUAGE_STANDARD
=
c99
;
GCC_NO_COMMON_BLOCKS
=
YES
;
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS
=
YES
;
GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS
=
YES
;
GCC_TREAT_WARNINGS_AS_ERRORS
=
YES
;
...
...
@@ -1042,9 +1055,10 @@
GCC_WARN_UNUSED_PARAMETER
=
YES
;
GCC_WARN_UNUSED_VARIABLE
=
YES
;
GENERATE_PROFILING_CODE
=
NO
;
IPHONEOS_DEPLOYMENT_TARGET
=
6.1
;
IPHONEOS_DEPLOYMENT_TARGET
=
8.0
;
RUN_CLANG_STATIC_ANALYZER
=
YES
;
SDKROOT
=
iphoneos
;
SWIFT_OPTIMIZATION_LEVEL
=
"-Owholemodule"
;
WARNING_CFLAGS
=
(
"-Wdocumentation-unknown-command"
,
"-Wundef"
,
...
...
objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme
View file @
4d875278
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion =
"0
71
0"
LastUpgradeVersion =
"0
80
0"
version =
"1.3"
>
<BuildAction
parallelizeBuildables =
"YES"
...
...
objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme
View file @
4d875278
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion =
"0
71
0"
LastUpgradeVersion =
"0
80
0"
version =
"1.3"
>
<BuildAction
parallelizeBuildables =
"YES"
...
...
objectivec/Tests/GPBSwiftTests.swift
View file @
4d875278
...
...
@@ -42,23 +42,23 @@ class GPBBridgeTests: XCTestCase {
msg
.
optionalInt32
=
100
msg
.
optionalString
=
"abc"
msg
.
optionalEnum
=
.
B
ar
msg
.
optionalEnum
=
.
b
ar
msg2
.
optionalString
=
"other"
msg
.
optional
Message
=
msg2
msg
.
optional
=
msg2
msg3
.
a
=
200
msg
.
optionalGroup
=
msg3
msg
.
repeatedInt32Array
.
addValue
(
300
)
msg
.
repeatedInt32Array
.
addValue
(
301
)
msg
.
repeatedStringArray
.
add
Object
(
"mno"
)
msg
.
repeatedStringArray
.
add
Object
(
"pqr"
)
msg
.
repeatedEnumArray
.
addValue
(
Message2_Enum
.
B
ar
.
rawValue
)
msg
.
repeatedEnumArray
.
addValue
(
Message2_Enum
.
B
az
.
rawValue
)
msg
.
repeatedStringArray
.
add
(
"mno"
)
msg
.
repeatedStringArray
.
add
(
"pqr"
)
msg
.
repeatedEnumArray
.
addValue
(
Message2_Enum
.
b
ar
.
rawValue
)
msg
.
repeatedEnumArray
.
addValue
(
Message2_Enum
.
b
az
.
rawValue
)
msg
.
mapInt32Int32
.
setInt32
(
400
,
forKey
:
500
)
msg
.
mapInt32Int32
.
setInt32
(
401
,
forKey
:
501
)
msg
.
mapStringString
.
setObject
(
"foo"
,
forKey
:
"bar"
)
msg
.
mapStringString
.
setObject
(
"abc"
,
forKey
:
"xyz"
)
msg
.
mapInt32Enum
.
setEnum
(
Message2_Enum
.
B
ar
.
rawValue
,
forKey
:
600
)
msg
.
mapInt32Enum
.
setEnum
(
Message2_Enum
.
B
az
.
rawValue
,
forKey
:
601
)
msg
.
mapStringString
.
setObject
(
"foo"
,
forKey
:
"bar"
as
NSString
)
msg
.
mapStringString
.
setObject
(
"abc"
,
forKey
:
"xyz"
as
NSString
)
msg
.
mapInt32Enum
.
setEnum
(
Message2_Enum
.
b
ar
.
rawValue
,
forKey
:
600
)
msg
.
mapInt32Enum
.
setEnum
(
Message2_Enum
.
b
az
.
rawValue
,
forKey
:
601
)
// Check has*.
XCTAssertTrue
(
msg
.
hasOptionalInt32
)
...
...
@@ -75,19 +75,19 @@ class GPBBridgeTests: XCTestCase {
XCTAssertEqual
(
msg
.
optionalInt32
,
Int32
(
100
))
XCTAssertEqual
(
msg
.
optionalString
,
"abc"
)
XCTAssertEqual
(
msg2
.
optionalString
,
"other"
)
XCTAssertTrue
(
msg
.
optional
Message
===
msg2
)
XCTAssertEqual
(
msg
.
optionalEnum
,
Message2_Enum
.
B
ar
)
XCTAssertTrue
(
msg
.
optional
===
msg2
)
XCTAssertEqual
(
msg
.
optionalEnum
,
Message2_Enum
.
b
ar
)
XCTAssertEqual
(
msg3
.
a
,
Int32
(
200
))
XCTAssertTrue
(
msg
.
optionalGroup
===
msg3
)
XCTAssertEqual
(
msg
.
repeatedInt32Array
.
count
,
UInt
(
2
))
XCTAssertEqual
(
msg
.
repeatedInt32Array
.
value
AtIndex
(
0
),
Int32
(
300
))
XCTAssertEqual
(
msg
.
repeatedInt32Array
.
value
AtIndex
(
1
),
Int32
(
301
))
XCTAssertEqual
(
msg
.
repeatedInt32Array
.
value
(
at
:
0
),
Int32
(
300
))
XCTAssertEqual
(
msg
.
repeatedInt32Array
.
value
(
at
:
1
),
Int32
(
301
))
XCTAssertEqual
(
msg
.
repeatedStringArray
.
count
,
Int
(
2
))
XCTAssertEqual
(
msg
.
repeatedStringArray
.
object
AtIndex
(
0
)
as?
String
,
"mno"
)
XCTAssertEqual
(
msg
.
repeatedStringArray
.
object
AtIndex
(
1
)
as?
String
,
"pqr"
)
XCTAssertEqual
(
msg
.
repeatedStringArray
.
object
(
at
:
0
)
as?
String
,
"mno"
)
XCTAssertEqual
(
msg
.
repeatedStringArray
.
object
(
at
:
1
)
as?
String
,
"pqr"
)
XCTAssertEqual
(
msg
.
repeatedEnumArray
.
count
,
UInt
(
2
))
XCTAssertEqual
(
msg
.
repeatedEnumArray
.
value
AtIndex
(
0
),
Message2_Enum
.
B
ar
.
rawValue
)
XCTAssertEqual
(
msg
.
repeatedEnumArray
.
value
AtIndex
(
1
),
Message2_Enum
.
B
az
.
rawValue
)
XCTAssertEqual
(
msg
.
repeatedEnumArray
.
value
(
at
:
0
),
Message2_Enum
.
b
ar
.
rawValue
)
XCTAssertEqual
(
msg
.
repeatedEnumArray
.
value
(
at
:
1
),
Message2_Enum
.
b
az
.
rawValue
)
XCTAssertEqual
(
msg
.
repeatedInt64Array
.
count
,
UInt
(
0
))
XCTAssertEqual
(
msg
.
mapInt32Int32
.
count
,
UInt
(
2
))
var
intValue
:
Int32
=
0
...
...
@@ -96,13 +96,13 @@ class GPBBridgeTests: XCTestCase {
XCTAssertTrue
(
msg
.
mapInt32Int32
.
getInt32
(
&
intValue
,
forKey
:
501
))
XCTAssertEqual
(
intValue
,
Int32
(
401
))
XCTAssertEqual
(
msg
.
mapStringString
.
count
,
Int
(
2
))
XCTAssertEqual
(
msg
.
mapStringString
.
object
ForKey
(
"bar"
)
as?
String
,
"foo"
)
XCTAssertEqual
(
msg
.
mapStringString
.
object
ForKey
(
"xyz"
)
as?
String
,
"abc"
)
XCTAssertEqual
(
msg
.
mapStringString
.
object
(
forKey
:
"bar"
)
as?
String
,
"foo"
)
XCTAssertEqual
(
msg
.
mapStringString
.
object
(
forKey
:
"xyz"
)
as?
String
,
"abc"
)
XCTAssertEqual
(
msg
.
mapInt32Enum
.
count
,
UInt
(
2
))
XCTAssertTrue
(
msg
.
mapInt32Enum
.
getEnum
(
&
intValue
,
forKey
:
600
))
XCTAssertEqual
(
intValue
,
Message2_Enum
.
B
ar
.
rawValue
)
XCTAssertEqual
(
intValue
,
Message2_Enum
.
b
ar
.
rawValue
)
XCTAssertTrue
(
msg
.
mapInt32Enum
.
getEnum
(
&
intValue
,
forKey
:
601
))
XCTAssertEqual
(
intValue
,
Message2_Enum
.
B
az
.
rawValue
)
XCTAssertEqual
(
intValue
,
Message2_Enum
.
b
az
.
rawValue
)
// Clearing a string with nil.
msg2
.
optionalString
=
nil
...
...
@@ -124,8 +124,8 @@ class GPBBridgeTests: XCTestCase {
XCTAssertFalse
(
msg
.
hasOptionalFloat
)
XCTAssertEqual
(
msg
.
optionalInt32
,
Int32
(
0
))
XCTAssertEqual
(
msg
.
optionalString
,
""
)
XCTAssertTrue
(
msg
.
optional
Message
!==
msg2
)
// New instance
XCTAssertEqual
(
msg
.
optionalEnum
,
Message2_Enum
.
F
oo
)
// Default
XCTAssertTrue
(
msg
.
optional
!==
msg2
)
// New instance
XCTAssertEqual
(
msg
.
optionalEnum
,
Message2_Enum
.
f
oo
)
// Default
XCTAssertEqual
(
msg
.
repeatedInt32Array
.
count
,
UInt
(
0
))
XCTAssertEqual
(
msg
.
repeatedStringArray
.
count
,
Int
(
0
))
XCTAssertEqual
(
msg
.
repeatedEnumArray
.
count
,
UInt
(
0
))
...
...
@@ -140,22 +140,22 @@ class GPBBridgeTests: XCTestCase {
msg
.
optionalInt32
=
100
msg
.
optionalString
=
"abc"
msg
.
optionalEnum
=
.
B
ar
msg
.
optionalEnum
=
.
b
ar
msg2
.
optionalString
=
"other"
msg
.
optional
Message
=
msg2
msg
.
optional
=
msg2
msg
.
repeatedInt32Array
.
addValue
(
300
)
msg
.
repeatedInt32Array
.
addValue
(
301
)
msg
.
repeatedStringArray
.
add
Object
(
"mno"
)
msg
.
repeatedStringArray
.
add
Object
(
"pqr"
)
msg
.
repeatedStringArray
.
add
(
"mno"
)
msg
.
repeatedStringArray
.
add
(
"pqr"
)
// "proto3" syntax lets enum get unknown values.
msg
.
repeatedEnumArray
.
addValue
(
Message3_Enum
.
B
ar
.
rawValue
)
msg
.
repeatedEnumArray
.
addValue
(
Message3_Enum
.
b
ar
.
rawValue
)
msg
.
repeatedEnumArray
.
addRawValue
(
666
)
SetMessage3_OptionalEnum_RawValue
(
msg2
,
666
)
msg
.
mapInt32Int32
.
setInt32
(
400
,
forKey
:
500
)
msg
.
mapInt32Int32
.
setInt32
(
401
,
forKey
:
501
)
msg
.
mapStringString
.
setObject
(
"foo"
,
forKey
:
"bar"
)
msg
.
mapStringString
.
setObject
(
"abc"
,
forKey
:
"xyz"
)
msg
.
mapInt32Enum
.
setEnum
(
Message2_Enum
.
B
ar
.
rawValue
,
forKey
:
600
)
msg
.
mapStringString
.
setObject
(
"foo"
,
forKey
:
"bar"
as
NSString
)
msg
.
mapStringString
.
setObject
(
"abc"
,
forKey
:
"xyz"
as
NSString
)
msg
.
mapInt32Enum
.
setEnum
(
Message2_Enum
.
b
ar
.
rawValue
,
forKey
:
600
)
// "proto3" syntax lets enum get unknown values.
msg
.
mapInt32Enum
.
setRawValue
(
666
,
forKey
:
601
)
...
...
@@ -167,20 +167,20 @@ class GPBBridgeTests: XCTestCase {
XCTAssertEqual
(
msg
.
optionalInt32
,
Int32
(
100
))
XCTAssertEqual
(
msg
.
optionalString
,
"abc"
)
XCTAssertEqual
(
msg2
.
optionalString
,
"other"
)
XCTAssertTrue
(
msg
.
optional
Message
===
msg2
)
XCTAssertEqual
(
msg
.
optionalEnum
,
Message3_Enum
.
B
ar
)
XCTAssertTrue
(
msg
.
optional
===
msg2
)
XCTAssertEqual
(
msg
.
optionalEnum
,
Message3_Enum
.
b
ar
)
XCTAssertEqual
(
msg
.
repeatedInt32Array
.
count
,
UInt
(
2
))
XCTAssertEqual
(
msg
.
repeatedInt32Array
.
value
AtIndex
(
0
),
Int32
(
300
))
XCTAssertEqual
(
msg
.
repeatedInt32Array
.
value
AtIndex
(
1
),
Int32
(
301
))
XCTAssertEqual
(
msg
.
repeatedInt32Array
.
value
(
at
:
0
),
Int32
(
300
))
XCTAssertEqual
(
msg
.
repeatedInt32Array
.
value
(
at
:
1
),
Int32
(
301
))
XCTAssertEqual
(
msg
.
repeatedStringArray
.
count
,
Int
(
2
))
XCTAssertEqual
(
msg
.
repeatedStringArray
.
object
AtIndex
(
0
)
as?
String
,
"mno"
)
XCTAssertEqual
(
msg
.
repeatedStringArray
.
object
AtIndex
(
1
)
as?
String
,
"pqr"
)
XCTAssertEqual
(
msg
.
repeatedStringArray
.
object
(
at
:
0
)
as?
String
,
"mno"
)
XCTAssertEqual
(
msg
.
repeatedStringArray
.
object
(
at
:
1
)
as?
String
,
"pqr"
)
XCTAssertEqual
(
msg
.
repeatedInt64Array
.
count
,
UInt
(
0
))
XCTAssertEqual
(
msg
.
repeatedEnumArray
.
count
,
UInt
(
2
))
XCTAssertEqual
(
msg
.
repeatedEnumArray
.
value
AtIndex
(
0
),
Message3_Enum
.
B
ar
.
rawValue
)
XCTAssertEqual
(
msg
.
repeatedEnumArray
.
value
AtIndex
(
1
),
Message3_Enum
.
GPB
UnrecognizedEnumeratorValue
.
rawValue
)
XCTAssertEqual
(
msg
.
repeatedEnumArray
.
rawValue
AtIndex
(
1
),
666
)
XCTAssertEqual
(
msg2
.
optionalEnum
,
Message3_Enum
.
GPB
UnrecognizedEnumeratorValue
)
XCTAssertEqual
(
msg
.
repeatedEnumArray
.
value
(
at
:
0
),
Message3_Enum
.
b
ar
.
rawValue
)
XCTAssertEqual
(
msg
.
repeatedEnumArray
.
value
(
at
:
1
),
Message3_Enum
.
gpb
UnrecognizedEnumeratorValue
.
rawValue
)
XCTAssertEqual
(
msg
.
repeatedEnumArray
.
rawValue
(
at
:
1
),
666
)
XCTAssertEqual
(
msg2
.
optionalEnum
,
Message3_Enum
.
gpb
UnrecognizedEnumeratorValue
)
XCTAssertEqual
(
Message3_OptionalEnum_RawValue
(
msg2
),
Int32
(
666
))
XCTAssertEqual
(
msg
.
mapInt32Int32
.
count
,
UInt
(
2
))
var
intValue
:
Int32
=
0
...
...
@@ -189,13 +189,13 @@ class GPBBridgeTests: XCTestCase {
XCTAssertTrue
(
msg
.
mapInt32Int32
.
getInt32
(
&
intValue
,
forKey
:
501
))
XCTAssertEqual
(
intValue
,
Int32
(
401
))
XCTAssertEqual
(
msg
.
mapStringString
.
count
,
Int
(
2
))
XCTAssertEqual
(
msg
.
mapStringString
.
object
ForKey
(
"bar"
)
as?
String
,
"foo"
)
XCTAssertEqual
(
msg
.
mapStringString
.
object
ForKey
(
"xyz"
)
as?
String
,
"abc"
)
XCTAssertEqual
(
msg
.
mapStringString
.
object
(
forKey
:
"bar"
)
as?
String
,
"foo"
)
XCTAssertEqual
(
msg
.
mapStringString
.
object
(
forKey
:
"xyz"
)
as?
String
,
"abc"
)
XCTAssertEqual
(
msg
.
mapInt32Enum
.
count
,
UInt
(
2
))
XCTAssertTrue
(
msg
.
mapInt32Enum
.
getEnum
(
&
intValue
,
forKey
:
600
))
XCTAssertEqual
(
intValue
,
Message2_Enum
.
B
ar
.
rawValue
)
XCTAssertEqual
(
intValue
,
Message2_Enum
.
b
ar
.
rawValue
)
XCTAssertTrue
(
msg
.
mapInt32Enum
.
getEnum
(
&
intValue
,
forKey
:
601
))
XCTAssertEqual
(
intValue
,
Message3_Enum
.
GPB
UnrecognizedEnumeratorValue
.
rawValue
)
XCTAssertEqual
(
intValue
,
Message3_Enum
.
gpb
UnrecognizedEnumeratorValue
.
rawValue
)
XCTAssertTrue
(
msg
.
mapInt32Enum
.
getRawValue
(
&
intValue
,
forKey
:
601
))
XCTAssertEqual
(
intValue
,
666
)
...
...
@@ -204,23 +204,23 @@ class GPBBridgeTests: XCTestCase {
XCTAssertEqual
(
msg2
.
optionalString
,
""
)
// Clearing a message with nil.
msg
.
optional
Message
=
nil
msg
.
optional
=
nil
XCTAssertFalse
(
msg
.
hasOptionalMessage
)
XCTAssertTrue
(
msg
.
optional
Message
!==
msg2
)
// New instance
XCTAssertTrue
(
msg
.
optional
!==
msg2
)
// New instance
// Clear.
msg
.
clear
()
XCTAssertFalse
(
msg
.
hasOptionalMessage
)
XCTAssertEqual
(
msg
.
optionalInt32
,
Int32
(
0
))
XCTAssertEqual
(
msg
.
optionalString
,
""
)
XCTAssertTrue
(
msg
.
optional
Message
!==
msg2
)
// New instance
XCTAssertEqual
(
msg
.
optionalEnum
,
Message3_Enum
.
F
oo
)
// Default
XCTAssertTrue
(
msg
.
optional
!==
msg2
)
// New instance
XCTAssertEqual
(
msg
.
optionalEnum
,
Message3_Enum
.
f
oo
)
// Default
XCTAssertEqual
(
msg
.
repeatedInt32Array
.
count
,
UInt
(
0
))
XCTAssertEqual
(
msg
.
repeatedStringArray
.
count
,
Int
(
0
))
XCTAssertEqual
(
msg
.
repeatedEnumArray
.
count
,
UInt
(
0
))
msg2
.
clear
()
XCTAssertEqual
(
msg2
.
optionalEnum
,
Message3_Enum
.
F
oo
)
// Default
XCTAssertEqual
(
Message3_OptionalEnum_RawValue
(
msg2
),
Message3_Enum
.
F
oo
.
rawValue
)
XCTAssertEqual
(
msg2
.
optionalEnum
,
Message3_Enum
.
f
oo
)
// Default
XCTAssertEqual
(
Message3_OptionalEnum_RawValue
(
msg2
),
Message3_Enum
.
f
oo
.
rawValue
)
XCTAssertEqual
(
msg
.
mapInt32Int32
.
count
,
UInt
(
0
))
XCTAssertEqual
(
msg
.
mapStringString
.
count
,
Int
(
0
))
XCTAssertEqual
(
msg
.
mapInt32Enum
.
count
,
UInt
(
0
))
...
...
@@ -234,201 +234,201 @@ class GPBBridgeTests: XCTestCase {
// Access shouldn't result in has* but should return objects.
let
msg2
=
msg
.
optionalGroup
let
msg3
=
msg
.
optional
Message
.
optionalMessage
let
msg4
=
msg
.
optional
Message
let
msg3
=
msg
.
optional
.
optional
let
msg4
=
msg
.
optional
XCTAssertNotNil
(
msg2
)
XCTAssertNotNil
(
msg3
)
XCTAssertFalse
(
msg
.
hasOptionalGroup
)
XCTAssertFalse
(
msg
.
optional
Message
.
hasOptionalMessage
)
XCTAssertFalse
(
msg
.
optional
.
hasOptionalMessage
)
XCTAssertFalse
(
msg
.
hasOptionalMessage
)
// Setting things should trigger has* getting set.
msg
.
optionalGroup
.
a
=
10
msg
.
optional
Message
.
optionalMessage
.
optionalInt32
=
100
msg
.
optional
.
optional
.
optionalInt32
=
100
XCTAssertTrue
(
msg
.
hasOptionalGroup
)
XCTAssertTrue
(
msg
.
optional
Message
.
hasOptionalMessage
)
XCTAssertTrue
(
msg
.
optional
.
hasOptionalMessage
)
XCTAssertTrue
(
msg
.
hasOptionalMessage
)
// And they should be the same pointer as before.
XCTAssertTrue
(
msg2
===
msg
.
optionalGroup
)
XCTAssertTrue
(
msg3
===
msg
.
optional
Message
.
optionalMessage
)
XCTAssertTrue
(
msg4
===
msg
.
optional
Message
)
XCTAssertTrue
(
msg3
===
msg
.
optional
.
optional
)
XCTAssertTrue
(
msg4
===
msg
.
optional
)
// Clear gets us new objects next time around.
msg
.
clear
()
XCTAssertFalse
(
msg
.
hasOptionalGroup
)
XCTAssertFalse
(
msg
.
optional
Message
.
hasOptionalMessage
)
XCTAssertFalse
(
msg
.
optional
.
hasOptionalMessage
)
XCTAssertFalse
(
msg
.
hasOptionalMessage
)
msg
.
optionalGroup
.
a
=
20
msg
.
optional
Message
.
optionalMessage
.
optionalInt32
=
200
msg
.
optional
.
optional
.
optionalInt32
=
200
XCTAssertTrue
(
msg
.
hasOptionalGroup
)
XCTAssertTrue
(
msg
.
optional
Message
.
hasOptionalMessage
)
XCTAssertTrue
(
msg
.
optional
.
hasOptionalMessage
)
XCTAssertTrue
(
msg
.
hasOptionalMessage
)
XCTAssertTrue
(
msg2
!==
msg
.
optionalGroup
)
XCTAssertTrue
(
msg3
!==
msg
.
optional
Message
.
optionalMessage
)
XCTAssertTrue
(
msg4
!==
msg
.
optional
Message
)
XCTAssertTrue
(
msg3
!==
msg
.
optional
.
optional
)
XCTAssertTrue
(
msg4
!==
msg
.
optional
)
// Explicit set of a message, means autocreated object doesn't bind.
msg
.
clear
()
let
autoCreated
=
msg
.
optional
Message
let
autoCreated
=
msg
.
optional
XCTAssertFalse
(
msg
.
hasOptionalMessage
)
let
msg5
=
Message2
()
msg5
.
optionalInt32
=
123
msg
.
optional
Message
=
msg5
msg
.
optional
=
msg5
XCTAssertTrue
(
msg
.
hasOptionalMessage
)
// Modifing the autocreated doesn't replaced the explicit set one.
autoCreated
.
optionalInt32
=
456
autoCreated
?
.
optionalInt32
=
456
XCTAssertTrue
(
msg
.
hasOptionalMessage
)
XCTAssertTrue
(
msg
.
optional
Message
===
msg5
)
XCTAssertEqual
(
msg
.
optional
Message
.
optionalInt32
,
Int32
(
123
))
XCTAssertTrue
(
msg
.
optional
===
msg5
)
XCTAssertEqual
(
msg
.
optional
.
optionalInt32
,
Int32
(
123
))
}
func
testProto2OneOfSupport
()
{
let
msg
=
Message2
()
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message2_O_OneOfCase
.
GPB
UnsetOneOfCase
)
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message2_O_OneOfCase
.
gpb
UnsetOneOfCase
)
XCTAssertEqual
(
msg
.
oneofInt32
,
Int32
(
100
))
// Default
XCTAssertEqual
(
msg
.
oneofFloat
,
Float
(
110.0
))
// Default
XCTAssertEqual
(
msg
.
oneofEnum
,
Message2_Enum
.
B
az
)
// Default
let
autoCreated
=
msg
.
oneof
Message
// Default create one.
XCTAssertEqual
(
msg
.
oneofEnum
,
Message2_Enum
.
b
az
)
// Default
let
autoCreated
=
msg
.
oneof
// Default create one.
XCTAssertNotNil
(
autoCreated
)
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message2_O_OneOfCase
.
GPB
UnsetOneOfCase
)
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message2_O_OneOfCase
.
gpb
UnsetOneOfCase
)
msg
.
oneofInt32
=
10
XCTAssertEqual
(
msg
.
oneofInt32
,
Int32
(
10
))
XCTAssertEqual
(
msg
.
oneofFloat
,
Float
(
110.0
))
// Default
XCTAssertEqual
(
msg
.
oneofEnum
,
Message2_Enum
.
B
az
)
// Default
XCTAssertTrue
(
msg
.
oneof
Message
===
autoCreated
)
// Still the same
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message2_O_OneOfCase
.
O
neofInt32
)
XCTAssertEqual
(
msg
.
oneofEnum
,
Message2_Enum
.
b
az
)
// Default
XCTAssertTrue
(
msg
.
oneof
===
autoCreated
)
// Still the same
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message2_O_OneOfCase
.
o
neofInt32
)
msg
.
oneofFloat
=
20.0
XCTAssertEqual
(
msg
.
oneofInt32
,
Int32
(
100
))
// Default
XCTAssertEqual
(
msg
.
oneofFloat
,
Float
(
20.0
))
XCTAssertEqual
(
msg
.
oneofEnum
,
Message2_Enum
.
B
az
)
// Default
XCTAssertTrue
(
msg
.
oneof
Message
===
autoCreated
)
// Still the same
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message2_O_OneOfCase
.
O
neofFloat
)
XCTAssertEqual
(
msg
.
oneofEnum
,
Message2_Enum
.
b
az
)
// Default
XCTAssertTrue
(
msg
.
oneof
===
autoCreated
)
// Still the same
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message2_O_OneOfCase
.
o
neofFloat
)
msg
.
oneofEnum
=
.
B
ar
msg
.
oneofEnum
=
.
b
ar
XCTAssertEqual
(
msg
.
oneofInt32
,
Int32
(
100
))
// Default
XCTAssertEqual
(
msg
.
oneofFloat
,
Float
(
110.0
))
// Default
XCTAssertEqual
(
msg
.
oneofEnum
,
Message2_Enum
.
B
ar
)
XCTAssertTrue
(
msg
.
oneof
Message
===
autoCreated
)
// Still the same
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message2_O_OneOfCase
.
O
neofEnum
)
XCTAssertEqual
(
msg
.
oneofEnum
,
Message2_Enum
.
b
ar
)
XCTAssertTrue
(
msg
.
oneof
===
autoCreated
)
// Still the same
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message2_O_OneOfCase
.
o
neofEnum
)
// Sets via the autocreated instance.
msg
.
oneof
Message
.
optionalInt32
=
200
msg
.
oneof
.
optionalInt32
=
200
XCTAssertEqual
(
msg
.
oneofInt32
,
Int32
(
100
))
// Default
XCTAssertEqual
(
msg
.
oneofFloat
,
Float
(
110.0
))
// Default
XCTAssertEqual
(
msg
.
oneofEnum
,
Message2_Enum
.
B
az
)
// Default
XCTAssertTrue
(
msg
.
oneof
Message
===
autoCreated
)
// Still the same
XCTAssertEqual
(
msg
.
oneof
Message
.
optionalInt32
,
Int32
(
200
))
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message2_O_OneOfCase
.
O
neofMessage
)
XCTAssertEqual
(
msg
.
oneofEnum
,
Message2_Enum
.
b
az
)
// Default
XCTAssertTrue
(
msg
.
oneof
===
autoCreated
)
// Still the same
XCTAssertEqual
(
msg
.
oneof
.
optionalInt32
,
Int32
(
200
))
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message2_O_OneOfCase
.
o
neofMessage
)
// Clear the oneof.
Message2_ClearOOneOfCase
(
msg
)
XCTAssertEqual
(
msg
.
oneofInt32
,
Int32
(
100
))
// Default
XCTAssertEqual
(
msg
.
oneofFloat
,
Float
(
110.0
))
// Default
XCTAssertEqual
(
msg
.
oneofEnum
,
Message2_Enum
.
B
az
)
// Default
let
autoCreated2
=
msg
.
oneof
Message
// Default create one
XCTAssertEqual
(
msg
.
oneofEnum
,
Message2_Enum
.
b
az
)
// Default
let
autoCreated2
=
msg
.
oneof
// Default create one
XCTAssertNotNil
(
autoCreated2
)
XCTAssertTrue
(
autoCreated2
!==
autoCreated
)
// New instance
XCTAssertEqual
(
msg
.
oneof
Message
.
optionalInt32
,
Int32
(
0
))
// Default
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message2_O_OneOfCase
.
GPB
UnsetOneOfCase
)
XCTAssertEqual
(
msg
.
oneof
.
optionalInt32
,
Int32
(
0
))
// Default
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message2_O_OneOfCase
.
gpb
UnsetOneOfCase
)
msg
.
oneofInt32
=
10
XCTAssertEqual
(
msg
.
oneofInt32
,
Int32
(
10
))
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message2_O_OneOfCase
.
O
neofInt32
)
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message2_O_OneOfCase
.
o
neofInt32
)
// Confirm Message.clear() handles the oneof correctly.
msg
.
clear
()
XCTAssertEqual
(
msg
.
oneofInt32
,
Int32
(
100
))
// Default
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message2_O_OneOfCase
.
GPB
UnsetOneOfCase
)
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message2_O_OneOfCase
.
gpb
UnsetOneOfCase
)
// Sets via the autocreated instance.
msg
.
oneof
Message
.
optionalInt32
=
300
XCTAssertTrue
(
msg
.
oneof
Message
!==
autoCreated
)
// New instance
XCTAssertTrue
(
msg
.
oneof
Message
!==
autoCreated2
)
// New instance
XCTAssertEqual
(
msg
.
oneof
Message
.
optionalInt32
,
Int32
(
300
))
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message2_O_OneOfCase
.
O
neofMessage
)
msg
.
oneof
.
optionalInt32
=
300
XCTAssertTrue
(
msg
.
oneof
!==
autoCreated
)
// New instance
XCTAssertTrue
(
msg
.
oneof
!==
autoCreated2
)
// New instance
XCTAssertEqual
(
msg
.
oneof
.
optionalInt32
,
Int32
(
300
))
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message2_O_OneOfCase
.
o
neofMessage
)
// Set message to nil clears the oneof.
msg
.
oneof
Message
=
nil
XCTAssertEqual
(
msg
.
oneof
Message
.
optionalInt32
,
Int32
(
0
))
// Default
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message2_O_OneOfCase
.
GPB
UnsetOneOfCase
)
msg
.
oneof
=
nil
XCTAssertEqual
(
msg
.
oneof
.
optionalInt32
,
Int32
(
0
))
// Default
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message2_O_OneOfCase
.
gpb
UnsetOneOfCase
)
}
func
testProto3OneOfSupport
()
{
let
msg
=
Message3
()
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message3_O_OneOfCase
.
GPB
UnsetOneOfCase
)
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message3_O_OneOfCase
.
gpb
UnsetOneOfCase
)
XCTAssertEqual
(
msg
.
oneofInt32
,
Int32
(
0
))
// Default
XCTAssertEqual
(
msg
.
oneofFloat
,
Float
(
0.0
))
// Default
XCTAssertEqual
(
msg
.
oneofEnum
,
Message3_Enum
.
F
oo
)
// Default
let
autoCreated
=
msg
.
oneof
Message
// Default create one.
XCTAssertEqual
(
msg
.
oneofEnum
,
Message3_Enum
.
f
oo
)
// Default
let
autoCreated
=
msg
.
oneof
// Default create one.
XCTAssertNotNil
(
autoCreated
)
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message3_O_OneOfCase
.
GPB
UnsetOneOfCase
)
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message3_O_OneOfCase
.
gpb
UnsetOneOfCase
)
msg
.
oneofInt32
=
10
XCTAssertEqual
(
msg
.
oneofInt32
,
Int32
(
10
))
XCTAssertEqual
(
msg
.
oneofFloat
,
Float
(
0.0
))
// Default
XCTAssertEqual
(
msg
.
oneofEnum
,
Message3_Enum
.
F
oo
)
// Default
XCTAssertTrue
(
msg
.
oneof
Message
===
autoCreated
)
// Still the same
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message3_O_OneOfCase
.
O
neofInt32
)
XCTAssertEqual
(
msg
.
oneofEnum
,
Message3_Enum
.
f
oo
)
// Default
XCTAssertTrue
(
msg
.
oneof
===
autoCreated
)
// Still the same
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message3_O_OneOfCase
.
o
neofInt32
)
msg
.
oneofFloat
=
20.0
XCTAssertEqual
(
msg
.
oneofInt32
,
Int32
(
0
))
// Default
XCTAssertEqual
(
msg
.
oneofFloat
,
Float
(
20.0
))
XCTAssertEqual
(
msg
.
oneofEnum
,
Message3_Enum
.
F
oo
)
// Default
XCTAssertTrue
(
msg
.
oneof
Message
===
autoCreated
)
// Still the same
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message3_O_OneOfCase
.
O
neofFloat
)
XCTAssertEqual
(
msg
.
oneofEnum
,
Message3_Enum
.
f
oo
)
// Default
XCTAssertTrue
(
msg
.
oneof
===
autoCreated
)
// Still the same
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message3_O_OneOfCase
.
o
neofFloat
)
msg
.
oneofEnum
=
.
B
ar
msg
.
oneofEnum
=
.
b
ar
XCTAssertEqual
(
msg
.
oneofInt32
,
Int32
(
0
))
// Default
XCTAssertEqual
(
msg
.
oneofFloat
,
Float
(
0.0
))
// Default
XCTAssertEqual
(
msg
.
oneofEnum
,
Message3_Enum
.
B
ar
)
XCTAssertTrue
(
msg
.
oneof
Message
===
autoCreated
)
// Still the same
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message3_O_OneOfCase
.
O
neofEnum
)
XCTAssertEqual
(
msg
.
oneofEnum
,
Message3_Enum
.
b
ar
)
XCTAssertTrue
(
msg
.
oneof
===
autoCreated
)
// Still the same
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message3_O_OneOfCase
.
o
neofEnum
)
// Sets via the autocreated instance.
msg
.
oneof
Message
.
optionalInt32
=
200
msg
.
oneof
.
optionalInt32
=
200
XCTAssertEqual
(
msg
.
oneofInt32
,
Int32
(
0
))
// Default
XCTAssertEqual
(
msg
.
oneofFloat
,
Float
(
0.0
))
// Default
XCTAssertEqual
(
msg
.
oneofEnum
,
Message3_Enum
.
F
oo
)
// Default
XCTAssertTrue
(
msg
.
oneof
Message
===
autoCreated
)
// Still the same
XCTAssertEqual
(
msg
.
oneof
Message
.
optionalInt32
,
Int32
(
200
))
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message3_O_OneOfCase
.
O
neofMessage
)
XCTAssertEqual
(
msg
.
oneofEnum
,
Message3_Enum
.
f
oo
)
// Default
XCTAssertTrue
(
msg
.
oneof
===
autoCreated
)
// Still the same
XCTAssertEqual
(
msg
.
oneof
.
optionalInt32
,
Int32
(
200
))
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message3_O_OneOfCase
.
o
neofMessage
)
// Clear the oneof.
Message3_ClearOOneOfCase
(
msg
)
XCTAssertEqual
(
msg
.
oneofInt32
,
Int32
(
0
))
// Default
XCTAssertEqual
(
msg
.
oneofFloat
,
Float
(
0.0
))
// Default
XCTAssertEqual
(
msg
.
oneofEnum
,
Message3_Enum
.
F
oo
)
// Default
let
autoCreated2
=
msg
.
oneof
Message
// Default create one
XCTAssertEqual
(
msg
.
oneofEnum
,
Message3_Enum
.
f
oo
)
// Default
let
autoCreated2
=
msg
.
oneof
// Default create one
XCTAssertNotNil
(
autoCreated2
)
XCTAssertTrue
(
autoCreated2
!==
autoCreated
)
// New instance
XCTAssertEqual
(
msg
.
oneof
Message
.
optionalInt32
,
Int32
(
0
))
// Default
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message3_O_OneOfCase
.
GPB
UnsetOneOfCase
)
XCTAssertEqual
(
msg
.
oneof
.
optionalInt32
,
Int32
(
0
))
// Default
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message3_O_OneOfCase
.
gpb
UnsetOneOfCase
)
msg
.
oneofInt32
=
10
XCTAssertEqual
(
msg
.
oneofInt32
,
Int32
(
10
))
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message3_O_OneOfCase
.
O
neofInt32
)
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message3_O_OneOfCase
.
o
neofInt32
)
// Confirm Message.clear() handles the oneof correctly.
msg
.
clear
()
XCTAssertEqual
(
msg
.
oneofInt32
,
Int32
(
0
))
// Default
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message3_O_OneOfCase
.
GPB
UnsetOneOfCase
)
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message3_O_OneOfCase
.
gpb
UnsetOneOfCase
)
// Sets via the autocreated instance.
msg
.
oneof
Message
.
optionalInt32
=
300
XCTAssertTrue
(
msg
.
oneof
Message
!==
autoCreated
)
// New instance
XCTAssertTrue
(
msg
.
oneof
Message
!==
autoCreated2
)
// New instance
XCTAssertEqual
(
msg
.
oneof
Message
.
optionalInt32
,
Int32
(
300
))
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message3_O_OneOfCase
.
O
neofMessage
)
msg
.
oneof
.
optionalInt32
=
300
XCTAssertTrue
(
msg
.
oneof
!==
autoCreated
)
// New instance
XCTAssertTrue
(
msg
.
oneof
!==
autoCreated2
)
// New instance
XCTAssertEqual
(
msg
.
oneof
.
optionalInt32
,
Int32
(
300
))
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message3_O_OneOfCase
.
o
neofMessage
)
// Set message to nil clears the oneof.
msg
.
oneof
Message
=
nil
XCTAssertEqual
(
msg
.
oneof
Message
.
optionalInt32
,
Int32
(
0
))
// Default
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message3_O_OneOfCase
.
GPB
UnsetOneOfCase
)
msg
.
oneof
=
nil
XCTAssertEqual
(
msg
.
oneof
.
optionalInt32
,
Int32
(
0
))
// Default
XCTAssertEqual
(
msg
.
oOneOfCase
,
Message3_O_OneOfCase
.
gpb
UnsetOneOfCase
)
}
func
testSerialization
()
{
...
...
@@ -437,12 +437,12 @@ class GPBBridgeTests: XCTestCase {
msg
.
optionalInt32
=
100
msg
.
optionalInt64
=
101
msg
.
optionalGroup
.
a
=
102
msg
.
repeatedStringArray
.
add
Object
(
"abc"
)
msg
.
repeatedStringArray
.
add
Object
(
"def"
)
msg
.
repeatedStringArray
.
add
(
"abc"
)
msg
.
repeatedStringArray
.
add
(
"def"
)
msg
.
mapInt32Int32
.
setInt32
(
200
,
forKey
:
300
)
msg
.
mapInt32Int32
.
setInt32
(
201
,
forKey
:
201
)
msg
.
mapStringString
.
setObject
(
"foo"
,
forKey
:
"bar"
)
msg
.
mapStringString
.
setObject
(
"abc"
,
forKey
:
"xyz"
)
msg
.
mapStringString
.
setObject
(
"foo"
,
forKey
:
"bar"
as
NSString
)
msg
.
mapStringString
.
setObject
(
"abc"
,
forKey
:
"xyz"
as
NSString
)
let
data
=
msg
.
data
()
...
...
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