aboutsummaryrefslogtreecommitdiff
path: root/objectivec/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'objectivec/Tests')
-rw-r--r--objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/project.pbxproj290
-rw-r--r--objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/project.xcworkspace/contents.xcworkspacedata7
-rw-r--r--objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/xcshareddata/xcschemes/OSXCocoaPodsTester.xcscheme91
-rw-r--r--objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/AppDelegate.h37
-rw-r--r--objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/AppDelegate.m48
-rw-r--r--objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Assets.xcassets/AppIcon.appiconset/Contents.json58
-rw-r--r--objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Base.lproj/MainMenu.xib680
-rw-r--r--objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Info.plist34
-rw-r--r--objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/main.m35
-rw-r--r--objectivec/Tests/CocoaPods/OSXCocoaPodsTester/Podfile-framework10
-rw-r--r--objectivec/Tests/CocoaPods/OSXCocoaPodsTester/Podfile-static8
-rw-r--r--objectivec/Tests/CocoaPods/README.md9
-rw-r--r--objectivec/Tests/CocoaPods/iOSCocoaPodsTester/Podfile-framework10
-rw-r--r--objectivec/Tests/CocoaPods/iOSCocoaPodsTester/Podfile-static8
-rw-r--r--objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/project.pbxproj309
-rw-r--r--objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/project.xcworkspace/contents.xcworkspacedata7
-rw-r--r--objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/xcshareddata/xcschemes/iOSCocoaPodsTester.xcscheme91
-rw-r--r--objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/AppDelegate.h39
-rw-r--r--objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/AppDelegate.m67
-rw-r--r--objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Assets.xcassets/AppIcon.appiconset/Contents.json (renamed from objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/Contents.json)54
-rw-r--r--objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Base.lproj/LaunchScreen.storyboard27
-rw-r--r--objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Base.lproj/Main.storyboard26
-rw-r--r--objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Info.plist (renamed from objectivec/Tests/iOSTestHarness/Info.plist)16
-rw-r--r--objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/ViewController.h37
-rw-r--r--objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/ViewController.m49
-rw-r--r--objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/main.m39
-rwxr-xr-xobjectivec/Tests/CocoaPods/run_tests.sh150
-rw-r--r--objectivec/Tests/GPBARCUnittestProtos.m7
-rw-r--r--objectivec/Tests/GPBArrayTests.m331
-rw-r--r--objectivec/Tests/GPBCodedInputStreamTests.m236
-rw-r--r--objectivec/Tests/GPBCodedOuputStreamTests.m119
-rw-r--r--objectivec/Tests/GPBCompileTest01.m40
-rw-r--r--objectivec/Tests/GPBCompileTest02.m40
-rw-r--r--objectivec/Tests/GPBCompileTest03.m40
-rw-r--r--objectivec/Tests/GPBCompileTest04.m40
-rw-r--r--objectivec/Tests/GPBCompileTest05.m40
-rw-r--r--objectivec/Tests/GPBCompileTest06.m40
-rw-r--r--objectivec/Tests/GPBCompileTest07.m40
-rw-r--r--objectivec/Tests/GPBCompileTest08.m40
-rw-r--r--objectivec/Tests/GPBCompileTest09.m40
-rw-r--r--objectivec/Tests/GPBCompileTest10.m40
-rw-r--r--objectivec/Tests/GPBCompileTest11.m40
-rw-r--r--objectivec/Tests/GPBCompileTest12.m40
-rw-r--r--objectivec/Tests/GPBCompileTest13.m40
-rw-r--r--objectivec/Tests/GPBCompileTest14.m40
-rw-r--r--objectivec/Tests/GPBCompileTest15.m40
-rw-r--r--objectivec/Tests/GPBCompileTest16.m40
-rw-r--r--objectivec/Tests/GPBCompileTest17.m40
-rw-r--r--objectivec/Tests/GPBCompileTest18.m40
-rw-r--r--objectivec/Tests/GPBCompileTest19.m40
-rw-r--r--objectivec/Tests/GPBCompileTest20.m40
-rw-r--r--objectivec/Tests/GPBCompileTest21.m40
-rw-r--r--objectivec/Tests/GPBCompileTest22.m40
-rw-r--r--objectivec/Tests/GPBCompileTest23.m40
-rw-r--r--objectivec/Tests/GPBCompileTest24.m42
-rw-r--r--objectivec/Tests/GPBCompileTest25.m42
-rw-r--r--objectivec/Tests/GPBDescriptorTests.m224
-rw-r--r--objectivec/Tests/GPBDictionaryTests+Bool.m1148
-rw-r--r--objectivec/Tests/GPBDictionaryTests+Int32.m2189
-rw-r--r--objectivec/Tests/GPBDictionaryTests+Int64.m2189
-rw-r--r--objectivec/Tests/GPBDictionaryTests+String.m2111
-rw-r--r--objectivec/Tests/GPBDictionaryTests+UInt32.m2189
-rw-r--r--objectivec/Tests/GPBDictionaryTests+UInt64.m2189
-rw-r--r--objectivec/Tests/GPBDictionaryTests.m186
-rw-r--r--objectivec/Tests/GPBDictionaryTests.pddm558
-rw-r--r--objectivec/Tests/GPBExtensionRegistryTest.m138
-rw-r--r--objectivec/Tests/GPBMessageTests+Runtime.m439
-rw-r--r--objectivec/Tests/GPBMessageTests+Serialization.m288
-rw-r--r--objectivec/Tests/GPBMessageTests.m182
-rw-r--r--objectivec/Tests/GPBPerfTests.m106
-rw-r--r--objectivec/Tests/GPBSwiftTests.swift314
-rw-r--r--objectivec/Tests/GPBTestUtilities.h3
-rw-r--r--objectivec/Tests/GPBTestUtilities.m30
-rw-r--r--objectivec/Tests/GPBUnittestProtos.m16
-rw-r--r--objectivec/Tests/GPBUnittestProtos2.m34
-rw-r--r--objectivec/Tests/GPBUnknownFieldSetTest.m271
-rw-r--r--objectivec/Tests/GPBUtilitiesTests.m235
-rw-r--r--objectivec/Tests/GPBWellKnownTypesTest.m216
-rw-r--r--objectivec/Tests/GPBWireFormatTests.m8
-rw-r--r--objectivec/Tests/iOSTestHarness/AppDelegate.m35
-rw-r--r--objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad6.pngbin8583 -> 0 bytes
-rw-r--r--objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad6_2x.pngbin17744 -> 0 bytes
-rw-r--r--objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad7.pngbin8969 -> 0 bytes
-rw-r--r--objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad7_2x.pngbin18788 -> 0 bytes
-rw-r--r--objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone6.pngbin7021 -> 0 bytes
-rw-r--r--objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone6_2x.pngbin13348 -> 0 bytes
-rw-r--r--objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone7_2x.pngbin11128 -> 0 bytes
-rw-r--r--objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone7_3x.pngbin21792 -> 0 bytes
-rw-r--r--objectivec/Tests/iOSTestHarness/Images.xcassets/LaunchImage.launchimage/Contents.json49
-rw-r--r--objectivec/Tests/iOSTestHarness/LaunchScreen.xib33
-rw-r--r--objectivec/Tests/iOSTestHarness/en.lproj/InfoPlist.strings2
-rw-r--r--objectivec/Tests/unittest_cycle.proto6
-rw-r--r--objectivec/Tests/unittest_deprecated.proto95
-rw-r--r--objectivec/Tests/unittest_deprecated_file.proto76
-rw-r--r--objectivec/Tests/unittest_extension_chain_a.proto51
-rw-r--r--objectivec/Tests/unittest_extension_chain_b.proto47
-rw-r--r--objectivec/Tests/unittest_extension_chain_c.proto45
-rw-r--r--objectivec/Tests/unittest_extension_chain_d.proto49
-rw-r--r--objectivec/Tests/unittest_extension_chain_e.proto40
-rw-r--r--objectivec/Tests/unittest_extension_chain_f.proto44
-rw-r--r--objectivec/Tests/unittest_extension_chain_g.proto41
-rw-r--r--objectivec/Tests/unittest_objc.proto97
102 files changed, 13113 insertions, 6793 deletions
diff --git a/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/project.pbxproj b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/project.pbxproj
new file mode 100644
index 00000000..b9df381a
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/project.pbxproj
@@ -0,0 +1,290 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ F4D5A0AE1CEE2D8F00562D79 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F4D5A0AD1CEE2D8F00562D79 /* AppDelegate.m */; };
+ F4D5A0B11CEE2D8F00562D79 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F4D5A0B01CEE2D8F00562D79 /* main.m */; };
+ F4D5A0B31CEE2D8F00562D79 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F4D5A0B21CEE2D8F00562D79 /* Assets.xcassets */; };
+ F4D5A0B61CEE2D8F00562D79 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = F4D5A0B41CEE2D8F00562D79 /* MainMenu.xib */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ F4D5A0A91CEE2D8F00562D79 /* OSXCocoaPodsTester.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OSXCocoaPodsTester.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ F4D5A0AC1CEE2D8F00562D79 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
+ F4D5A0AD1CEE2D8F00562D79 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
+ F4D5A0B01CEE2D8F00562D79 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
+ F4D5A0B21CEE2D8F00562D79 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
+ F4D5A0B51CEE2D8F00562D79 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; };
+ F4D5A0B71CEE2D8F00562D79 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ F4D5A0A61CEE2D8F00562D79 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ F4D5A0A01CEE2D8F00562D79 = {
+ isa = PBXGroup;
+ children = (
+ F4D5A0AB1CEE2D8F00562D79 /* OSXCocoaPodsTester */,
+ F4D5A0AA1CEE2D8F00562D79 /* Products */,
+ );
+ sourceTree = "<group>";
+ };
+ F4D5A0AA1CEE2D8F00562D79 /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ F4D5A0A91CEE2D8F00562D79 /* OSXCocoaPodsTester.app */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ F4D5A0AB1CEE2D8F00562D79 /* OSXCocoaPodsTester */ = {
+ isa = PBXGroup;
+ children = (
+ F4D5A0AC1CEE2D8F00562D79 /* AppDelegate.h */,
+ F4D5A0AD1CEE2D8F00562D79 /* AppDelegate.m */,
+ F4D5A0B21CEE2D8F00562D79 /* Assets.xcassets */,
+ F4D5A0B41CEE2D8F00562D79 /* MainMenu.xib */,
+ F4D5A0B71CEE2D8F00562D79 /* Info.plist */,
+ F4D5A0AF1CEE2D8F00562D79 /* Supporting Files */,
+ );
+ path = OSXCocoaPodsTester;
+ sourceTree = "<group>";
+ };
+ F4D5A0AF1CEE2D8F00562D79 /* Supporting Files */ = {
+ isa = PBXGroup;
+ children = (
+ F4D5A0B01CEE2D8F00562D79 /* main.m */,
+ );
+ name = "Supporting Files";
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ F4D5A0A81CEE2D8F00562D79 /* OSXCocoaPodsTester */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = F4D5A0BA1CEE2D8F00562D79 /* Build configuration list for PBXNativeTarget "OSXCocoaPodsTester" */;
+ buildPhases = (
+ F4D5A0A51CEE2D8F00562D79 /* Sources */,
+ F4D5A0A61CEE2D8F00562D79 /* Frameworks */,
+ F4D5A0A71CEE2D8F00562D79 /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = OSXCocoaPodsTester;
+ productName = OSXCocoaPodsTester;
+ productReference = F4D5A0A91CEE2D8F00562D79 /* OSXCocoaPodsTester.app */;
+ productType = "com.apple.product-type.application";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ F4D5A0A11CEE2D8F00562D79 /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0730;
+ ORGANIZATIONNAME = Google;
+ TargetAttributes = {
+ F4D5A0A81CEE2D8F00562D79 = {
+ CreatedOnToolsVersion = 7.3.1;
+ };
+ };
+ };
+ buildConfigurationList = F4D5A0A41CEE2D8F00562D79 /* Build configuration list for PBXProject "OSXCocoaPodsTester" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ Base,
+ );
+ mainGroup = F4D5A0A01CEE2D8F00562D79;
+ productRefGroup = F4D5A0AA1CEE2D8F00562D79 /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ F4D5A0A81CEE2D8F00562D79 /* OSXCocoaPodsTester */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ F4D5A0A71CEE2D8F00562D79 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ F4D5A0B31CEE2D8F00562D79 /* Assets.xcassets in Resources */,
+ F4D5A0B61CEE2D8F00562D79 /* MainMenu.xib in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ F4D5A0A51CEE2D8F00562D79 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ F4D5A0B11CEE2D8F00562D79 /* main.m in Sources */,
+ F4D5A0AE1CEE2D8F00562D79 /* AppDelegate.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXVariantGroup section */
+ F4D5A0B41CEE2D8F00562D79 /* MainMenu.xib */ = {
+ isa = PBXVariantGroup;
+ children = (
+ F4D5A0B51CEE2D8F00562D79 /* Base */,
+ );
+ name = MainMenu.xib;
+ sourceTree = "<group>";
+ };
+/* End PBXVariantGroup section */
+
+/* Begin XCBuildConfiguration section */
+ F4D5A0B81CEE2D8F00562D79 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ CODE_SIGN_IDENTITY = "-";
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = dwarf;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ ENABLE_TESTABILITY = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.11;
+ MTL_ENABLE_DEBUG_INFO = YES;
+ ONLY_ACTIVE_ARCH = YES;
+ SDKROOT = macosx;
+ };
+ name = Debug;
+ };
+ F4D5A0B91CEE2D8F00562D79 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ CODE_SIGN_IDENTITY = "-";
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ ENABLE_NS_ASSERTIONS = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.11;
+ MTL_ENABLE_DEBUG_INFO = NO;
+ SDKROOT = macosx;
+ };
+ name = Release;
+ };
+ F4D5A0BB1CEE2D8F00562D79 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ COMBINE_HIDPI_IMAGES = YES;
+ INFOPLIST_FILE = OSXCocoaPodsTester/Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = com.google.OSXCocoaPodsTester;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Debug;
+ };
+ F4D5A0BC1CEE2D8F00562D79 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ COMBINE_HIDPI_IMAGES = YES;
+ INFOPLIST_FILE = OSXCocoaPodsTester/Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = com.google.OSXCocoaPodsTester;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ F4D5A0A41CEE2D8F00562D79 /* Build configuration list for PBXProject "OSXCocoaPodsTester" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ F4D5A0B81CEE2D8F00562D79 /* Debug */,
+ F4D5A0B91CEE2D8F00562D79 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ F4D5A0BA1CEE2D8F00562D79 /* Build configuration list for PBXNativeTarget "OSXCocoaPodsTester" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ F4D5A0BB1CEE2D8F00562D79 /* Debug */,
+ F4D5A0BC1CEE2D8F00562D79 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = F4D5A0A11CEE2D8F00562D79 /* Project object */;
+}
diff --git a/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/project.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 00000000..6d874e28
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Workspace
+ version = "1.0">
+ <FileRef
+ location = "self:OSXCocoaPodsTester.xcodeproj">
+ </FileRef>
+</Workspace>
diff --git a/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/xcshareddata/xcschemes/OSXCocoaPodsTester.xcscheme b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/xcshareddata/xcschemes/OSXCocoaPodsTester.xcscheme
new file mode 100644
index 00000000..56f8782e
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/xcshareddata/xcschemes/OSXCocoaPodsTester.xcscheme
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+ LastUpgradeVersion = "0730"
+ version = "1.3">
+ <BuildAction
+ parallelizeBuildables = "YES"
+ buildImplicitDependencies = "YES">
+ <BuildActionEntries>
+ <BuildActionEntry
+ buildForTesting = "YES"
+ buildForRunning = "YES"
+ buildForProfiling = "YES"
+ buildForArchiving = "YES"
+ buildForAnalyzing = "YES">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "F4D5A0A81CEE2D8F00562D79"
+ BuildableName = "OSXCocoaPodsTester.app"
+ BlueprintName = "OSXCocoaPodsTester"
+ ReferencedContainer = "container:OSXCocoaPodsTester.xcodeproj">
+ </BuildableReference>
+ </BuildActionEntry>
+ </BuildActionEntries>
+ </BuildAction>
+ <TestAction
+ buildConfiguration = "Debug"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ shouldUseLaunchSchemeArgsEnv = "YES">
+ <Testables>
+ </Testables>
+ <MacroExpansion>
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "F4D5A0A81CEE2D8F00562D79"
+ BuildableName = "OSXCocoaPodsTester.app"
+ BlueprintName = "OSXCocoaPodsTester"
+ ReferencedContainer = "container:OSXCocoaPodsTester.xcodeproj">
+ </BuildableReference>
+ </MacroExpansion>
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </TestAction>
+ <LaunchAction
+ buildConfiguration = "Debug"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ launchStyle = "0"
+ useCustomWorkingDirectory = "NO"
+ ignoresPersistentStateOnLaunch = "NO"
+ debugDocumentVersioning = "YES"
+ debugServiceExtension = "internal"
+ allowLocationSimulation = "YES">
+ <BuildableProductRunnable
+ runnableDebuggingMode = "0">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "F4D5A0A81CEE2D8F00562D79"
+ BuildableName = "OSXCocoaPodsTester.app"
+ BlueprintName = "OSXCocoaPodsTester"
+ ReferencedContainer = "container:OSXCocoaPodsTester.xcodeproj">
+ </BuildableReference>
+ </BuildableProductRunnable>
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </LaunchAction>
+ <ProfileAction
+ buildConfiguration = "Release"
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ savedToolIdentifier = ""
+ useCustomWorkingDirectory = "NO"
+ debugDocumentVersioning = "YES">
+ <BuildableProductRunnable
+ runnableDebuggingMode = "0">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "F4D5A0A81CEE2D8F00562D79"
+ BuildableName = "OSXCocoaPodsTester.app"
+ BlueprintName = "OSXCocoaPodsTester"
+ ReferencedContainer = "container:OSXCocoaPodsTester.xcodeproj">
+ </BuildableReference>
+ </BuildableProductRunnable>
+ </ProfileAction>
+ <AnalyzeAction
+ buildConfiguration = "Debug">
+ </AnalyzeAction>
+ <ArchiveAction
+ buildConfiguration = "Release"
+ revealArchiveInOrganizer = "YES">
+ </ArchiveAction>
+</Scheme>
diff --git a/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/AppDelegate.h b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/AppDelegate.h
new file mode 100644
index 00000000..c7ab521d
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/AppDelegate.h
@@ -0,0 +1,37 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#import <Cocoa/Cocoa.h>
+
+@interface AppDelegate : NSObject <NSApplicationDelegate>
+
+
+@end
+
diff --git a/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/AppDelegate.m b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/AppDelegate.m
new file mode 100644
index 00000000..08735a00
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/AppDelegate.m
@@ -0,0 +1,48 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#import "AppDelegate.h"
+
+@interface AppDelegate ()
+
+@property (weak) IBOutlet NSWindow *window;
+@end
+
+@implementation AppDelegate
+
+- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
+ // Insert code here to initialize your application
+}
+
+- (void)applicationWillTerminate:(NSNotification *)aNotification {
+ // Insert code here to tear down your application
+}
+
+@end
diff --git a/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Assets.xcassets/AppIcon.appiconset/Contents.json b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Assets.xcassets/AppIcon.appiconset/Contents.json
new file mode 100644
index 00000000..2db2b1c7
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Assets.xcassets/AppIcon.appiconset/Contents.json
@@ -0,0 +1,58 @@
+{
+ "images" : [
+ {
+ "idiom" : "mac",
+ "size" : "16x16",
+ "scale" : "1x"
+ },
+ {
+ "idiom" : "mac",
+ "size" : "16x16",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "mac",
+ "size" : "32x32",
+ "scale" : "1x"
+ },
+ {
+ "idiom" : "mac",
+ "size" : "32x32",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "mac",
+ "size" : "128x128",
+ "scale" : "1x"
+ },
+ {
+ "idiom" : "mac",
+ "size" : "128x128",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "mac",
+ "size" : "256x256",
+ "scale" : "1x"
+ },
+ {
+ "idiom" : "mac",
+ "size" : "256x256",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "mac",
+ "size" : "512x512",
+ "scale" : "1x"
+ },
+ {
+ "idiom" : "mac",
+ "size" : "512x512",
+ "scale" : "2x"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+} \ No newline at end of file
diff --git a/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Base.lproj/MainMenu.xib b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Base.lproj/MainMenu.xib
new file mode 100644
index 00000000..aa3547ca
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Base.lproj/MainMenu.xib
@@ -0,0 +1,680 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6233" systemVersion="14A329f" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+ <dependencies>
+ <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6233"/>
+ </dependencies>
+ <objects>
+ <customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
+ <connections>
+ <outlet property="delegate" destination="Voe-Tx-rLC" id="GzC-gU-4Uq"/>
+ </connections>
+ </customObject>
+ <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
+ <customObject id="-3" userLabel="Application" customClass="NSObject"/>
+ <customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModuleProvider="">
+ <connections>
+ <outlet property="window" destination="QvC-M9-y7g" id="gIp-Ho-8D9"/>
+ </connections>
+ </customObject>
+ <customObject id="YLy-65-1bz" customClass="NSFontManager"/>
+ <menu title="Main Menu" systemMenu="main" id="AYu-sK-qS6">
+ <items>
+ <menuItem title="OSXCocoaPodsTester" id="1Xt-HY-uBw">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="OSXCocoaPodsTester" systemMenu="apple" id="uQy-DD-JDr">
+ <items>
+ <menuItem title="About OSXCocoaPodsTester" id="5kV-Vb-QxS">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="orderFrontStandardAboutPanel:" target="-1" id="Exp-CZ-Vem"/>
+ </connections>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="VOq-y0-SEH"/>
+ <menuItem title="Preferences…" keyEquivalent="," id="BOF-NM-1cW"/>
+ <menuItem isSeparatorItem="YES" id="wFC-TO-SCJ"/>
+ <menuItem title="Services" id="NMo-om-nkz">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Services" systemMenu="services" id="hz9-B4-Xy5"/>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="4je-JR-u6R"/>
+ <menuItem title="Hide OSXCocoaPodsTester" keyEquivalent="h" id="Olw-nP-bQN">
+ <connections>
+ <action selector="hide:" target="-1" id="PnN-Uc-m68"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Hide Others" keyEquivalent="h" id="Vdr-fp-XzO">
+ <modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
+ <connections>
+ <action selector="hideOtherApplications:" target="-1" id="VT4-aY-XCT"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Show All" id="Kd2-mp-pUS">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="unhideAllApplications:" target="-1" id="Dhg-Le-xox"/>
+ </connections>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="kCx-OE-vgT"/>
+ <menuItem title="Quit OSXCocoaPodsTester" keyEquivalent="q" id="4sb-4s-VLi">
+ <connections>
+ <action selector="terminate:" target="-1" id="Te7-pn-YzF"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem title="File" id="dMs-cI-mzQ">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="File" id="bib-Uj-vzu">
+ <items>
+ <menuItem title="New" keyEquivalent="n" id="Was-JA-tGl">
+ <connections>
+ <action selector="newDocument:" target="-1" id="4Si-XN-c54"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Open…" keyEquivalent="o" id="IAo-SY-fd9">
+ <connections>
+ <action selector="openDocument:" target="-1" id="bVn-NM-KNZ"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Open Recent" id="tXI-mr-wws">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Open Recent" systemMenu="recentDocuments" id="oas-Oc-fiZ">
+ <items>
+ <menuItem title="Clear Menu" id="vNY-rz-j42">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="clearRecentDocuments:" target="-1" id="Daa-9d-B3U"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="m54-Is-iLE"/>
+ <menuItem title="Close" keyEquivalent="w" id="DVo-aG-piG">
+ <connections>
+ <action selector="performClose:" target="-1" id="HmO-Ls-i7Q"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Save…" keyEquivalent="s" id="pxx-59-PXV">
+ <connections>
+ <action selector="saveDocument:" target="-1" id="teZ-XB-qJY"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Save As…" keyEquivalent="S" id="Bw7-FT-i3A">
+ <connections>
+ <action selector="saveDocumentAs:" target="-1" id="mDf-zr-I0C"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Revert to Saved" id="KaW-ft-85H">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="revertDocumentToSaved:" target="-1" id="iJ3-Pv-kwq"/>
+ </connections>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="aJh-i4-bef"/>
+ <menuItem title="Page Setup…" keyEquivalent="P" id="qIS-W8-SiK">
+ <modifierMask key="keyEquivalentModifierMask" shift="YES" command="YES"/>
+ <connections>
+ <action selector="runPageLayout:" target="-1" id="Din-rz-gC5"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Print…" keyEquivalent="p" id="aTl-1u-JFS">
+ <connections>
+ <action selector="print:" target="-1" id="qaZ-4w-aoO"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem title="Edit" id="5QF-Oa-p0T">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Edit" id="W48-6f-4Dl">
+ <items>
+ <menuItem title="Undo" keyEquivalent="z" id="dRJ-4n-Yzg">
+ <connections>
+ <action selector="undo:" target="-1" id="M6e-cu-g7V"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Redo" keyEquivalent="Z" id="6dh-zS-Vam">
+ <connections>
+ <action selector="redo:" target="-1" id="oIA-Rs-6OD"/>
+ </connections>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="WRV-NI-Exz"/>
+ <menuItem title="Cut" keyEquivalent="x" id="uRl-iY-unG">
+ <connections>
+ <action selector="cut:" target="-1" id="YJe-68-I9s"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Copy" keyEquivalent="c" id="x3v-GG-iWU">
+ <connections>
+ <action selector="copy:" target="-1" id="G1f-GL-Joy"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Paste" keyEquivalent="v" id="gVA-U4-sdL">
+ <connections>
+ <action selector="paste:" target="-1" id="UvS-8e-Qdg"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Paste and Match Style" keyEquivalent="V" id="WeT-3V-zwk">
+ <modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
+ <connections>
+ <action selector="pasteAsPlainText:" target="-1" id="cEh-KX-wJQ"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Delete" id="pa3-QI-u2k">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="delete:" target="-1" id="0Mk-Ml-PaM"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Select All" keyEquivalent="a" id="Ruw-6m-B2m">
+ <connections>
+ <action selector="selectAll:" target="-1" id="VNm-Mi-diN"/>
+ </connections>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="uyl-h8-XO2"/>
+ <menuItem title="Find" id="4EN-yA-p0u">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Find" id="1b7-l0-nxx">
+ <items>
+ <menuItem title="Find…" tag="1" keyEquivalent="f" id="Xz5-n4-O0W">
+ <connections>
+ <action selector="performFindPanelAction:" target="-1" id="cD7-Qs-BN4"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Find and Replace…" tag="12" keyEquivalent="f" id="YEy-JH-Tfz">
+ <modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
+ <connections>
+ <action selector="performFindPanelAction:" target="-1" id="WD3-Gg-5AJ"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Find Next" tag="2" keyEquivalent="g" id="q09-fT-Sye">
+ <connections>
+ <action selector="performFindPanelAction:" target="-1" id="NDo-RZ-v9R"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Find Previous" tag="3" keyEquivalent="G" id="OwM-mh-QMV">
+ <connections>
+ <action selector="performFindPanelAction:" target="-1" id="HOh-sY-3ay"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Use Selection for Find" tag="7" keyEquivalent="e" id="buJ-ug-pKt">
+ <connections>
+ <action selector="performFindPanelAction:" target="-1" id="U76-nv-p5D"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Jump to Selection" keyEquivalent="j" id="S0p-oC-mLd">
+ <connections>
+ <action selector="centerSelectionInVisibleArea:" target="-1" id="IOG-6D-g5B"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem title="Spelling and Grammar" id="Dv1-io-Yv7">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Spelling" id="3IN-sU-3Bg">
+ <items>
+ <menuItem title="Show Spelling and Grammar" keyEquivalent=":" id="HFo-cy-zxI">
+ <connections>
+ <action selector="showGuessPanel:" target="-1" id="vFj-Ks-hy3"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Check Document Now" keyEquivalent=";" id="hz2-CU-CR7">
+ <connections>
+ <action selector="checkSpelling:" target="-1" id="fz7-VC-reM"/>
+ </connections>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="bNw-od-mp5"/>
+ <menuItem title="Check Spelling While Typing" id="rbD-Rh-wIN">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="toggleContinuousSpellChecking:" target="-1" id="7w6-Qz-0kB"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Check Grammar With Spelling" id="mK6-2p-4JG">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="toggleGrammarChecking:" target="-1" id="muD-Qn-j4w"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Correct Spelling Automatically" id="78Y-hA-62v">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="toggleAutomaticSpellingCorrection:" target="-1" id="2lM-Qi-WAP"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem title="Substitutions" id="9ic-FL-obx">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Substitutions" id="FeM-D8-WVr">
+ <items>
+ <menuItem title="Show Substitutions" id="z6F-FW-3nz">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="orderFrontSubstitutionsPanel:" target="-1" id="oku-mr-iSq"/>
+ </connections>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="gPx-C9-uUO"/>
+ <menuItem title="Smart Copy/Paste" id="9yt-4B-nSM">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="toggleSmartInsertDelete:" target="-1" id="3IJ-Se-DZD"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Smart Quotes" id="hQb-2v-fYv">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="toggleAutomaticQuoteSubstitution:" target="-1" id="ptq-xd-QOA"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Smart Dashes" id="rgM-f4-ycn">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="toggleAutomaticDashSubstitution:" target="-1" id="oCt-pO-9gS"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Smart Links" id="cwL-P1-jid">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="toggleAutomaticLinkDetection:" target="-1" id="Gip-E3-Fov"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Data Detectors" id="tRr-pd-1PS">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="toggleAutomaticDataDetection:" target="-1" id="R1I-Nq-Kbl"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Text Replacement" id="HFQ-gK-NFA">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="toggleAutomaticTextReplacement:" target="-1" id="DvP-Fe-Py6"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem title="Transformations" id="2oI-Rn-ZJC">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Transformations" id="c8a-y6-VQd">
+ <items>
+ <menuItem title="Make Upper Case" id="vmV-6d-7jI">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="uppercaseWord:" target="-1" id="sPh-Tk-edu"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Make Lower Case" id="d9M-CD-aMd">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="lowercaseWord:" target="-1" id="iUZ-b5-hil"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Capitalize" id="UEZ-Bs-lqG">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="capitalizeWord:" target="-1" id="26H-TL-nsh"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem title="Speech" id="xrE-MZ-jX0">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Speech" id="3rS-ZA-NoH">
+ <items>
+ <menuItem title="Start Speaking" id="Ynk-f8-cLZ">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="startSpeaking:" target="-1" id="654-Ng-kyl"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Stop Speaking" id="Oyz-dy-DGm">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="stopSpeaking:" target="-1" id="dX8-6p-jy9"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem title="Format" id="jxT-CU-nIS">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Format" id="GEO-Iw-cKr">
+ <items>
+ <menuItem title="Font" id="Gi5-1S-RQB">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Font" systemMenu="font" id="aXa-aM-Jaq">
+ <items>
+ <menuItem title="Show Fonts" keyEquivalent="t" id="Q5e-8K-NDq">
+ <connections>
+ <action selector="orderFrontFontPanel:" target="YLy-65-1bz" id="WHr-nq-2xA"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Bold" tag="2" keyEquivalent="b" id="GB9-OM-e27">
+ <connections>
+ <action selector="addFontTrait:" target="YLy-65-1bz" id="hqk-hr-sYV"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Italic" tag="1" keyEquivalent="i" id="Vjx-xi-njq">
+ <connections>
+ <action selector="addFontTrait:" target="YLy-65-1bz" id="IHV-OB-c03"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Underline" keyEquivalent="u" id="WRG-CD-K1S">
+ <connections>
+ <action selector="underline:" target="-1" id="FYS-2b-JAY"/>
+ </connections>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="5gT-KC-WSO"/>
+ <menuItem title="Bigger" tag="3" keyEquivalent="+" id="Ptp-SP-VEL">
+ <connections>
+ <action selector="modifyFont:" target="YLy-65-1bz" id="Uc7-di-UnL"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Smaller" tag="4" keyEquivalent="-" id="i1d-Er-qST">
+ <connections>
+ <action selector="modifyFont:" target="YLy-65-1bz" id="HcX-Lf-eNd"/>
+ </connections>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="kx3-Dk-x3B"/>
+ <menuItem title="Kern" id="jBQ-r6-VK2">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Kern" id="tlD-Oa-oAM">
+ <items>
+ <menuItem title="Use Default" id="GUa-eO-cwY">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="useStandardKerning:" target="-1" id="6dk-9l-Ckg"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Use None" id="cDB-IK-hbR">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="turnOffKerning:" target="-1" id="U8a-gz-Maa"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Tighten" id="46P-cB-AYj">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="tightenKerning:" target="-1" id="hr7-Nz-8ro"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Loosen" id="ogc-rX-tC1">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="loosenKerning:" target="-1" id="8i4-f9-FKE"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem title="Ligatures" id="o6e-r0-MWq">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Ligatures" id="w0m-vy-SC9">
+ <items>
+ <menuItem title="Use Default" id="agt-UL-0e3">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="useStandardLigatures:" target="-1" id="7uR-wd-Dx6"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Use None" id="J7y-lM-qPV">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="turnOffLigatures:" target="-1" id="iX2-gA-Ilz"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Use All" id="xQD-1f-W4t">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="useAllLigatures:" target="-1" id="KcB-kA-TuK"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem title="Baseline" id="OaQ-X3-Vso">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Baseline" id="ijk-EB-dga">
+ <items>
+ <menuItem title="Use Default" id="3Om-Ey-2VK">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="unscript:" target="-1" id="0vZ-95-Ywn"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Superscript" id="Rqc-34-cIF">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="superscript:" target="-1" id="3qV-fo-wpU"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Subscript" id="I0S-gh-46l">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="subscript:" target="-1" id="Q6W-4W-IGz"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Raise" id="2h7-ER-AoG">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="raiseBaseline:" target="-1" id="4sk-31-7Q9"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Lower" id="1tx-W0-xDw">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="lowerBaseline:" target="-1" id="OF1-bc-KW4"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="Ndw-q3-faq"/>
+ <menuItem title="Show Colors" keyEquivalent="C" id="bgn-CT-cEk">
+ <connections>
+ <action selector="orderFrontColorPanel:" target="-1" id="mSX-Xz-DV3"/>
+ </connections>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="iMs-zA-UFJ"/>
+ <menuItem title="Copy Style" keyEquivalent="c" id="5Vv-lz-BsD">
+ <modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
+ <connections>
+ <action selector="copyFont:" target="-1" id="GJO-xA-L4q"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Paste Style" keyEquivalent="v" id="vKC-jM-MkH">
+ <modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
+ <connections>
+ <action selector="pasteFont:" target="-1" id="JfD-CL-leO"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem title="Text" id="Fal-I4-PZk">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Text" id="d9c-me-L2H">
+ <items>
+ <menuItem title="Align Left" keyEquivalent="{" id="ZM1-6Q-yy1">
+ <connections>
+ <action selector="alignLeft:" target="-1" id="zUv-R1-uAa"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Center" keyEquivalent="|" id="VIY-Ag-zcb">
+ <connections>
+ <action selector="alignCenter:" target="-1" id="spX-mk-kcS"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Justify" id="J5U-5w-g23">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="alignJustified:" target="-1" id="ljL-7U-jND"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Align Right" keyEquivalent="}" id="wb2-vD-lq4">
+ <connections>
+ <action selector="alignRight:" target="-1" id="r48-bG-YeY"/>
+ </connections>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="4s2-GY-VfK"/>
+ <menuItem title="Writing Direction" id="H1b-Si-o9J">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Writing Direction" id="8mr-sm-Yjd">
+ <items>
+ <menuItem title="Paragraph" enabled="NO" id="ZvO-Gk-QUH">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ </menuItem>
+ <menuItem id="YGs-j5-SAR">
+ <string key="title"> Default</string>
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="makeBaseWritingDirectionNatural:" target="-1" id="qtV-5e-UBP"/>
+ </connections>
+ </menuItem>
+ <menuItem id="Lbh-J2-qVU">
+ <string key="title"> Left to Right</string>
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="makeBaseWritingDirectionLeftToRight:" target="-1" id="S0X-9S-QSf"/>
+ </connections>
+ </menuItem>
+ <menuItem id="jFq-tB-4Kx">
+ <string key="title"> Right to Left</string>
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="makeBaseWritingDirectionRightToLeft:" target="-1" id="5fk-qB-AqJ"/>
+ </connections>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="swp-gr-a21"/>
+ <menuItem title="Selection" enabled="NO" id="cqv-fj-IhA">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ </menuItem>
+ <menuItem id="Nop-cj-93Q">
+ <string key="title"> Default</string>
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="makeTextWritingDirectionNatural:" target="-1" id="lPI-Se-ZHp"/>
+ </connections>
+ </menuItem>
+ <menuItem id="BgM-ve-c93">
+ <string key="title"> Left to Right</string>
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="makeTextWritingDirectionLeftToRight:" target="-1" id="caW-Bv-w94"/>
+ </connections>
+ </menuItem>
+ <menuItem id="RB4-Sm-HuC">
+ <string key="title"> Right to Left</string>
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="makeTextWritingDirectionRightToLeft:" target="-1" id="EXD-6r-ZUu"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="fKy-g9-1gm"/>
+ <menuItem title="Show Ruler" id="vLm-3I-IUL">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="toggleRuler:" target="-1" id="FOx-HJ-KwY"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Copy Ruler" keyEquivalent="c" id="MkV-Pr-PK5">
+ <modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
+ <connections>
+ <action selector="copyRuler:" target="-1" id="71i-fW-3W2"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Paste Ruler" keyEquivalent="v" id="LVM-kO-fVI">
+ <modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
+ <connections>
+ <action selector="pasteRuler:" target="-1" id="cSh-wd-qM2"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem title="View" id="H8h-7b-M4v">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="View" id="HyV-fh-RgO">
+ <items>
+ <menuItem title="Show Toolbar" keyEquivalent="t" id="snW-S8-Cw5">
+ <modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
+ <connections>
+ <action selector="toggleToolbarShown:" target="-1" id="BXY-wc-z0C"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Customize Toolbar…" id="1UK-8n-QPP">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="runToolbarCustomizationPalette:" target="-1" id="pQI-g3-MTW"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem title="Window" id="aUF-d1-5bR">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Window" systemMenu="window" id="Td7-aD-5lo">
+ <items>
+ <menuItem title="Minimize" keyEquivalent="m" id="OY7-WF-poV">
+ <connections>
+ <action selector="performMiniaturize:" target="-1" id="VwT-WD-YPe"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Zoom" id="R4o-n2-Eq4">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="performZoom:" target="-1" id="DIl-cC-cCs"/>
+ </connections>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="eu3-7i-yIM"/>
+ <menuItem title="Bring All to Front" id="LE2-aR-0XJ">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="arrangeInFront:" target="-1" id="DRN-fu-gQh"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem title="Help" id="wpr-3q-Mcd">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="Help" systemMenu="help" id="F2S-fz-NVQ">
+ <items>
+ <menuItem title="OSXCocoaPodsTester Help" keyEquivalent="?" id="FKE-Sm-Kum">
+ <connections>
+ <action selector="showHelp:" target="-1" id="y7X-2Q-9no"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ </items>
+ </menu>
+ <window title="OSXCocoaPodsTester" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g">
+ <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
+ <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
+ <rect key="contentRect" x="335" y="390" width="480" height="360"/>
+ <rect key="screenRect" x="0.0" y="0.0" width="1920" height="1177"/>
+ <view key="contentView" id="EiT-Mj-1SZ">
+ <rect key="frame" x="0.0" y="0.0" width="480" height="360"/>
+ <autoresizingMask key="autoresizingMask"/>
+ </view>
+ </window>
+ </objects>
+</document>
diff --git a/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Info.plist b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Info.plist
new file mode 100644
index 00000000..ed806e40
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Info.plist
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>en</string>
+ <key>CFBundleExecutable</key>
+ <string>$(EXECUTABLE_NAME)</string>
+ <key>CFBundleIconFile</key>
+ <string></string>
+ <key>CFBundleIdentifier</key>
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>$(PRODUCT_NAME)</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+ <key>LSMinimumSystemVersion</key>
+ <string>$(MACOSX_DEPLOYMENT_TARGET)</string>
+ <key>NSHumanReadableCopyright</key>
+ <string>Copyright © 2016 Google. All rights reserved.</string>
+ <key>NSMainNibFile</key>
+ <string>MainMenu</string>
+ <key>NSPrincipalClass</key>
+ <string>NSApplication</string>
+</dict>
+</plist>
diff --git a/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/main.m b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/main.m
new file mode 100644
index 00000000..b230090e
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/main.m
@@ -0,0 +1,35 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#import <Cocoa/Cocoa.h>
+
+int main(int argc, const char * argv[]) {
+ return NSApplicationMain(argc, argv);
+}
diff --git a/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/Podfile-framework b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/Podfile-framework
new file mode 100644
index 00000000..27eeafc9
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/Podfile-framework
@@ -0,0 +1,10 @@
+source 'https://github.com/CocoaPods/Specs.git'
+platform :osx, '10.9'
+
+install! 'cocoapods', :deterministic_uuids => false
+
+use_frameworks!
+
+target 'OSXCocoaPodsTester' do
+ pod 'Protobuf', :path => '../../../..'
+end
diff --git a/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/Podfile-static b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/Podfile-static
new file mode 100644
index 00000000..5dfc8de5
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/Podfile-static
@@ -0,0 +1,8 @@
+source 'https://github.com/CocoaPods/Specs.git'
+platform :osx, '10.9'
+
+install! 'cocoapods', :deterministic_uuids => false
+
+target 'OSXCocoaPodsTester' do
+ pod 'Protobuf', :path => '../../../..'
+end
diff --git a/objectivec/Tests/CocoaPods/README.md b/objectivec/Tests/CocoaPods/README.md
new file mode 100644
index 00000000..08785918
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/README.md
@@ -0,0 +1,9 @@
+CocoaPods Protocol Buffers Integration Tests
+============================================
+
+The sub directories are the basic projects as created by Xcode 6.3. They are
+used to then drive `pod` and `xcodebuild` to ensure things integrate/build
+as expected.
+
+`run_tests.sh` defaults to running all the tests, invoke it with `--help` to
+see the arguments to control what tests are run.
diff --git a/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/Podfile-framework b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/Podfile-framework
new file mode 100644
index 00000000..913a289b
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/Podfile-framework
@@ -0,0 +1,10 @@
+source 'https://github.com/CocoaPods/Specs.git'
+platform :ios, '8.0'
+
+install! 'cocoapods', :deterministic_uuids => false
+
+use_frameworks!
+
+target 'iOSCocoaPodsTester' do
+ pod 'Protobuf', :path => '../../../..'
+end
diff --git a/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/Podfile-static b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/Podfile-static
new file mode 100644
index 00000000..e9b3c235
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/Podfile-static
@@ -0,0 +1,8 @@
+source 'https://github.com/CocoaPods/Specs.git'
+platform :ios, '8.0'
+
+install! 'cocoapods', :deterministic_uuids => false
+
+target 'iOSCocoaPodsTester' do
+ pod 'Protobuf', :path => '../../../..'
+end
diff --git a/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/project.pbxproj b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/project.pbxproj
new file mode 100644
index 00000000..27fb553f
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/project.pbxproj
@@ -0,0 +1,309 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ F4D5A08B1CEE01E200562D79 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F4D5A08A1CEE01E200562D79 /* main.m */; };
+ F4D5A08E1CEE01E200562D79 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F4D5A08D1CEE01E200562D79 /* AppDelegate.m */; };
+ F4D5A0911CEE01E200562D79 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F4D5A0901CEE01E200562D79 /* ViewController.m */; };
+ F4D5A0941CEE01E200562D79 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F4D5A0921CEE01E200562D79 /* Main.storyboard */; };
+ F4D5A0961CEE01E200562D79 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F4D5A0951CEE01E200562D79 /* Assets.xcassets */; };
+ F4D5A0991CEE01E200562D79 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F4D5A0971CEE01E200562D79 /* LaunchScreen.storyboard */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ F4D5A0861CEE01E200562D79 /* iOSCocoaPodsTester.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iOSCocoaPodsTester.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ F4D5A08A1CEE01E200562D79 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
+ F4D5A08C1CEE01E200562D79 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
+ F4D5A08D1CEE01E200562D79 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
+ F4D5A08F1CEE01E200562D79 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
+ F4D5A0901CEE01E200562D79 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
+ F4D5A0931CEE01E200562D79 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
+ F4D5A0951CEE01E200562D79 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
+ F4D5A0981CEE01E200562D79 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
+ F4D5A09A1CEE01E200562D79 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ F4D5A0831CEE01E200562D79 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ F4D5A07D1CEE01E200562D79 = {
+ isa = PBXGroup;
+ children = (
+ F4D5A0881CEE01E200562D79 /* iOSCocoaPodsTester */,
+ F4D5A0871CEE01E200562D79 /* Products */,
+ );
+ sourceTree = "<group>";
+ };
+ F4D5A0871CEE01E200562D79 /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ F4D5A0861CEE01E200562D79 /* iOSCocoaPodsTester.app */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ F4D5A0881CEE01E200562D79 /* iOSCocoaPodsTester */ = {
+ isa = PBXGroup;
+ children = (
+ F4D5A08C1CEE01E200562D79 /* AppDelegate.h */,
+ F4D5A08D1CEE01E200562D79 /* AppDelegate.m */,
+ F4D5A08F1CEE01E200562D79 /* ViewController.h */,
+ F4D5A0901CEE01E200562D79 /* ViewController.m */,
+ F4D5A0921CEE01E200562D79 /* Main.storyboard */,
+ F4D5A0951CEE01E200562D79 /* Assets.xcassets */,
+ F4D5A0971CEE01E200562D79 /* LaunchScreen.storyboard */,
+ F4D5A09A1CEE01E200562D79 /* Info.plist */,
+ F4D5A0891CEE01E200562D79 /* Supporting Files */,
+ );
+ path = iOSCocoaPodsTester;
+ sourceTree = "<group>";
+ };
+ F4D5A0891CEE01E200562D79 /* Supporting Files */ = {
+ isa = PBXGroup;
+ children = (
+ F4D5A08A1CEE01E200562D79 /* main.m */,
+ );
+ name = "Supporting Files";
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ F4D5A0851CEE01E200562D79 /* iOSCocoaPodsTester */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = F4D5A09D1CEE01E200562D79 /* Build configuration list for PBXNativeTarget "iOSCocoaPodsTester" */;
+ buildPhases = (
+ F4D5A0821CEE01E200562D79 /* Sources */,
+ F4D5A0831CEE01E200562D79 /* Frameworks */,
+ F4D5A0841CEE01E200562D79 /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = iOSCocoaPodsTester;
+ productName = iOSCocoaPodsTester;
+ productReference = F4D5A0861CEE01E200562D79 /* iOSCocoaPodsTester.app */;
+ productType = "com.apple.product-type.application";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ F4D5A07E1CEE01E200562D79 /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0730;
+ ORGANIZATIONNAME = Google;
+ TargetAttributes = {
+ F4D5A0851CEE01E200562D79 = {
+ CreatedOnToolsVersion = 7.3.1;
+ };
+ };
+ };
+ buildConfigurationList = F4D5A0811CEE01E200562D79 /* Build configuration list for PBXProject "iOSCocoaPodsTester" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ Base,
+ );
+ mainGroup = F4D5A07D1CEE01E200562D79;
+ productRefGroup = F4D5A0871CEE01E200562D79 /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ F4D5A0851CEE01E200562D79 /* iOSCocoaPodsTester */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ F4D5A0841CEE01E200562D79 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ F4D5A0991CEE01E200562D79 /* LaunchScreen.storyboard in Resources */,
+ F4D5A0961CEE01E200562D79 /* Assets.xcassets in Resources */,
+ F4D5A0941CEE01E200562D79 /* Main.storyboard in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ F4D5A0821CEE01E200562D79 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ F4D5A0911CEE01E200562D79 /* ViewController.m in Sources */,
+ F4D5A08E1CEE01E200562D79 /* AppDelegate.m in Sources */,
+ F4D5A08B1CEE01E200562D79 /* main.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXVariantGroup section */
+ F4D5A0921CEE01E200562D79 /* Main.storyboard */ = {
+ isa = PBXVariantGroup;
+ children = (
+ F4D5A0931CEE01E200562D79 /* Base */,
+ );
+ name = Main.storyboard;
+ sourceTree = "<group>";
+ };
+ F4D5A0971CEE01E200562D79 /* LaunchScreen.storyboard */ = {
+ isa = PBXVariantGroup;
+ children = (
+ F4D5A0981CEE01E200562D79 /* Base */,
+ );
+ name = LaunchScreen.storyboard;
+ sourceTree = "<group>";
+ };
+/* End PBXVariantGroup section */
+
+/* Begin XCBuildConfiguration section */
+ F4D5A09B1CEE01E200562D79 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = dwarf;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ ENABLE_TESTABILITY = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 9.3;
+ MTL_ENABLE_DEBUG_INFO = YES;
+ ONLY_ACTIVE_ARCH = YES;
+ SDKROOT = iphoneos;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Debug;
+ };
+ F4D5A09C1CEE01E200562D79 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ ENABLE_NS_ASSERTIONS = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 9.3;
+ MTL_ENABLE_DEBUG_INFO = NO;
+ SDKROOT = iphoneos;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Release;
+ };
+ F4D5A09E1CEE01E200562D79 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ INFOPLIST_FILE = iOSCocoaPodsTester/Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = com.google.iOSCocoaPodsTester;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Debug;
+ };
+ F4D5A09F1CEE01E200562D79 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ INFOPLIST_FILE = iOSCocoaPodsTester/Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = com.google.iOSCocoaPodsTester;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ F4D5A0811CEE01E200562D79 /* Build configuration list for PBXProject "iOSCocoaPodsTester" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ F4D5A09B1CEE01E200562D79 /* Debug */,
+ F4D5A09C1CEE01E200562D79 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ F4D5A09D1CEE01E200562D79 /* Build configuration list for PBXNativeTarget "iOSCocoaPodsTester" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ F4D5A09E1CEE01E200562D79 /* Debug */,
+ F4D5A09F1CEE01E200562D79 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = F4D5A07E1CEE01E200562D79 /* Project object */;
+}
diff --git a/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/project.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 00000000..008f7b4a
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Workspace
+ version = "1.0">
+ <FileRef
+ location = "self:iOSCocoaPodsTester.xcodeproj">
+ </FileRef>
+</Workspace>
diff --git a/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/xcshareddata/xcschemes/iOSCocoaPodsTester.xcscheme b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/xcshareddata/xcschemes/iOSCocoaPodsTester.xcscheme
new file mode 100644
index 00000000..9558dd7a
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/xcshareddata/xcschemes/iOSCocoaPodsTester.xcscheme
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+ LastUpgradeVersion = "0730"
+ version = "1.3">
+ <BuildAction
+ parallelizeBuildables = "YES"
+ buildImplicitDependencies = "YES">
+ <BuildActionEntries>
+ <BuildActionEntry
+ buildForTesting = "YES"
+ buildForRunning = "YES"
+ buildForProfiling = "YES"
+ buildForArchiving = "YES"
+ buildForAnalyzing = "YES">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "F4D5A0851CEE01E200562D79"
+ BuildableName = "iOSCocoaPodsTester.app"
+ BlueprintName = "iOSCocoaPodsTester"
+ ReferencedContainer = "container:iOSCocoaPodsTester.xcodeproj">
+ </BuildableReference>
+ </BuildActionEntry>
+ </BuildActionEntries>
+ </BuildAction>
+ <TestAction
+ buildConfiguration = "Debug"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ shouldUseLaunchSchemeArgsEnv = "YES">
+ <Testables>
+ </Testables>
+ <MacroExpansion>
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "F4D5A0851CEE01E200562D79"
+ BuildableName = "iOSCocoaPodsTester.app"
+ BlueprintName = "iOSCocoaPodsTester"
+ ReferencedContainer = "container:iOSCocoaPodsTester.xcodeproj">
+ </BuildableReference>
+ </MacroExpansion>
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </TestAction>
+ <LaunchAction
+ buildConfiguration = "Debug"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ launchStyle = "0"
+ useCustomWorkingDirectory = "NO"
+ ignoresPersistentStateOnLaunch = "NO"
+ debugDocumentVersioning = "YES"
+ debugServiceExtension = "internal"
+ allowLocationSimulation = "YES">
+ <BuildableProductRunnable
+ runnableDebuggingMode = "0">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "F4D5A0851CEE01E200562D79"
+ BuildableName = "iOSCocoaPodsTester.app"
+ BlueprintName = "iOSCocoaPodsTester"
+ ReferencedContainer = "container:iOSCocoaPodsTester.xcodeproj">
+ </BuildableReference>
+ </BuildableProductRunnable>
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </LaunchAction>
+ <ProfileAction
+ buildConfiguration = "Release"
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ savedToolIdentifier = ""
+ useCustomWorkingDirectory = "NO"
+ debugDocumentVersioning = "YES">
+ <BuildableProductRunnable
+ runnableDebuggingMode = "0">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "F4D5A0851CEE01E200562D79"
+ BuildableName = "iOSCocoaPodsTester.app"
+ BlueprintName = "iOSCocoaPodsTester"
+ ReferencedContainer = "container:iOSCocoaPodsTester.xcodeproj">
+ </BuildableReference>
+ </BuildableProductRunnable>
+ </ProfileAction>
+ <AnalyzeAction
+ buildConfiguration = "Debug">
+ </AnalyzeAction>
+ <ArchiveAction
+ buildConfiguration = "Release"
+ revealArchiveInOrganizer = "YES">
+ </ArchiveAction>
+</Scheme>
diff --git a/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/AppDelegate.h b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/AppDelegate.h
new file mode 100644
index 00000000..5eca690c
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/AppDelegate.h
@@ -0,0 +1,39 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#import <UIKit/UIKit.h>
+
+@interface AppDelegate : UIResponder <UIApplicationDelegate>
+
+@property (strong, nonatomic) UIWindow *window;
+
+
+@end
+
diff --git a/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/AppDelegate.m b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/AppDelegate.m
new file mode 100644
index 00000000..dd7b969a
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/AppDelegate.m
@@ -0,0 +1,67 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#import "AppDelegate.h"
+
+@interface AppDelegate ()
+
+@end
+
+@implementation AppDelegate
+
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
+ // Override point for customization after application launch.
+ return YES;
+}
+
+- (void)applicationWillResignActive:(UIApplication *)application {
+ // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
+ // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
+}
+
+- (void)applicationDidEnterBackground:(UIApplication *)application {
+ // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
+ // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
+}
+
+- (void)applicationWillEnterForeground:(UIApplication *)application {
+ // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
+}
+
+- (void)applicationDidBecomeActive:(UIApplication *)application {
+ // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
+}
+
+- (void)applicationWillTerminate:(UIApplication *)application {
+ // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
+}
+
+@end
diff --git a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/Contents.json b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Assets.xcassets/AppIcon.appiconset/Contents.json
index 0cbf9acc..36d2c80d 100644
--- a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/Contents.json
+++ b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Assets.xcassets/AppIcon.appiconset/Contents.json
@@ -3,11 +3,6 @@
{
"idiom" : "iphone",
"size" : "29x29",
- "scale" : "1x"
- },
- {
- "idiom" : "iphone",
- "size" : "29x29",
"scale" : "2x"
},
{
@@ -26,27 +21,13 @@
"scale" : "3x"
},
{
- "size" : "57x57",
- "idiom" : "iphone",
- "filename" : "iPhone6.png",
- "scale" : "1x"
- },
- {
- "size" : "57x57",
"idiom" : "iphone",
- "filename" : "iPhone6_2x.png",
- "scale" : "2x"
- },
- {
"size" : "60x60",
- "idiom" : "iphone",
- "filename" : "iPhone7_2x.png",
"scale" : "2x"
},
{
- "size" : "60x60",
"idiom" : "iphone",
- "filename" : "iPhone7_3x.png",
+ "size" : "60x60",
"scale" : "3x"
},
{
@@ -71,46 +52,17 @@
},
{
"idiom" : "ipad",
- "size" : "50x50",
- "scale" : "1x"
- },
- {
- "idiom" : "ipad",
- "size" : "50x50",
- "scale" : "2x"
- },
- {
- "size" : "72x72",
- "idiom" : "ipad",
- "filename" : "iPad6.png",
- "scale" : "1x"
- },
- {
- "size" : "72x72",
- "idiom" : "ipad",
- "filename" : "iPad6_2x.png",
- "scale" : "2x"
- },
- {
"size" : "76x76",
- "idiom" : "ipad",
- "filename" : "iPad7.png",
"scale" : "1x"
},
{
- "size" : "76x76",
"idiom" : "ipad",
- "filename" : "iPad7_2x.png",
+ "size" : "76x76",
"scale" : "2x"
- },
- {
- "idiom" : "car",
- "size" : "120x120",
- "scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
-}
+} \ No newline at end of file
diff --git a/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Base.lproj/LaunchScreen.storyboard b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Base.lproj/LaunchScreen.storyboard
new file mode 100644
index 00000000..2e721e18
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Base.lproj/LaunchScreen.storyboard
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8150" systemVersion="15A204g" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
+ <dependencies>
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8122"/>
+ </dependencies>
+ <scenes>
+ <!--View Controller-->
+ <scene sceneID="EHf-IW-A2E">
+ <objects>
+ <viewController id="01J-lp-oVM" sceneMemberID="viewController">
+ <layoutGuides>
+ <viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
+ <viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
+ </layoutGuides>
+ <view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
+ <rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+ <animations/>
+ <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
+ </view>
+ </viewController>
+ <placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
+ </objects>
+ <point key="canvasLocation" x="53" y="375"/>
+ </scene>
+ </scenes>
+</document>
diff --git a/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Base.lproj/Main.storyboard b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Base.lproj/Main.storyboard
new file mode 100644
index 00000000..82cd159a
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Base.lproj/Main.storyboard
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
+ <dependencies>
+ <deployment identifier="iOS"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
+ </dependencies>
+ <scenes>
+ <!--View Controller-->
+ <scene sceneID="tne-QT-ifu">
+ <objects>
+ <viewController id="BYZ-38-t0r" customClass="ViewController" sceneMemberID="viewController">
+ <layoutGuides>
+ <viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
+ <viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
+ </layoutGuides>
+ <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
+ <rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+ <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
+ </view>
+ </viewController>
+ <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
+ </objects>
+ </scene>
+ </scenes>
+</document>
diff --git a/objectivec/Tests/iOSTestHarness/Info.plist b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Info.plist
index 24bd333d..40c6215d 100644
--- a/objectivec/Tests/iOSTestHarness/Info.plist
+++ b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Info.plist
@@ -4,16 +4,14 @@
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
- <key>CFBundleDisplayName</key>
- <string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
- <string>${EXECUTABLE_NAME}</string>
+ <string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
- <string>${PRODUCT_NAME}</string>
+ <string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
@@ -21,11 +19,17 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>1.0</string>
+ <string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
+ <key>UIMainStoryboardFile</key>
+ <string>Main</string>
+ <key>UIRequiredDeviceCapabilities</key>
+ <array>
+ <string>armv7</string>
+ </array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
@@ -35,9 +39,9 @@
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
- <string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
</dict>
</plist>
diff --git a/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/ViewController.h b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/ViewController.h
new file mode 100644
index 00000000..777257b8
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/ViewController.h
@@ -0,0 +1,37 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#import <UIKit/UIKit.h>
+
+@interface ViewController : UIViewController
+
+
+@end
+
diff --git a/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/ViewController.m b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/ViewController.m
new file mode 100644
index 00000000..c3b7e6c0
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/ViewController.m
@@ -0,0 +1,49 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#import "ViewController.h"
+
+@interface ViewController ()
+
+@end
+
+@implementation ViewController
+
+- (void)viewDidLoad {
+ [super viewDidLoad];
+ // Do any additional setup after loading the view, typically from a nib.
+}
+
+- (void)didReceiveMemoryWarning {
+ [super didReceiveMemoryWarning];
+ // Dispose of any resources that can be recreated.
+}
+
+@end
diff --git a/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/main.m b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/main.m
new file mode 100644
index 00000000..4df0b769
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/main.m
@@ -0,0 +1,39 @@
+//
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#import <UIKit/UIKit.h>
+#import "AppDelegate.h"
+
+int main(int argc, char * argv[]) {
+ @autoreleasepool {
+ return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
+ }
+}
diff --git a/objectivec/Tests/CocoaPods/run_tests.sh b/objectivec/Tests/CocoaPods/run_tests.sh
new file mode 100755
index 00000000..6d3e12be
--- /dev/null
+++ b/objectivec/Tests/CocoaPods/run_tests.sh
@@ -0,0 +1,150 @@
+#!/bin/bash
+#
+# Helper to run the pods tests.
+
+set -eu
+
+readonly ScriptDir=$(dirname "$(echo $0 | sed -e "s,^\([^/]\),$(pwd)/\1,")")
+
+printUsage() {
+ NAME=$(basename "${0}")
+ cat << EOF
+usage: ${NAME} [OPTIONS]
+
+This script runs some test to check the CocoaPods integration.
+
+OPTIONS:
+
+ General:
+
+ -h, --help
+ Show this message
+ --skip-static
+ Skip the static based pods tests.
+ --skip-framework
+ Skip the framework based pods tests.
+ --skip-ios
+ Skip the iOS pods tests.
+ --skip-osx
+ Skip the OS X pods tests.
+
+EOF
+}
+
+TEST_MODES=( "static" "framework" )
+TEST_NAMES=( "iOSCocoaPodsTester" "OSXCocoaPodsTester" )
+while [[ $# != 0 ]]; do
+ case "${1}" in
+ -h | --help )
+ printUsage
+ exit 0
+ ;;
+ --skip-static )
+ TEST_MODES=(${TEST_MODES[@]/static})
+ ;;
+ --skip-framework )
+ TEST_MODES=(${TEST_MODES[@]/framework})
+ ;;
+ --skip-ios )
+ TEST_NAMES=(${TEST_NAMES[@]/iOSCocoaPodsTester})
+ ;;
+ --skip-osx )
+ TEST_NAMES=(${TEST_NAMES[@]/OSXCocoaPodsTester})
+ ;;
+ -*)
+ echo "ERROR: Unknown option: ${1}" 1>&2
+ printUsage
+ exit 1
+ ;;
+ *)
+ echo "ERROR: Unknown argument: ${1}" 1>&2
+ printUsage
+ exit 1
+ ;;
+ esac
+ shift
+done
+
+# Sanity check.
+if [[ "${#TEST_NAMES[@]}" == 0 ]] ; then
+ echo "ERROR: Need to run at least iOS or OS X tests." 1>&2
+ exit 2
+fi
+if [[ "${#TEST_MODES[@]}" == 0 ]] ; then
+ echo "ERROR: Need to run at least static or frameworks tests." 1>&2
+ exit 2
+fi
+
+header() {
+ echo ""
+ echo "========================================================================"
+ echo " ${@}"
+ echo "========================================================================"
+ echo ""
+}
+
+# Cleanup hook for do_test, assumes directory is correct.
+cleanup() {
+ local TEST_NAME="$1"
+
+ echo "Cleaning up..."
+
+ # Generally don't let things fail, and eat common stdout, but let stderr show
+ # incase something does hiccup.
+ xcodebuild -workspace "${TEST_NAME}.xcworkspace" -scheme "${TEST_NAME}" clean > /dev/null || true
+ pod deintegrate > /dev/null || true
+ # Flush the cache so nothing is left behind.
+ pod cache clean --all || true
+ # Delete the files left after pod deintegrate.
+ rm -f Podfile.lock || true
+ rm -rf "${TEST_NAME}.xcworkspace" || true
+ git checkout -- "${TEST_NAME}.xcodeproj" || true
+ # Remove the Podfile that was put in place.
+ rm -f Podfile || true
+}
+
+do_test() {
+ local TEST_NAME="$1"
+ local TEST_MODE="$2"
+
+ header "${TEST_NAME}" - Mode: "${TEST_MODE}"
+ cd "${ScriptDir}/${TEST_NAME}"
+
+ # Hook in cleanup for any failures.
+ trap "cleanup ${TEST_NAME}" EXIT
+
+ # Ensure nothing is cached by pods to start with that could throw things off.
+ pod cache clean --all
+
+ # Put the right Podfile in place.
+ cp -f "Podfile-${TEST_MODE}" "Podfile"
+
+ xcodebuild_args=( "-workspace" "${TEST_NAME}.xcworkspace" "-scheme" "${TEST_NAME}" )
+
+ # For iOS, if the SDK is not provided it tries to use iphoneos, and the test
+ # fail on Travis since those machines don't have a Code Signing identity.
+ if [[ "${TEST_NAME}" == iOS* ]] ; then
+ # Apparently the destination flag is required to avoid "Unsupported architecture"
+ # errors.
+ xcodebuild_args+=(
+ -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO
+ -destination "platform=iOS Simulator,name=iPad 2,OS=9.3"
+ )
+ fi
+
+ # Do the work!
+ pod install --verbose
+
+ xcodebuild "${xcodebuild_args[@]}" build
+
+ # Clear the hook and manually run cleanup.
+ trap - EXIT
+ cleanup "${TEST_NAME}"
+}
+
+# Run the tests.
+for TEST_NAME in "${TEST_NAMES[@]}" ; do
+ for TEST_MODE in "${TEST_MODES[@]}" ; do
+ do_test "${TEST_NAME}" "${TEST_MODE}"
+ done
+done
diff --git a/objectivec/Tests/GPBARCUnittestProtos.m b/objectivec/Tests/GPBARCUnittestProtos.m
index d0408869..29f6ccf6 100644
--- a/objectivec/Tests/GPBARCUnittestProtos.m
+++ b/objectivec/Tests/GPBARCUnittestProtos.m
@@ -34,9 +34,16 @@
// Makes sure all the generated headers compile with ARC on.
+// The unittest_custom_options.proto extends the messages in descriptor.proto
+// so we build it in to test extending in general. The library doesn't provide
+// a descriptor as it doesn't use the classes/enums.
+#import "google/protobuf/Descriptor.pbobjc.h"
+
#import "google/protobuf/Unittest.pbobjc.h"
#import "google/protobuf/UnittestCustomOptions.pbobjc.h"
#import "google/protobuf/UnittestCycle.pbobjc.h"
+#import "google/protobuf/UnittestDeprecated.pbobjc.h"
+#import "google/protobuf/UnittestDeprecatedFile.pbobjc.h"
#import "google/protobuf/UnittestDropUnknownFields.pbobjc.h"
#import "google/protobuf/UnittestEmbedOptimizeFor.pbobjc.h"
#import "google/protobuf/UnittestEmpty.pbobjc.h"
diff --git a/objectivec/Tests/GPBArrayTests.m b/objectivec/Tests/GPBArrayTests.m
index 0fb15e40..e414d90a 100644
--- a/objectivec/Tests/GPBArrayTests.m
+++ b/objectivec/Tests/GPBArrayTests.m
@@ -32,12 +32,14 @@
#import <XCTest/XCTest.h>
#import "GPBArray.h"
+#import "GPBArray_PackagePrivate.h"
#import "GPBTestUtilities.h"
// To let the testing macros work, add some extra methods to simplify things.
@interface GPBEnumArray (TestingTweak)
+ (instancetype)arrayWithValue:(int32_t)value;
++ (instancetype)arrayWithCapacity:(NSUInteger)count;
- (instancetype)initWithValues:(const int32_t [])values
count:(NSUInteger)count;
@end
@@ -71,6 +73,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
rawValues:&value
count:1] autorelease];
}
++ (instancetype)arrayWithCapacity:(NSUInteger)count {
+ return [[[self alloc] initWithValidationFunction:TestingEnum_IsValidValue
+ capacity:count] autorelease];
+}
- (instancetype)initWithValues:(const int32_t [])values
count:(NSUInteger)count {
return [self initWithValidationFunction:TestingEnum_IsValidValue
@@ -176,6 +182,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
//% XCTAssertNotEqual(idx, 0U);
//% ++idx2;
//% }];
+//% // Ensure description doesn't choke.
+//% XCTAssertTrue(array.description.length > 10);
//% [array release];
//%}
//%
@@ -200,6 +208,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
//% NAME$S count:GPBARRAYSIZE(kValues3)];
//% XCTAssertNotNil(array3);
//%
+//% // Identity
+//% XCTAssertTrue([array1 isEqual:array1]);
+//% // Wrong type doesn't blow up.
+//% XCTAssertFalse([array1 isEqual:@"bogus"]);
//% // 1/1Prime should be different objects, but equal.
//% XCTAssertNotEqual(array1, array1prime);
//% XCTAssertEqualObjects(array1, array1prime);
@@ -270,6 +282,12 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
//% [array add##HELPER##ValuesFromArray:array2];
//% XCTAssertEqual(array.count, 5U);
//%
+//% // Zero/nil inputs do nothing.
+//% [array addValues:kValues1 count:0];
+//% XCTAssertEqual(array.count, 5U);
+//% [array addValues:NULL count:5];
+//% XCTAssertEqual(array.count, 5U);
+//%
//% XCTAssertEqual([array valueAtIndex:0], VAL1);
//% XCTAssertEqual([array valueAtIndex:1], VAL2);
//% XCTAssertEqual([array valueAtIndex:2], VAL3);
@@ -390,9 +408,9 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
//%- (void)testInternalResizing {
//% const TYPE kValues[] = { VAL1, VAL2, VAL3, VAL4 };
//% GPB##NAME##Array *array =
-//% [[GPB##NAME##Array alloc] initWithValues:kValues
-//% NAME$S count:GPBARRAYSIZE(kValues)];
+//% [GPB##NAME##Array arrayWithCapacity:GPBARRAYSIZE(kValues)];
//% XCTAssertNotNil(array);
+//% [array addValues:kValues count:GPBARRAYSIZE(kValues)];
//%
//% // Add/remove to trigger the intneral buffer to grow/shrink.
//% for (int i = 0; i < 100; ++i) {
@@ -409,7 +427,6 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
//% XCTAssertEqual(array.count, 404U);
//% [array removeAll];
//% XCTAssertEqual(array.count, 0U);
-//% [array release];
//%}
//%
//%@end
@@ -509,6 +526,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertNotEqual(idx, 0U);
++idx2;
}];
+ // Ensure description doesn't choke.
+ XCTAssertTrue(array.description.length > 10);
[array release];
}
@@ -533,6 +552,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(array3);
+ // Identity
+ XCTAssertTrue([array1 isEqual:array1]);
+ // Wrong type doesn't blow up.
+ XCTAssertFalse([array1 isEqual:@"bogus"]);
// 1/1Prime should be different objects, but equal.
XCTAssertNotEqual(array1, array1prime);
XCTAssertEqualObjects(array1, array1prime);
@@ -603,6 +626,12 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
[array addValuesFromArray:array2];
XCTAssertEqual(array.count, 5U);
+ // Zero/nil inputs do nothing.
+ [array addValues:kValues1 count:0];
+ XCTAssertEqual(array.count, 5U);
+ [array addValues:NULL count:5];
+ XCTAssertEqual(array.count, 5U);
+
XCTAssertEqual([array valueAtIndex:0], 1);
XCTAssertEqual([array valueAtIndex:1], 2);
XCTAssertEqual([array valueAtIndex:2], 3);
@@ -723,9 +752,9 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
- (void)testInternalResizing {
const int32_t kValues[] = { 1, 2, 3, 4 };
GPBInt32Array *array =
- [[GPBInt32Array alloc] initWithValues:kValues
- count:GPBARRAYSIZE(kValues)];
+ [GPBInt32Array arrayWithCapacity:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(array);
+ [array addValues:kValues count:GPBARRAYSIZE(kValues)];
// Add/remove to trigger the intneral buffer to grow/shrink.
for (int i = 0; i < 100; ++i) {
@@ -742,7 +771,6 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertEqual(array.count, 404U);
[array removeAll];
XCTAssertEqual(array.count, 0U);
- [array release];
}
@end
@@ -842,6 +870,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertNotEqual(idx, 0U);
++idx2;
}];
+ // Ensure description doesn't choke.
+ XCTAssertTrue(array.description.length > 10);
[array release];
}
@@ -866,6 +896,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(array3);
+ // Identity
+ XCTAssertTrue([array1 isEqual:array1]);
+ // Wrong type doesn't blow up.
+ XCTAssertFalse([array1 isEqual:@"bogus"]);
// 1/1Prime should be different objects, but equal.
XCTAssertNotEqual(array1, array1prime);
XCTAssertEqualObjects(array1, array1prime);
@@ -936,6 +970,12 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
[array addValuesFromArray:array2];
XCTAssertEqual(array.count, 5U);
+ // Zero/nil inputs do nothing.
+ [array addValues:kValues1 count:0];
+ XCTAssertEqual(array.count, 5U);
+ [array addValues:NULL count:5];
+ XCTAssertEqual(array.count, 5U);
+
XCTAssertEqual([array valueAtIndex:0], 11U);
XCTAssertEqual([array valueAtIndex:1], 12U);
XCTAssertEqual([array valueAtIndex:2], 13U);
@@ -1056,9 +1096,9 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
- (void)testInternalResizing {
const uint32_t kValues[] = { 11U, 12U, 13U, 14U };
GPBUInt32Array *array =
- [[GPBUInt32Array alloc] initWithValues:kValues
- count:GPBARRAYSIZE(kValues)];
+ [GPBUInt32Array arrayWithCapacity:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(array);
+ [array addValues:kValues count:GPBARRAYSIZE(kValues)];
// Add/remove to trigger the intneral buffer to grow/shrink.
for (int i = 0; i < 100; ++i) {
@@ -1075,7 +1115,6 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertEqual(array.count, 404U);
[array removeAll];
XCTAssertEqual(array.count, 0U);
- [array release];
}
@end
@@ -1175,6 +1214,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertNotEqual(idx, 0U);
++idx2;
}];
+ // Ensure description doesn't choke.
+ XCTAssertTrue(array.description.length > 10);
[array release];
}
@@ -1199,6 +1240,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(array3);
+ // Identity
+ XCTAssertTrue([array1 isEqual:array1]);
+ // Wrong type doesn't blow up.
+ XCTAssertFalse([array1 isEqual:@"bogus"]);
// 1/1Prime should be different objects, but equal.
XCTAssertNotEqual(array1, array1prime);
XCTAssertEqualObjects(array1, array1prime);
@@ -1269,6 +1314,12 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
[array addValuesFromArray:array2];
XCTAssertEqual(array.count, 5U);
+ // Zero/nil inputs do nothing.
+ [array addValues:kValues1 count:0];
+ XCTAssertEqual(array.count, 5U);
+ [array addValues:NULL count:5];
+ XCTAssertEqual(array.count, 5U);
+
XCTAssertEqual([array valueAtIndex:0], 31LL);
XCTAssertEqual([array valueAtIndex:1], 32LL);
XCTAssertEqual([array valueAtIndex:2], 33LL);
@@ -1389,9 +1440,9 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
- (void)testInternalResizing {
const int64_t kValues[] = { 31LL, 32LL, 33LL, 34LL };
GPBInt64Array *array =
- [[GPBInt64Array alloc] initWithValues:kValues
- count:GPBARRAYSIZE(kValues)];
+ [GPBInt64Array arrayWithCapacity:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(array);
+ [array addValues:kValues count:GPBARRAYSIZE(kValues)];
// Add/remove to trigger the intneral buffer to grow/shrink.
for (int i = 0; i < 100; ++i) {
@@ -1408,7 +1459,6 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertEqual(array.count, 404U);
[array removeAll];
XCTAssertEqual(array.count, 0U);
- [array release];
}
@end
@@ -1508,6 +1558,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertNotEqual(idx, 0U);
++idx2;
}];
+ // Ensure description doesn't choke.
+ XCTAssertTrue(array.description.length > 10);
[array release];
}
@@ -1532,6 +1584,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(array3);
+ // Identity
+ XCTAssertTrue([array1 isEqual:array1]);
+ // Wrong type doesn't blow up.
+ XCTAssertFalse([array1 isEqual:@"bogus"]);
// 1/1Prime should be different objects, but equal.
XCTAssertNotEqual(array1, array1prime);
XCTAssertEqualObjects(array1, array1prime);
@@ -1602,6 +1658,12 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
[array addValuesFromArray:array2];
XCTAssertEqual(array.count, 5U);
+ // Zero/nil inputs do nothing.
+ [array addValues:kValues1 count:0];
+ XCTAssertEqual(array.count, 5U);
+ [array addValues:NULL count:5];
+ XCTAssertEqual(array.count, 5U);
+
XCTAssertEqual([array valueAtIndex:0], 41ULL);
XCTAssertEqual([array valueAtIndex:1], 42ULL);
XCTAssertEqual([array valueAtIndex:2], 43ULL);
@@ -1722,9 +1784,9 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
- (void)testInternalResizing {
const uint64_t kValues[] = { 41ULL, 42ULL, 43ULL, 44ULL };
GPBUInt64Array *array =
- [[GPBUInt64Array alloc] initWithValues:kValues
- count:GPBARRAYSIZE(kValues)];
+ [GPBUInt64Array arrayWithCapacity:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(array);
+ [array addValues:kValues count:GPBARRAYSIZE(kValues)];
// Add/remove to trigger the intneral buffer to grow/shrink.
for (int i = 0; i < 100; ++i) {
@@ -1741,7 +1803,6 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertEqual(array.count, 404U);
[array removeAll];
XCTAssertEqual(array.count, 0U);
- [array release];
}
@end
@@ -1841,6 +1902,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertNotEqual(idx, 0U);
++idx2;
}];
+ // Ensure description doesn't choke.
+ XCTAssertTrue(array.description.length > 10);
[array release];
}
@@ -1865,6 +1928,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(array3);
+ // Identity
+ XCTAssertTrue([array1 isEqual:array1]);
+ // Wrong type doesn't blow up.
+ XCTAssertFalse([array1 isEqual:@"bogus"]);
// 1/1Prime should be different objects, but equal.
XCTAssertNotEqual(array1, array1prime);
XCTAssertEqualObjects(array1, array1prime);
@@ -1935,6 +2002,12 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
[array addValuesFromArray:array2];
XCTAssertEqual(array.count, 5U);
+ // Zero/nil inputs do nothing.
+ [array addValues:kValues1 count:0];
+ XCTAssertEqual(array.count, 5U);
+ [array addValues:NULL count:5];
+ XCTAssertEqual(array.count, 5U);
+
XCTAssertEqual([array valueAtIndex:0], 51.f);
XCTAssertEqual([array valueAtIndex:1], 52.f);
XCTAssertEqual([array valueAtIndex:2], 53.f);
@@ -2055,9 +2128,9 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
- (void)testInternalResizing {
const float kValues[] = { 51.f, 52.f, 53.f, 54.f };
GPBFloatArray *array =
- [[GPBFloatArray alloc] initWithValues:kValues
- count:GPBARRAYSIZE(kValues)];
+ [GPBFloatArray arrayWithCapacity:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(array);
+ [array addValues:kValues count:GPBARRAYSIZE(kValues)];
// Add/remove to trigger the intneral buffer to grow/shrink.
for (int i = 0; i < 100; ++i) {
@@ -2074,7 +2147,6 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertEqual(array.count, 404U);
[array removeAll];
XCTAssertEqual(array.count, 0U);
- [array release];
}
@end
@@ -2174,6 +2246,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertNotEqual(idx, 0U);
++idx2;
}];
+ // Ensure description doesn't choke.
+ XCTAssertTrue(array.description.length > 10);
[array release];
}
@@ -2198,6 +2272,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(array3);
+ // Identity
+ XCTAssertTrue([array1 isEqual:array1]);
+ // Wrong type doesn't blow up.
+ XCTAssertFalse([array1 isEqual:@"bogus"]);
// 1/1Prime should be different objects, but equal.
XCTAssertNotEqual(array1, array1prime);
XCTAssertEqualObjects(array1, array1prime);
@@ -2268,6 +2346,12 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
[array addValuesFromArray:array2];
XCTAssertEqual(array.count, 5U);
+ // Zero/nil inputs do nothing.
+ [array addValues:kValues1 count:0];
+ XCTAssertEqual(array.count, 5U);
+ [array addValues:NULL count:5];
+ XCTAssertEqual(array.count, 5U);
+
XCTAssertEqual([array valueAtIndex:0], 61.);
XCTAssertEqual([array valueAtIndex:1], 62.);
XCTAssertEqual([array valueAtIndex:2], 63.);
@@ -2388,9 +2472,9 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
- (void)testInternalResizing {
const double kValues[] = { 61., 62., 63., 64. };
GPBDoubleArray *array =
- [[GPBDoubleArray alloc] initWithValues:kValues
- count:GPBARRAYSIZE(kValues)];
+ [GPBDoubleArray arrayWithCapacity:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(array);
+ [array addValues:kValues count:GPBARRAYSIZE(kValues)];
// Add/remove to trigger the intneral buffer to grow/shrink.
for (int i = 0; i < 100; ++i) {
@@ -2407,7 +2491,6 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertEqual(array.count, 404U);
[array removeAll];
XCTAssertEqual(array.count, 0U);
- [array release];
}
@end
@@ -2507,6 +2590,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertNotEqual(idx, 0U);
++idx2;
}];
+ // Ensure description doesn't choke.
+ XCTAssertTrue(array.description.length > 10);
[array release];
}
@@ -2531,6 +2616,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(array3);
+ // Identity
+ XCTAssertTrue([array1 isEqual:array1]);
+ // Wrong type doesn't blow up.
+ XCTAssertFalse([array1 isEqual:@"bogus"]);
// 1/1Prime should be different objects, but equal.
XCTAssertNotEqual(array1, array1prime);
XCTAssertEqualObjects(array1, array1prime);
@@ -2601,6 +2690,12 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
[array addValuesFromArray:array2];
XCTAssertEqual(array.count, 5U);
+ // Zero/nil inputs do nothing.
+ [array addValues:kValues1 count:0];
+ XCTAssertEqual(array.count, 5U);
+ [array addValues:NULL count:5];
+ XCTAssertEqual(array.count, 5U);
+
XCTAssertEqual([array valueAtIndex:0], TRUE);
XCTAssertEqual([array valueAtIndex:1], TRUE);
XCTAssertEqual([array valueAtIndex:2], FALSE);
@@ -2721,9 +2816,9 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
- (void)testInternalResizing {
const BOOL kValues[] = { TRUE, TRUE, FALSE, FALSE };
GPBBoolArray *array =
- [[GPBBoolArray alloc] initWithValues:kValues
- count:GPBARRAYSIZE(kValues)];
+ [GPBBoolArray arrayWithCapacity:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(array);
+ [array addValues:kValues count:GPBARRAYSIZE(kValues)];
// Add/remove to trigger the intneral buffer to grow/shrink.
for (int i = 0; i < 100; ++i) {
@@ -2740,7 +2835,6 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertEqual(array.count, 404U);
[array removeAll];
XCTAssertEqual(array.count, 0U);
- [array release];
}
@end
@@ -2840,6 +2934,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertNotEqual(idx, 0U);
++idx2;
}];
+ // Ensure description doesn't choke.
+ XCTAssertTrue(array.description.length > 10);
[array release];
}
@@ -2864,6 +2960,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(array3);
+ // Identity
+ XCTAssertTrue([array1 isEqual:array1]);
+ // Wrong type doesn't blow up.
+ XCTAssertFalse([array1 isEqual:@"bogus"]);
// 1/1Prime should be different objects, but equal.
XCTAssertNotEqual(array1, array1prime);
XCTAssertEqualObjects(array1, array1prime);
@@ -2934,6 +3034,12 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
[array addRawValuesFromArray:array2];
XCTAssertEqual(array.count, 5U);
+ // Zero/nil inputs do nothing.
+ [array addValues:kValues1 count:0];
+ XCTAssertEqual(array.count, 5U);
+ [array addValues:NULL count:5];
+ XCTAssertEqual(array.count, 5U);
+
XCTAssertEqual([array valueAtIndex:0], 71);
XCTAssertEqual([array valueAtIndex:1], 72);
XCTAssertEqual([array valueAtIndex:2], 73);
@@ -3054,9 +3160,9 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
- (void)testInternalResizing {
const int32_t kValues[] = { 71, 72, 73, 74 };
GPBEnumArray *array =
- [[GPBEnumArray alloc] initWithValues:kValues
- count:GPBARRAYSIZE(kValues)];
+ [GPBEnumArray arrayWithCapacity:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(array);
+ [array addValues:kValues count:GPBARRAYSIZE(kValues)];
// Add/remove to trigger the intneral buffer to grow/shrink.
for (int i = 0; i < 100; ++i) {
@@ -3073,7 +3179,6 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertEqual(array.count, 404U);
[array removeAll];
XCTAssertEqual(array.count, 0U);
- [array release];
}
@end
@@ -3436,3 +3541,175 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
}
@end
+
+#pragma mark - GPBAutocreatedArray Tests
+
+// These are hand written tests to double check some behaviors of the
+// GPBAutocreatedArray.
+
+// NOTE: GPBAutocreatedArray is private to the library, users of the library
+// should never have to directly deal with this class.
+
+@interface GPBAutocreatedArrayTests : XCTestCase
+@end
+
+@implementation GPBAutocreatedArrayTests
+
+- (void)testEquality {
+ GPBAutocreatedArray *array = [[GPBAutocreatedArray alloc] init];
+
+ XCTAssertTrue([array isEqual:@[]]);
+ XCTAssertTrue([array isEqualToArray:@[]]);
+
+ XCTAssertFalse([array isEqual:@[ @"foo" ]]);
+ XCTAssertFalse([array isEqualToArray:@[ @"foo" ]]);
+
+ [array addObject:@"foo"];
+
+ XCTAssertFalse([array isEqual:@[]]);
+ XCTAssertFalse([array isEqualToArray:@[]]);
+ XCTAssertTrue([array isEqual:@[ @"foo" ]]);
+ XCTAssertTrue([array isEqualToArray:@[ @"foo" ]]);
+ XCTAssertFalse([array isEqual:@[ @"bar" ]]);
+ XCTAssertFalse([array isEqualToArray:@[ @"bar" ]]);
+
+ GPBAutocreatedArray *array2 = [[GPBAutocreatedArray alloc] init];
+
+ XCTAssertFalse([array isEqual:array2]);
+ XCTAssertFalse([array isEqualToArray:array2]);
+
+ [array2 addObject:@"bar"];
+ XCTAssertFalse([array isEqual:array2]);
+ XCTAssertFalse([array isEqualToArray:array2]);
+
+ [array2 replaceObjectAtIndex:0 withObject:@"foo"];
+ XCTAssertTrue([array isEqual:array2]);
+ XCTAssertTrue([array isEqualToArray:array2]);
+
+ [array2 release];
+ [array release];
+}
+
+- (void)testCopy {
+ {
+ GPBAutocreatedArray *array = [[GPBAutocreatedArray alloc] init];
+
+ NSArray *cpy = [array copy];
+ XCTAssertTrue(cpy != array); // Ptr compare
+ XCTAssertTrue([cpy isKindOfClass:[NSArray class]]);
+ XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedArray class]]);
+ XCTAssertEqual(cpy.count, (NSUInteger)0);
+
+ NSArray *cpy2 = [array copy];
+ XCTAssertTrue(cpy2 != array); // Ptr compare
+ // Can't compare cpy and cpy2 because NSArray has a singleton empty
+ // array it uses, so the ptrs are the same.
+ XCTAssertTrue([cpy2 isKindOfClass:[NSArray class]]);
+ XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedArray class]]);
+ XCTAssertEqual(cpy2.count, (NSUInteger)0);
+
+ [cpy2 release];
+ [cpy release];
+ [array release];
+ }
+
+ {
+ GPBAutocreatedArray *array = [[GPBAutocreatedArray alloc] init];
+
+ NSMutableArray *cpy = [array mutableCopy];
+ XCTAssertTrue(cpy != array); // Ptr compare
+ XCTAssertTrue([cpy isKindOfClass:[NSMutableArray class]]);
+ XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedArray class]]);
+ XCTAssertEqual(cpy.count, (NSUInteger)0);
+
+ NSMutableArray *cpy2 = [array mutableCopy];
+ XCTAssertTrue(cpy2 != array); // Ptr compare
+ XCTAssertTrue(cpy2 != cpy); // Ptr compare
+ XCTAssertTrue([cpy2 isKindOfClass:[NSMutableArray class]]);
+ XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedArray class]]);
+ XCTAssertEqual(cpy2.count, (NSUInteger)0);
+
+ [cpy2 release];
+ [cpy release];
+ [array release];
+ }
+
+ {
+ GPBAutocreatedArray *array = [[GPBAutocreatedArray alloc] init];
+ [array addObject:@"foo"];
+ [array addObject:@"bar"];
+
+ NSArray *cpy = [array copy];
+ XCTAssertTrue(cpy != array); // Ptr compare
+ XCTAssertTrue([cpy isKindOfClass:[NSArray class]]);
+ XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedArray class]]);
+ XCTAssertEqual(cpy.count, (NSUInteger)2);
+ XCTAssertEqualObjects(cpy[0], @"foo");
+ XCTAssertEqualObjects(cpy[1], @"bar");
+
+ NSArray *cpy2 = [array copy];
+ XCTAssertTrue(cpy2 != array); // Ptr compare
+ XCTAssertTrue(cpy2 != cpy); // Ptr compare
+ XCTAssertTrue([cpy2 isKindOfClass:[NSArray class]]);
+ XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedArray class]]);
+ XCTAssertEqual(cpy2.count, (NSUInteger)2);
+ XCTAssertEqualObjects(cpy2[0], @"foo");
+ XCTAssertEqualObjects(cpy2[1], @"bar");
+
+ [cpy2 release];
+ [cpy release];
+ [array release];
+ }
+
+ {
+ GPBAutocreatedArray *array = [[GPBAutocreatedArray alloc] init];
+ [array addObject:@"foo"];
+ [array addObject:@"bar"];
+
+ NSMutableArray *cpy = [array mutableCopy];
+ XCTAssertTrue(cpy != array); // Ptr compare
+ XCTAssertTrue([cpy isKindOfClass:[NSArray class]]);
+ XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedArray class]]);
+ XCTAssertEqual(cpy.count, (NSUInteger)2);
+ XCTAssertEqualObjects(cpy[0], @"foo");
+ XCTAssertEqualObjects(cpy[1], @"bar");
+
+ NSMutableArray *cpy2 = [array mutableCopy];
+ XCTAssertTrue(cpy2 != array); // Ptr compare
+ XCTAssertTrue(cpy2 != cpy); // Ptr compare
+ XCTAssertTrue([cpy2 isKindOfClass:[NSArray class]]);
+ XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedArray class]]);
+ XCTAssertEqual(cpy2.count, (NSUInteger)2);
+ XCTAssertEqualObjects(cpy2[0], @"foo");
+ XCTAssertEqualObjects(cpy2[1], @"bar");
+
+ [cpy2 release];
+ [cpy release];
+ [array release];
+ }
+}
+
+- (void)testIndexedSubscriptSupport {
+ // The base NSArray/NSMutableArray behaviors for *IndexedSubscript methods
+ // should still work via the methods that one has to override to make an
+ // NSMutableArray subclass. i.e. - this should "just work" and if these
+ // crash/fail, then something is wrong in how NSMutableArray is subclassed.
+
+ GPBAutocreatedArray *array = [[GPBAutocreatedArray alloc] init];
+
+ [array addObject:@"foo"];
+ [array addObject:@"bar"];
+ XCTAssertEqual(array.count, (NSUInteger)2);
+ XCTAssertEqualObjects(array[0], @"foo");
+ XCTAssertEqualObjects(array[1], @"bar");
+ array[0] = @"foo2";
+ array[2] = @"baz";
+ XCTAssertEqual(array.count, (NSUInteger)3);
+ XCTAssertEqualObjects(array[0], @"foo2");
+ XCTAssertEqualObjects(array[1], @"bar");
+ XCTAssertEqualObjects(array[2], @"baz");
+
+ [array release];
+}
+
+@end
diff --git a/objectivec/Tests/GPBCodedInputStreamTests.m b/objectivec/Tests/GPBCodedInputStreamTests.m
index b0e39d2c..f5aa6903 100644
--- a/objectivec/Tests/GPBCodedInputStreamTests.m
+++ b/objectivec/Tests/GPBCodedInputStreamTests.m
@@ -62,52 +62,101 @@
#define bytes(...) [self bytes_with_sentinel:0, __VA_ARGS__, 256]
- (void)testDecodeZigZag {
- XCTAssertEqual(0, GPBDecodeZigZag32(0));
- XCTAssertEqual(-1, GPBDecodeZigZag32(1));
- XCTAssertEqual(1, GPBDecodeZigZag32(2));
- XCTAssertEqual(-2, GPBDecodeZigZag32(3));
- XCTAssertEqual((int32_t)0x3FFFFFFF, GPBDecodeZigZag32(0x7FFFFFFE));
- XCTAssertEqual((int32_t)0xC0000000, GPBDecodeZigZag32(0x7FFFFFFF));
- XCTAssertEqual((int32_t)0x7FFFFFFF, GPBDecodeZigZag32(0xFFFFFFFE));
- XCTAssertEqual((int32_t)0x80000000, GPBDecodeZigZag32(0xFFFFFFFF));
-
- XCTAssertEqual((int64_t)0, GPBDecodeZigZag64(0));
- XCTAssertEqual((int64_t)-1, GPBDecodeZigZag64(1));
- XCTAssertEqual((int64_t)1, GPBDecodeZigZag64(2));
- XCTAssertEqual((int64_t)-2, GPBDecodeZigZag64(3));
- XCTAssertEqual((int64_t)0x000000003FFFFFFFL,
- GPBDecodeZigZag64(0x000000007FFFFFFEL));
- XCTAssertEqual((int64_t)0xFFFFFFFFC0000000L,
- GPBDecodeZigZag64(0x000000007FFFFFFFL));
- XCTAssertEqual((int64_t)0x000000007FFFFFFFL,
- GPBDecodeZigZag64(0x00000000FFFFFFFEL));
- XCTAssertEqual((int64_t)0xFFFFFFFF80000000L,
- GPBDecodeZigZag64(0x00000000FFFFFFFFL));
- XCTAssertEqual((int64_t)0x7FFFFFFFFFFFFFFFL,
- GPBDecodeZigZag64(0xFFFFFFFFFFFFFFFEL));
- XCTAssertEqual((int64_t)0x8000000000000000L,
- GPBDecodeZigZag64(0xFFFFFFFFFFFFFFFFL));
+ [self assertReadZigZag32:bytes(0x0) value:0];
+ [self assertReadZigZag32:bytes(0x1) value:-1];
+ [self assertReadZigZag32:bytes(0x2) value:1];
+ [self assertReadZigZag32:bytes(0x3) value:-2];
+
+ [self assertReadZigZag32:bytes(0xFE, 0xFF, 0xFF, 0xFF, 0x07) value:(int32_t)0x3FFFFFFF];
+ [self assertReadZigZag32:bytes(0xFF, 0xFF, 0xFF, 0xFF, 0x07) value:(int32_t)0xC0000000];
+ [self assertReadZigZag32:bytes(0xFE, 0xFF, 0xFF, 0xFF, 0x0F) value:(int32_t)0x7FFFFFFF];
+ [self assertReadZigZag32:bytes(0xFF, 0xFF, 0xFF, 0xFF, 0x0F) value:(int32_t)0x80000000];
+
+ [self assertReadZigZag64:bytes(0x0) value:0];
+ [self assertReadZigZag64:bytes(0x1) value:-1];
+ [self assertReadZigZag64:bytes(0x2) value:1];
+ [self assertReadZigZag64:bytes(0x3) value:-2];
+
+ [self assertReadZigZag64:bytes(0xFE, 0xFF, 0xFF, 0xFF, 0x07) value:(int32_t)0x3FFFFFFF];
+ [self assertReadZigZag64:bytes(0xFF, 0xFF, 0xFF, 0xFF, 0x07) value:(int32_t)0xC0000000];
+ [self assertReadZigZag64:bytes(0xFE, 0xFF, 0xFF, 0xFF, 0x0F) value:(int32_t)0x7FFFFFFF];
+ [self assertReadZigZag64:bytes(0xFF, 0xFF, 0xFF, 0xFF, 0x0F) value:(int32_t)0x80000000];
+
+ [self assertReadZigZag64:bytes(0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01) value:0x7FFFFFFFFFFFFFFFL];
+ [self assertReadZigZag64:bytes(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01) value:0x8000000000000000L];
}
- (void)assertReadVarint:(NSData*)data value:(int64_t)value {
- {
+ if (value <= INT32_MAX && value >= INT32_MIN) {
+ {
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual((int32_t)value, [input readInt32]);
+ }
+ {
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual((int32_t)value, [input readEnum]);
+ }
+ }
+ if (value <= UINT32_MAX && value >= 0) {
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
- XCTAssertEqual((int32_t)value, [input readInt32]);
+ XCTAssertEqual((uint32_t)value, [input readUInt32]);
}
{
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
XCTAssertEqual(value, [input readInt64]);
}
+ if (value >= 0) {
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual((uint64_t)value, [input readUInt64]);
+ }
}
- (void)assertReadLittleEndian32:(NSData*)data value:(int32_t)value {
- GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
- XCTAssertEqual(value, [input readSFixed32]);
+ {
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual(value, [input readSFixed32]);
+ }
+ {
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual(GPBConvertInt32ToFloat(value), [input readFloat]);
+ }
+ {
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual((uint32_t)value, [input readFixed32]);
+ }
+ {
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual(value, [input readSFixed32]);
+ }
}
- (void)assertReadLittleEndian64:(NSData*)data value:(int64_t)value {
+ {
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual(value, [input readSFixed64]);
+ }
+ {
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual(GPBConvertInt64ToDouble(value), [input readDouble]);
+ }
+ {
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual((uint64_t)value, [input readFixed64]);
+ }
+ {
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual(value, [input readSFixed64]);
+ }
+}
+
+- (void)assertReadZigZag32:(NSData*)data value:(int64_t)value {
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
- XCTAssertEqual(value, [input readSFixed64]);
+ XCTAssertEqual((int32_t)value, [input readSInt32]);
+}
+
+- (void)assertReadZigZag64:(NSData*)data value:(int64_t)value {
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual(value, [input readSInt64]);
}
- (void)assertReadVarintFailure:(NSData*)data {
@@ -128,12 +177,28 @@
XCTAssertEqual(((uint8_t*)data.bytes)[1], (uint8_t)0x74);
}
+- (void)testReadBool {
+ {
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:bytes(0x00)];
+ XCTAssertEqual(NO, [input readBool]);
+ }
+ {
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:bytes(0x01)];
+ XCTAssertEqual(YES, [input readBool]);
+ }
+}
+
- (void)testReadVarint {
[self assertReadVarint:bytes(0x00) value:0];
[self assertReadVarint:bytes(0x01) value:1];
[self assertReadVarint:bytes(0x7f) value:127];
// 14882
[self assertReadVarint:bytes(0xa2, 0x74) value:(0x22 << 0) | (0x74 << 7)];
+ // 1904930
+ [self assertReadVarint:bytes(0xa2, 0xa2, 0x74) value:(0x22 << 0) | (0x22 << 7) | (0x74 << 14)];
+ // 243831074
+ [self assertReadVarint:bytes(0xa2, 0xa2, 0xa2, 0x74)
+ value:(0x22 << 0) | (0x22 << 7) | (0x22 << 14) | (0x74 << 21)];
// 2961488830
[self assertReadVarint:bytes(0xbe, 0xf7, 0x92, 0x84, 0x0b)
value:(0x3e << 0) | (0x77 << 7) | (0x12 << 14) |
@@ -155,7 +220,7 @@
0xa6, 0x01)
value:(0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) |
(0x3bLL << 28) | (0x56LL << 35) | (0x00LL << 42) |
- (0x05LL << 49) | (0x26LL << 56) | (0x01LL << 63)];
+ (0x05LL << 49) | (0x26LL << 56) | (0x01ULL << 63)];
// Failures
[self assertReadVarintFailure:bytes(0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
@@ -163,6 +228,45 @@
[self assertReadVarintFailure:bytes(0x80)];
}
+- (void)testReadVarint32FromVarint64 {
+ {
+ // Turn on lower 31 bits of the upper half on a 64 bit varint.
+ NSData* data = bytes(0x80, 0x80, 0x80, 0x80, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0x7E);
+
+ int32_t value32 = 0x0;
+ GPBCodedInputStream* input32 = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual(value32, [input32 readInt32]);
+
+ int64_t value64 = INT64_MAX & 0xFFFFFFFF00000000;
+ GPBCodedInputStream* input64 = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual(value64, [input64 readInt64]);
+ }
+ {
+ // Turn on lower 31 bits and lower 31 bits on upper half on a 64 bit varint.
+ NSData* data = bytes(0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0xFF, 0xFF, 0xFF, 0xFF, 0x7E);
+
+ int32_t value32 = INT32_MAX;
+ GPBCodedInputStream* input32 = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual(value32, [input32 readInt32]);
+
+ int64_t value64 = INT64_MAX & 0xFFFFFFFF7FFFFFFF;
+ GPBCodedInputStream* input64 = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual(value64, [input64 readInt64]);
+ }
+ {
+ // Turn on bits 32 and 64 bit on a 64 bit varint.
+ NSData* data = bytes(0x80, 0x80, 0x80, 0x80, 0x88, 0x80, 0x80, 0x80, 0x80, 0x01);
+
+ int32_t value32 = INT32_MIN;
+ GPBCodedInputStream* input32 = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual(value32, [input32 readInt32]);
+
+ int64_t value64 = INT64_MIN | (0x01LL << 31);
+ GPBCodedInputStream* input64 = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqual(value64, [input64 readInt64]);
+ }
+}
+
- (void)testReadLittleEndian {
[self assertReadLittleEndian32:bytes(0x78, 0x56, 0x34, 0x12)
value:0x12345678];
@@ -265,6 +369,27 @@
XCTAssertThrows([input readBytes]);
}
+- (void)testReadEmptyString {
+ NSData *data = bytes(0x00);
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
+ XCTAssertEqualObjects(@"", [input readString]);
+}
+
+- (void)testInvalidGroupEndTagThrows {
+ NSData *data = bytes(0x0B, 0x1A, 0x02, 0x4B, 0x50, 0x14);
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
+ XCTAssertThrowsSpecificNamed([input skipMessage],
+ NSException,
+ GPBCodedInputStreamException,
+ @"should throw a GPBCodedInputStreamException exception ");
+}
+
+- (void)testBytesWithNegativeSize {
+ NSData *data = bytes(0xFF, 0xFF, 0xFF, 0xFF, 0x0F);
+ GPBCodedInputStream *input = [GPBCodedInputStream streamWithData:data];
+ XCTAssertNil([input readBytes]);
+}
+
// Verifies fix for b/10315336.
// Note: Now that there isn't a custom string class under the hood, this test
// isn't as critical, but it does cover bad input and if a custom class is added
@@ -283,16 +408,53 @@
[output writeRawData:[NSData dataWithBytes:bytes length:sizeof(bytes)]];
[output flush];
- NSData* data =
+ NSData *data =
[rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
+ NSError *error = nil;
TestAllTypes* message = [TestAllTypes parseFromCodedInputStream:input
extensionRegistry:nil
- error:NULL];
- XCTAssertNotNil(message);
- // Make sure we can read string properties twice without crashing.
- XCTAssertEqual([message.defaultString length], (NSUInteger)0);
- XCTAssertEqualObjects(@"", message.defaultString);
+ error:&error];
+ XCTAssertNotNil(error);
+ XCTAssertNil(message);
+}
+
+- (void)testBOMWithinStrings {
+ // We've seen servers that end up with BOMs within strings (not always at the
+ // start, and sometimes in multiple places), make sure they always parse
+ // correctly. (Again, this is inpart incase a custom string class is ever
+ // used again.)
+ const char* strs[] = {
+ "\xEF\xBB\xBF String with BOM",
+ "String with \xEF\xBB\xBF in middle",
+ "String with end bom \xEF\xBB\xBF",
+ "\xEF\xBB\xBF\xe2\x99\xa1", // BOM White Heart
+ "\xEF\xBB\xBF\xEF\xBB\xBF String with Two BOM",
+ };
+ for (size_t i = 0; i < GPBARRAYSIZE(strs); ++i) {
+ NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
+ GPBCodedOutputStream* output =
+ [GPBCodedOutputStream streamWithOutputStream:rawOutput];
+
+ int32_t tag = GPBWireFormatMakeTag(TestAllTypes_FieldNumber_DefaultString,
+ GPBWireFormatLengthDelimited);
+ [output writeRawVarint32:tag];
+ size_t length = strlen(strs[i]);
+ [output writeRawVarint32:(int32_t)length];
+ [output writeRawData:[NSData dataWithBytes:strs[i] length:length]];
+ [output flush];
+
+ NSData* data =
+ [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
+ GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
+ TestAllTypes* message = [TestAllTypes parseFromCodedInputStream:input
+ extensionRegistry:nil
+ error:NULL];
+ XCTAssertNotNil(message, @"Loop %zd", i);
+ // Ensure the string is there. NSString can consume the BOM in some
+ // cases, so don't actually check the string for exact equality.
+ XCTAssertTrue(message.defaultString.length > 0, @"Loop %zd", i);
+ }
}
@end
diff --git a/objectivec/Tests/GPBCodedOuputStreamTests.m b/objectivec/Tests/GPBCodedOuputStreamTests.m
index 77d88033..109239d5 100644
--- a/objectivec/Tests/GPBCodedOuputStreamTests.m
+++ b/objectivec/Tests/GPBCodedOuputStreamTests.m
@@ -30,11 +30,30 @@
#import "GPBTestUtilities.h"
-#import "GPBCodedOutputStream.h"
+#import "GPBCodedOutputStream_PackagePrivate.h"
#import "GPBCodedInputStream.h"
#import "GPBUtilities_PackagePrivate.h"
#import "google/protobuf/Unittest.pbobjc.h"
+@interface GPBCodedOutputStream (InternalMethods)
+// Declared in the .m file, expose for testing.
+- (instancetype)initWithOutputStream:(NSOutputStream *)output
+ data:(NSMutableData *)data;
+@end
+
+@interface GPBCodedOutputStream (Helper)
++ (instancetype)streamWithOutputStream:(NSOutputStream *)output
+ bufferSize:(size_t)bufferSize;
+@end
+
+@implementation GPBCodedOutputStream (Helper)
++ (instancetype)streamWithOutputStream:(NSOutputStream *)output
+ bufferSize:(size_t)bufferSize {
+ NSMutableData *data = [NSMutableData dataWithLength:bufferSize];
+ return [[[self alloc] initWithOutputStream:output data:data] autorelease];
+}
+@end
+
@interface CodedOutputStreamTests : GPBTestCase
@end
@@ -174,6 +193,32 @@
}
}
+- (void)assertWriteStringNoTag:(NSData*)data
+ value:(NSString *)value
+ context:(NSString *)contextMessage {
+ NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
+ GPBCodedOutputStream* output =
+ [GPBCodedOutputStream streamWithOutputStream:rawOutput];
+ [output writeStringNoTag:value];
+ [output flush];
+
+ NSData* actual =
+ [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
+ XCTAssertEqualObjects(data, actual, @"%@", contextMessage);
+
+ // Try different block sizes.
+ for (int blockSize = 1; blockSize <= 16; blockSize *= 2) {
+ rawOutput = [NSOutputStream outputStreamToMemory];
+ output = [GPBCodedOutputStream streamWithOutputStream:rawOutput
+ bufferSize:blockSize];
+ [output writeStringNoTag:value];
+ [output flush];
+
+ actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
+ XCTAssertEqualObjects(data, actual, @"%@", contextMessage);
+ }
+}
+
- (void)testWriteVarint1 {
[self assertWriteVarint:bytes(0x00) value:0];
}
@@ -221,7 +266,7 @@
value:(0x1b << 0) | (0x28 << 7) | (0x79 << 14) |
(0x42 << 21) | (0x3bLL << 28) | (0x56LL << 35) |
(0x00LL << 42) | (0x05LL << 49) | (0x26LL << 56) |
- (0x01LL << 63)];
+ (0x01ULL << 63)];
}
- (void)testWriteLittleEndian {
@@ -318,4 +363,74 @@
XCTAssertEqualObjects(rawBytes, goldenData);
}
+- (void)testCFStringGetCStringPtrAndStringsWithNullChars {
+ // This test exists to verify that CFStrings with embedded NULLs still expose
+ // their raw buffer if they are backed by UTF8 storage. If this fails, the
+ // quick/direct access paths in GPBCodedOutputStream that depend on
+ // CFStringGetCStringPtr need to be re-evalutated (maybe just removed).
+ // And yes, we do get NULLs in strings from some servers.
+
+ char zeroTest[] = "\0Test\0String";
+ // Note: there is a \0 at the end of this since it is a c-string.
+ NSString *asNSString = [[NSString alloc] initWithBytes:zeroTest
+ length:sizeof(zeroTest)
+ encoding:NSUTF8StringEncoding];
+ const char *cString =
+ CFStringGetCStringPtr((CFStringRef)asNSString, kCFStringEncodingUTF8);
+ XCTAssertTrue(cString != NULL);
+ // Again, if the above assert fails, then it means NSString no longer exposes
+ // the raw utf8 storage of a string created from utf8 input, so the code using
+ // CFStringGetCStringPtr in GPBCodedOutputStream will still work (it will take
+ // a different code path); but the optimizations for when
+ // CFStringGetCStringPtr does work could possibly go away.
+
+ XCTAssertEqual(sizeof(zeroTest),
+ [asNSString lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
+ XCTAssertTrue(0 == memcmp(cString, zeroTest, sizeof(zeroTest)));
+ [asNSString release];
+}
+
+- (void)testWriteStringsWithZeroChar {
+ // Unicode allows `\0` as a character, and NSString is a class cluster, so
+ // there are a few different classes that could end up beind a given string.
+ // Historically, we've seen differences based on constant strings in code and
+ // strings built via the NSString apis. So this round trips them to ensure
+ // they are acting as expected.
+
+ NSArray<NSString *> *strs = @[
+ @"\0at start",
+ @"in\0middle",
+ @"at end\0",
+ ];
+ int i = 0;
+ for (NSString *str in strs) {
+ NSData *asUTF8 = [str dataUsingEncoding:NSUTF8StringEncoding];
+ NSMutableData *expected = [NSMutableData data];
+ uint8_t lengthByte = (uint8_t)asUTF8.length;
+ [expected appendBytes:&lengthByte length:1];
+ [expected appendData:asUTF8];
+
+ NSString *context = [NSString stringWithFormat:@"Loop %d - Literal", i];
+ [self assertWriteStringNoTag:expected value:str context:context];
+
+ // Force a new string to be built which gets a different class from the
+ // NSString class cluster than the literal did.
+ NSString *str2 = [NSString stringWithFormat:@"%@", str];
+ context = [NSString stringWithFormat:@"Loop %d - Built", i];
+ [self assertWriteStringNoTag:expected value:str2 context:context];
+
+ ++i;
+ }
+}
+
+- (void)testThatItThrowsWhenWriteRawPtrFails {
+ NSOutputStream *output = [NSOutputStream outputStreamToMemory];
+ GPBCodedOutputStream *codedOutput =
+ [GPBCodedOutputStream streamWithOutputStream:output bufferSize:0]; // Skip buffering.
+ [output close]; // Close the output stream to force failure on write.
+ const char *cString = "raw";
+ XCTAssertThrowsSpecificNamed([codedOutput writeRawPtr:cString offset:0 length:strlen(cString)],
+ NSException, GPBCodedOutputStreamException_WriteFailed);
+}
+
@end
diff --git a/objectivec/Tests/GPBCompileTest01.m b/objectivec/Tests/GPBCompileTest01.m
new file mode 100644
index 00000000..c8bc433a
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest01.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "GPBArray.h"
+
+
+// Something in the body of this file so the compiler/linker won't complain
+// about an empty .o file.
+__attribute__((visibility("default"))) char dummy_symbol_1 = 0;
diff --git a/objectivec/Tests/GPBCompileTest02.m b/objectivec/Tests/GPBCompileTest02.m
new file mode 100644
index 00000000..c44e201a
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest02.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "GPBCodedInputStream.h"
+
+
+// Something in the body of this file so the compiler/linker won't complain
+// about an empty .o file.
+__attribute__((visibility("default"))) char dummy_symbol_2 = 0;
diff --git a/objectivec/Tests/GPBCompileTest03.m b/objectivec/Tests/GPBCompileTest03.m
new file mode 100644
index 00000000..41994f94
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest03.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "GPBCodedOutputStream.h"
+
+
+// Something in the body of this file so the compiler/linker won't complain
+// about an empty .o file.
+__attribute__((visibility("default"))) char dummy_symbol_3 = 0;
diff --git a/objectivec/Tests/GPBCompileTest04.m b/objectivec/Tests/GPBCompileTest04.m
new file mode 100644
index 00000000..c31498f1
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest04.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "GPBDescriptor.h"
+
+
+// Something in the body of this file so the compiler/linker won't complain
+// about an empty .o file.
+__attribute__((visibility("default"))) char dummy_symbol_4 = 0;
diff --git a/objectivec/Tests/GPBCompileTest05.m b/objectivec/Tests/GPBCompileTest05.m
new file mode 100644
index 00000000..adb72252
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest05.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "GPBDictionary.h"
+
+
+// Something in the body of this file so the compiler/linker won't complain
+// about an empty .o file.
+__attribute__((visibility("default"))) char dummy_symbol_5 = 0;
diff --git a/objectivec/Tests/GPBCompileTest06.m b/objectivec/Tests/GPBCompileTest06.m
new file mode 100644
index 00000000..b7505b02
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest06.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "GPBExtensionRegistry.h"
+
+
+// Something in the body of this file so the compiler/linker won't complain
+// about an empty .o file.
+__attribute__((visibility("default"))) char dummy_symbol_6 = 0;
diff --git a/objectivec/Tests/GPBCompileTest07.m b/objectivec/Tests/GPBCompileTest07.m
new file mode 100644
index 00000000..939bb709
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest07.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "GPBMessage.h"
+
+
+// Something in the body of this file so the compiler/linker won't complain
+// about an empty .o file.
+__attribute__((visibility("default"))) char dummy_symbol_7 = 0;
diff --git a/objectivec/Tests/GPBCompileTest08.m b/objectivec/Tests/GPBCompileTest08.m
new file mode 100644
index 00000000..a84f38cf
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest08.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "GPBRootObject.h"
+
+
+// Something in the body of this file so the compiler/linker won't complain
+// about an empty .o file.
+__attribute__((visibility("default"))) char dummy_symbol_8 = 0;
diff --git a/objectivec/Tests/GPBCompileTest09.m b/objectivec/Tests/GPBCompileTest09.m
new file mode 100644
index 00000000..f8ccb4a0
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest09.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "GPBUnknownField.h"
+
+
+// Something in the body of this file so the compiler/linker won't complain
+// about an empty .o file.
+__attribute__((visibility("default"))) char dummy_symbol_9 = 0;
diff --git a/objectivec/Tests/GPBCompileTest10.m b/objectivec/Tests/GPBCompileTest10.m
new file mode 100644
index 00000000..d8318678
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest10.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "GPBUnknownFieldSet.h"
+
+
+// Something in the body of this file so the compiler/linker won't complain
+// about an empty .o file.
+__attribute__((visibility("default"))) char dummy_symbol_10 = 0;
diff --git a/objectivec/Tests/GPBCompileTest11.m b/objectivec/Tests/GPBCompileTest11.m
new file mode 100644
index 00000000..9f2c6b11
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest11.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "GPBUtilities.h"
+
+
+// Something in the body of this file so the compiler/linker won't complain
+// about an empty .o file.
+__attribute__((visibility("default"))) char dummy_symbol_11 = 0;
diff --git a/objectivec/Tests/GPBCompileTest12.m b/objectivec/Tests/GPBCompileTest12.m
new file mode 100644
index 00000000..3aa29b31
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest12.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "GPBWellKnownTypes.h"
+
+
+// Something in the body of this file so the compiler/linker won't complain
+// about an empty .o file.
+__attribute__((visibility("default"))) char dummy_symbol_12 = 0;
diff --git a/objectivec/Tests/GPBCompileTest13.m b/objectivec/Tests/GPBCompileTest13.m
new file mode 100644
index 00000000..fef2af5f
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest13.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "GPBWireFormat.h"
+
+
+// Something in the body of this file so the compiler/linker won't complain
+// about an empty .o file.
+__attribute__((visibility("default"))) char dummy_symbol_13 = 0;
diff --git a/objectivec/Tests/GPBCompileTest14.m b/objectivec/Tests/GPBCompileTest14.m
new file mode 100644
index 00000000..ae04349a
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest14.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "google/protobuf/Any.pbobjc.h"
+
+
+// Something in the body of this file so the compiler/linker won't complain
+// about an empty .o file.
+__attribute__((visibility("default"))) char dummy_symbol_14 = 0;
diff --git a/objectivec/Tests/GPBCompileTest15.m b/objectivec/Tests/GPBCompileTest15.m
new file mode 100644
index 00000000..889243aa
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest15.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "google/protobuf/Api.pbobjc.h"
+
+
+// Something in the body of this file so the compiler/linker won't complain
+// about an empty .o file.
+__attribute__((visibility("default"))) char dummy_symbol_15 = 0;
diff --git a/objectivec/Tests/GPBCompileTest16.m b/objectivec/Tests/GPBCompileTest16.m
new file mode 100644
index 00000000..c5aaf14f
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest16.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "google/protobuf/Duration.pbobjc.h"
+
+
+// Something in the body of this file so the compiler/linker won't complain
+// about an empty .o file.
+__attribute__((visibility("default"))) char dummy_symbol_16 = 0;
diff --git a/objectivec/Tests/GPBCompileTest17.m b/objectivec/Tests/GPBCompileTest17.m
new file mode 100644
index 00000000..feb64d66
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest17.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "google/protobuf/Empty.pbobjc.h"
+
+
+// Something in the body of this file so the compiler/linker won't complain
+// about an empty .o file.
+__attribute__((visibility("default"))) char dummy_symbol_17 = 0;
diff --git a/objectivec/Tests/GPBCompileTest18.m b/objectivec/Tests/GPBCompileTest18.m
new file mode 100644
index 00000000..66784c4f
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest18.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "google/protobuf/FieldMask.pbobjc.h"
+
+
+// Something in the body of this file so the compiler/linker won't complain
+// about an empty .o file.
+__attribute__((visibility("default"))) char dummy_symbol_18 = 0;
diff --git a/objectivec/Tests/GPBCompileTest19.m b/objectivec/Tests/GPBCompileTest19.m
new file mode 100644
index 00000000..435dea01
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest19.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "google/protobuf/SourceContext.pbobjc.h"
+
+
+// Something in the body of this file so the compiler/linker won't complain
+// about an empty .o file.
+__attribute__((visibility("default"))) char dummy_symbol_19 = 0;
diff --git a/objectivec/Tests/GPBCompileTest20.m b/objectivec/Tests/GPBCompileTest20.m
new file mode 100644
index 00000000..c2da8066
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest20.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "google/protobuf/Struct.pbobjc.h"
+
+
+// Something in the body of this file so the compiler/linker won't complain
+// about an empty .o file.
+__attribute__((visibility("default"))) char dummy_symbol_20 = 0;
diff --git a/objectivec/Tests/GPBCompileTest21.m b/objectivec/Tests/GPBCompileTest21.m
new file mode 100644
index 00000000..d7110b93
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest21.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "google/protobuf/Timestamp.pbobjc.h"
+
+
+// Something in the body of this file so the compiler/linker won't complain
+// about an empty .o file.
+__attribute__((visibility("default"))) char dummy_symbol_21 = 0;
diff --git a/objectivec/Tests/GPBCompileTest22.m b/objectivec/Tests/GPBCompileTest22.m
new file mode 100644
index 00000000..17380618
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest22.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "google/protobuf/Type.pbobjc.h"
+
+
+// Something in the body of this file so the compiler/linker won't complain
+// about an empty .o file.
+__attribute__((visibility("default"))) char dummy_symbol_22 = 0;
diff --git a/objectivec/Tests/GPBCompileTest23.m b/objectivec/Tests/GPBCompileTest23.m
new file mode 100644
index 00000000..f22f9bdd
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest23.m
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single public header to ensure things build.
+// It helps test that imports are complete/ordered correctly.
+
+#import "google/protobuf/Wrappers.pbobjc.h"
+
+
+// Something in the body of this file so the compiler/linker won't complain
+// about an empty .o file.
+__attribute__((visibility("default"))) char dummy_symbol_23 = 0;
diff --git a/objectivec/Tests/GPBCompileTest24.m b/objectivec/Tests/GPBCompileTest24.m
new file mode 100644
index 00000000..c81ea732
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest24.m
@@ -0,0 +1,42 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single header to ensure things build. This
+// is NOT a public header of the library, but uses a file that defines
+// proto2 syntax messages that are extendable, so it can need more things
+// that the proto3 syntax WKTs bundled with the library.
+
+#import "google/protobuf/Descriptor.pbobjc.h"
+
+
+// Something in the body of this file so the compiler/linker won't complain
+// about an empty .o file.
+__attribute__((visibility("default"))) char dummy_symbol_24 = 0;
diff --git a/objectivec/Tests/GPBCompileTest25.m b/objectivec/Tests/GPBCompileTest25.m
new file mode 100644
index 00000000..7a482b51
--- /dev/null
+++ b/objectivec/Tests/GPBCompileTest25.m
@@ -0,0 +1,42 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// This is a test including a single header to ensure things build. This
+// is NOT a public header of the library, but uses a file that defines
+// extensions to proto2 syntax messages, so it can need more things
+// that the proto3 syntax WKTs bundled with the library.
+
+#import "google/protobuf/UnittestCustomOptions.pbobjc.h"
+
+
+// Something in the body of this file so the compiler/linker won't complain
+// about an empty .o file.
+__attribute__((visibility("default"))) char dummy_symbol_25 = 0;
diff --git a/objectivec/Tests/GPBDescriptorTests.m b/objectivec/Tests/GPBDescriptorTests.m
index ccdbb645..d47cc30f 100644
--- a/objectivec/Tests/GPBDescriptorTests.m
+++ b/objectivec/Tests/GPBDescriptorTests.m
@@ -32,14 +32,43 @@
#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"
@interface DescriptorTests : GPBTestCase
@end
@implementation DescriptorTests
+- (void)testDescriptor_containingType {
+ GPBDescriptor *testAllTypesDesc = [TestAllTypes descriptor];
+ GPBDescriptor *nestedMessageDesc = [TestAllTypes_NestedMessage descriptor];
+ XCTAssertNil(testAllTypesDesc.containingType);
+ XCTAssertNotNil(nestedMessageDesc.containingType);
+ XCTAssertEqual(nestedMessageDesc.containingType, testAllTypesDesc); // Ptr comparison
+}
+
+- (void)testDescriptor_fullName {
+ GPBDescriptor *testAllTypesDesc = [TestAllTypes descriptor];
+ XCTAssertEqualObjects(testAllTypesDesc.fullName, @"protobuf_unittest.TestAllTypes");
+ GPBDescriptor *nestedMessageDesc = [TestAllTypes_NestedMessage descriptor];
+ XCTAssertEqualObjects(nestedMessageDesc.fullName, @"protobuf_unittest.TestAllTypes.NestedMessage");
+
+ // Prefixes removed.
+ GPBDescriptor *descDesc = [GPBDescriptorProto descriptor];
+ XCTAssertEqualObjects(descDesc.fullName, @"google.protobuf.DescriptorProto");
+ GPBDescriptor *descExtRngDesc = [GPBDescriptorProto_ExtensionRange descriptor];
+ XCTAssertEqualObjects(descExtRngDesc.fullName, @"google.protobuf.DescriptorProto.ExtensionRange");
+
+ // Things that get "_Class" added.
+ GPBDescriptor *pointDesc = [Point_Class descriptor];
+ XCTAssertEqualObjects(pointDesc.fullName, @"protobuf_unittest.Point");
+ GPBDescriptor *pointRectDesc = [Point_Rect descriptor];
+ XCTAssertEqualObjects(pointRectDesc.fullName, @"protobuf_unittest.Point.Rect");
+}
+
- (void)testFieldDescriptor {
GPBDescriptor *descriptor = [TestAllTypes descriptor];
@@ -54,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"];
@@ -64,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"];
@@ -74,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"];
@@ -82,6 +117,8 @@
XCTAssertNotNil(fieldDescriptorWithNumber);
XCTAssertEqual(fieldDescriptorWithName, fieldDescriptorWithNumber);
XCTAssertNil(fieldDescriptorWithNumber.enumDescriptor);
+ XCTAssertEqual(fieldDescriptorWithName.number, fieldDescriptorWithNumber.number);
+ XCTAssertEqual(fieldDescriptorWithName.dataType, GPBDataTypeMessage);
// Foreign Message
fieldDescriptorWithName =
@@ -91,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"];
@@ -99,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 {
@@ -125,6 +170,13 @@
[descriptor getValue:&value forEnumName:@"TestAllTypes_NestedEnum_Baz"]);
XCTAssertEqual(value, TestAllTypes_NestedEnum_Baz);
+ // TextFormat
+ enumName = [descriptor textFormatNameForValue:1];
+ XCTAssertNotNil(enumName);
+ XCTAssertTrue([descriptor getValue:&value forEnumTextFormatName:@"FOO"]);
+ XCTAssertEqual(value, TestAllTypes_NestedEnum_Foo);
+ XCTAssertNil([descriptor textFormatNameForValue:99999]);
+
// Bad values
enumName = [descriptor enumNameForValue:0];
XCTAssertNil(enumName);
@@ -134,6 +186,65 @@
forEnumName:@"TestAllTypes_NestedEnum_Unknown"]);
XCTAssertFalse([descriptor getValue:NULL
forEnumName:@"TestAllTypes_NestedEnum_Unknown"]);
+ XCTAssertFalse([descriptor getValue:NULL forEnumTextFormatName:@"Unknown"]);
+ XCTAssertFalse([descriptor getValue:&value forEnumTextFormatName:@"Unknown"]);
+}
+
+- (void)testEnumDescriptorIntrospection {
+ GPBEnumDescriptor *descriptor = TestAllTypes_NestedEnum_EnumDescriptor();
+
+ XCTAssertEqual(descriptor.enumNameCount, 4U);
+ XCTAssertEqualObjects([descriptor getEnumNameForIndex:0],
+ @"TestAllTypes_NestedEnum_Foo");
+ XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:0], @"FOO");
+ XCTAssertEqualObjects([descriptor getEnumNameForIndex:1],
+ @"TestAllTypes_NestedEnum_Bar");
+ XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:1], @"BAR");
+ XCTAssertEqualObjects([descriptor getEnumNameForIndex:2],
+ @"TestAllTypes_NestedEnum_Baz");
+ XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:2], @"BAZ");
+ XCTAssertEqualObjects([descriptor getEnumNameForIndex:3],
+ @"TestAllTypes_NestedEnum_Neg");
+ XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:3], @"NEG");
+}
+
+- (void)testEnumDescriptorIntrospectionWithAlias {
+ GPBEnumDescriptor *descriptor = TestEnumWithDupValue_EnumDescriptor();
+ NSString *enumName;
+ int32_t value;
+
+ XCTAssertEqual(descriptor.enumNameCount, 5U);
+
+ enumName = [descriptor getEnumNameForIndex:0];
+ XCTAssertEqualObjects(enumName, @"TestEnumWithDupValue_Foo1");
+ XCTAssertTrue([descriptor getValue:&value forEnumName:enumName]);
+ XCTAssertEqual(value, 1);
+ XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:0], @"FOO1");
+
+ enumName = [descriptor getEnumNameForIndex:1];
+ XCTAssertEqualObjects(enumName, @"TestEnumWithDupValue_Bar1");
+ XCTAssertTrue([descriptor getValue:&value forEnumName:enumName]);
+ XCTAssertEqual(value, 2);
+ XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:1], @"BAR1");
+
+ enumName = [descriptor getEnumNameForIndex:2];
+ XCTAssertEqualObjects(enumName, @"TestEnumWithDupValue_Baz");
+ XCTAssertTrue([descriptor getValue:&value forEnumName:enumName]);
+ XCTAssertEqual(value, 3);
+ XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:2], @"BAZ");
+
+ enumName = [descriptor getEnumNameForIndex:3];
+ XCTAssertEqualObjects(enumName, @"TestEnumWithDupValue_Foo2");
+ XCTAssertTrue([descriptor getValue:&value forEnumName:enumName]);
+ XCTAssertEqual(value, 1);
+ XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:3], @"FOO2");
+
+ enumName = [descriptor getEnumNameForIndex:4];
+ XCTAssertEqualObjects(enumName, @"TestEnumWithDupValue_Bar2");
+ XCTAssertTrue([descriptor getValue:&value forEnumName:enumName]);
+ XCTAssertEqual(value, 2);
+ XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:4], @"BAR2");
+
}
- (void)testEnumValueValidator {
@@ -153,19 +264,6 @@
XCTAssertFalse([fieldDescriptor isValidEnumValue:-2]);
}
-- (void)testEnumDescriptorLookup {
- GPBDescriptor *descriptor = [TestAllTypes descriptor];
- GPBEnumDescriptor *enumDescriptor =
- [descriptor enumWithName:@"TestAllTypes_NestedEnum"];
- XCTAssertNotNil(enumDescriptor);
-
- // Descriptor cannot find foreign or imported enums.
- enumDescriptor = [descriptor enumWithName:@"ForeignEnumEnum"];
- XCTAssertNil(enumDescriptor);
- enumDescriptor = [descriptor enumWithName:@"ImportEnumEnum"];
- XCTAssertNil(enumDescriptor);
-}
-
- (void)testOneofDescriptor {
GPBDescriptor *descriptor = [TestOneof2 descriptor];
@@ -229,4 +327,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
diff --git a/objectivec/Tests/GPBDictionaryTests+Bool.m b/objectivec/Tests/GPBDictionaryTests+Bool.m
index 8b1900fe..0af0c815 100644
--- a/objectivec/Tests/GPBDictionaryTests+Bool.m
+++ b/objectivec/Tests/GPBDictionaryTests+Bool.m
@@ -54,8 +54,8 @@
GPBBoolUInt32Dictionary *dict = [[GPBBoolUInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:YES value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, uint32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt32:NULL forKey:YES]);
+ [dict enumerateKeysAndUInt32sUsingBlock:^(BOOL aKey, uint32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -63,42 +63,44 @@
}
- (void)testOne {
- GPBBoolUInt32Dictionary *dict = [GPBBoolUInt32Dictionary dictionaryWithValue:100U forKey:YES];
+ GPBBoolUInt32Dictionary *dict = [[GPBBoolUInt32Dictionary alloc] init];
+ [dict setUInt32:100U forKey:YES];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt32:&value forKey:YES]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, uint32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt32:NULL forKey:NO]);
+ [dict enumerateKeysAndUInt32sUsingBlock:^(BOOL aKey, uint32_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, YES);
XCTAssertEqual(aValue, 100U);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const BOOL kKeys[] = { YES, NO };
const uint32_t kValues[] = { 100U, 101U };
GPBBoolUInt32Dictionary *dict =
- [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt32:&value forKey:YES]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:NO]);
+ XCTAssertTrue([dict getUInt32:&value forKey:NO]);
XCTAssertEqual(value, 101U);
__block NSUInteger idx = 0;
BOOL *seenKeys = malloc(2 * sizeof(BOOL));
uint32_t *seenValues = malloc(2 * sizeof(uint32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, uint32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt32sUsingBlock:^(BOOL aKey, uint32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 2U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -120,7 +122,7 @@
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, uint32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt32sUsingBlock:^(BOOL aKey, uint32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 0) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -136,29 +138,29 @@
const uint32_t kValues2[] = { 101U, 100U };
const uint32_t kValues3[] = { 101U };
GPBBoolUInt32Dictionary *dict1 =
- [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBBoolUInt32Dictionary *dict1prime =
- [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBBoolUInt32Dictionary *dict2 =
- [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBBoolUInt32Dictionary *dict3 =
- [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBBoolUInt32Dictionary *dict4 =
- [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -187,9 +189,9 @@
const BOOL kKeys[] = { YES, NO };
const uint32_t kValues[] = { 100U, 101U };
GPBBoolUInt32Dictionary *dict =
- [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBBoolUInt32Dictionary *dict2 = [dict copy];
@@ -208,79 +210,81 @@
const BOOL kKeys[] = { YES, NO };
const uint32_t kValues[] = { 100U, 101U };
GPBBoolUInt32Dictionary *dict =
- [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBBoolUInt32Dictionary *dict2 =
- [GPBBoolUInt32Dictionary dictionaryWithDictionary:dict];
+ [[GPBBoolUInt32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBBoolUInt32Dictionary *dict = [GPBBoolUInt32Dictionary dictionary];
+ GPBBoolUInt32Dictionary *dict = [[GPBBoolUInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:100U forKey:YES];
+ [dict setUInt32:100U forKey:YES];
XCTAssertEqual(dict.count, 1U);
const BOOL kKeys[] = { NO };
const uint32_t kValues[] = { 101U };
GPBBoolUInt32Dictionary *dict2 =
- [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 2U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt32:&value forKey:YES]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:NO]);
+ XCTAssertTrue([dict getUInt32:&value forKey:NO]);
XCTAssertEqual(value, 101U);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const BOOL kKeys[] = { YES, NO};
const uint32_t kValues[] = { 100U, 101U };
GPBBoolUInt32Dictionary *dict =
- [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
- [dict removeValueForKey:NO];
+ [dict removeUInt32ForKey:NO];
XCTAssertEqual(dict.count, 1U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt32:&value forKey:YES]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:NO]);
// Remove again does nothing.
- [dict removeValueForKey:NO];
+ [dict removeUInt32ForKey:NO];
XCTAssertEqual(dict.count, 1U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt32:&value forKey:YES]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:NO]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:YES value:NULL]);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:YES]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:NO]);
[dict release];
}
@@ -288,51 +292,51 @@
const BOOL kKeys[] = { YES, NO };
const uint32_t kValues[] = { 100U, 101U };
GPBBoolUInt32Dictionary *dict =
- [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt32:&value forKey:YES]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:NO]);
+ XCTAssertTrue([dict getUInt32:&value forKey:NO]);
XCTAssertEqual(value, 101U);
- [dict setValue:101U forKey:YES];
+ [dict setUInt32:101U forKey:YES];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt32:&value forKey:YES]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:NO]);
+ XCTAssertTrue([dict getUInt32:&value forKey:NO]);
XCTAssertEqual(value, 101U);
- [dict setValue:100U forKey:NO];
+ [dict setUInt32:100U forKey:NO];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt32:&value forKey:YES]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:NO]);
+ XCTAssertTrue([dict getUInt32:&value forKey:NO]);
XCTAssertEqual(value, 100U);
const BOOL kKeys2[] = { NO, YES };
const uint32_t kValues2[] = { 101U, 100U };
GPBBoolUInt32Dictionary *dict2 =
- [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt32:&value forKey:YES]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:NO]);
+ XCTAssertTrue([dict getUInt32:&value forKey:NO]);
XCTAssertEqual(value, 101U);
[dict2 release];
@@ -355,8 +359,8 @@
GPBBoolInt32Dictionary *dict = [[GPBBoolInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:YES value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt32:NULL forKey:YES]);
+ [dict enumerateKeysAndInt32sUsingBlock:^(BOOL aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -364,42 +368,44 @@
}
- (void)testOne {
- GPBBoolInt32Dictionary *dict = [GPBBoolInt32Dictionary dictionaryWithValue:200 forKey:YES];
+ GPBBoolInt32Dictionary *dict = [[GPBBoolInt32Dictionary alloc] init];
+ [dict setInt32:200 forKey:YES];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt32:&value forKey:YES]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt32:NULL forKey:NO]);
+ [dict enumerateKeysAndInt32sUsingBlock:^(BOOL aKey, int32_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, YES);
XCTAssertEqual(aValue, 200);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const BOOL kKeys[] = { YES, NO };
const int32_t kValues[] = { 200, 201 };
GPBBoolInt32Dictionary *dict =
- [[GPBBoolInt32Dictionary alloc] initWithValues:kValues
+ [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
int32_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt32:&value forKey:YES]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:NO]);
+ XCTAssertTrue([dict getInt32:&value forKey:NO]);
XCTAssertEqual(value, 201);
__block NSUInteger idx = 0;
BOOL *seenKeys = malloc(2 * sizeof(BOOL));
int32_t *seenValues = malloc(2 * sizeof(int32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt32sUsingBlock:^(BOOL aKey, int32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 2U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -421,7 +427,7 @@
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt32sUsingBlock:^(BOOL aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 0) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -437,27 +443,27 @@
const int32_t kValues2[] = { 201, 200 };
const int32_t kValues3[] = { 201 };
GPBBoolInt32Dictionary *dict1 =
- [[GPBBoolInt32Dictionary alloc] initWithValues:kValues1
+ [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBBoolInt32Dictionary *dict1prime =
- [[GPBBoolInt32Dictionary alloc] initWithValues:kValues1
+ [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBBoolInt32Dictionary *dict2 =
- [[GPBBoolInt32Dictionary alloc] initWithValues:kValues2
+ [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBBoolInt32Dictionary *dict3 =
- [[GPBBoolInt32Dictionary alloc] initWithValues:kValues1
+ [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBBoolInt32Dictionary *dict4 =
- [[GPBBoolInt32Dictionary alloc] initWithValues:kValues3
+ [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -488,7 +494,7 @@
const BOOL kKeys[] = { YES, NO };
const int32_t kValues[] = { 200, 201 };
GPBBoolInt32Dictionary *dict =
- [[GPBBoolInt32Dictionary alloc] initWithValues:kValues
+ [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -509,33 +515,34 @@
const BOOL kKeys[] = { YES, NO };
const int32_t kValues[] = { 200, 201 };
GPBBoolInt32Dictionary *dict =
- [[GPBBoolInt32Dictionary alloc] initWithValues:kValues
+ [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBBoolInt32Dictionary *dict2 =
- [GPBBoolInt32Dictionary dictionaryWithDictionary:dict];
+ [[GPBBoolInt32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBBoolInt32Dictionary *dict = [GPBBoolInt32Dictionary dictionary];
+ GPBBoolInt32Dictionary *dict = [[GPBBoolInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:200 forKey:YES];
+ [dict setInt32:200 forKey:YES];
XCTAssertEqual(dict.count, 1U);
const BOOL kKeys[] = { NO };
const int32_t kValues[] = { 201 };
GPBBoolInt32Dictionary *dict2 =
- [[GPBBoolInt32Dictionary alloc] initWithValues:kValues
+ [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -543,45 +550,46 @@
XCTAssertEqual(dict.count, 2U);
int32_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt32:&value forKey:YES]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:NO]);
+ XCTAssertTrue([dict getInt32:&value forKey:NO]);
XCTAssertEqual(value, 201);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const BOOL kKeys[] = { YES, NO};
const int32_t kValues[] = { 200, 201 };
GPBBoolInt32Dictionary *dict =
- [[GPBBoolInt32Dictionary alloc] initWithValues:kValues
+ [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
- [dict removeValueForKey:NO];
+ [dict removeInt32ForKey:NO];
XCTAssertEqual(dict.count, 1U);
int32_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt32:&value forKey:YES]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:NO]);
// Remove again does nothing.
- [dict removeValueForKey:NO];
+ [dict removeInt32ForKey:NO];
XCTAssertEqual(dict.count, 1U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt32:&value forKey:YES]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:NO]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:YES value:NULL]);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:YES]);
+ XCTAssertFalse([dict getInt32:NULL forKey:NO]);
[dict release];
}
@@ -589,51 +597,51 @@
const BOOL kKeys[] = { YES, NO };
const int32_t kValues[] = { 200, 201 };
GPBBoolInt32Dictionary *dict =
- [[GPBBoolInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
int32_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt32:&value forKey:YES]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:NO]);
+ XCTAssertTrue([dict getInt32:&value forKey:NO]);
XCTAssertEqual(value, 201);
- [dict setValue:201 forKey:YES];
+ [dict setInt32:201 forKey:YES];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt32:&value forKey:YES]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:NO]);
+ XCTAssertTrue([dict getInt32:&value forKey:NO]);
XCTAssertEqual(value, 201);
- [dict setValue:200 forKey:NO];
+ [dict setInt32:200 forKey:NO];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt32:&value forKey:YES]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:NO]);
+ XCTAssertTrue([dict getInt32:&value forKey:NO]);
XCTAssertEqual(value, 200);
const BOOL kKeys2[] = { NO, YES };
const int32_t kValues2[] = { 201, 200 };
GPBBoolInt32Dictionary *dict2 =
- [[GPBBoolInt32Dictionary alloc] initWithValues:kValues2
+ [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt32:&value forKey:YES]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:NO]);
+ XCTAssertTrue([dict getInt32:&value forKey:NO]);
XCTAssertEqual(value, 201);
[dict2 release];
@@ -656,8 +664,8 @@
GPBBoolUInt64Dictionary *dict = [[GPBBoolUInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:YES value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, uint64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt64:NULL forKey:YES]);
+ [dict enumerateKeysAndUInt64sUsingBlock:^(BOOL aKey, uint64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -665,42 +673,44 @@
}
- (void)testOne {
- GPBBoolUInt64Dictionary *dict = [GPBBoolUInt64Dictionary dictionaryWithValue:300U forKey:YES];
+ GPBBoolUInt64Dictionary *dict = [[GPBBoolUInt64Dictionary alloc] init];
+ [dict setUInt64:300U forKey:YES];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt64:&value forKey:YES]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, uint64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt64:NULL forKey:NO]);
+ [dict enumerateKeysAndUInt64sUsingBlock:^(BOOL aKey, uint64_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, YES);
XCTAssertEqual(aValue, 300U);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const BOOL kKeys[] = { YES, NO };
const uint64_t kValues[] = { 300U, 301U };
GPBBoolUInt64Dictionary *dict =
- [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt64:&value forKey:YES]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:NO]);
+ XCTAssertTrue([dict getUInt64:&value forKey:NO]);
XCTAssertEqual(value, 301U);
__block NSUInteger idx = 0;
BOOL *seenKeys = malloc(2 * sizeof(BOOL));
uint64_t *seenValues = malloc(2 * sizeof(uint64_t));
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, uint64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt64sUsingBlock:^(BOOL aKey, uint64_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 2U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -722,7 +732,7 @@
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, uint64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt64sUsingBlock:^(BOOL aKey, uint64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 0) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -738,29 +748,29 @@
const uint64_t kValues2[] = { 301U, 300U };
const uint64_t kValues3[] = { 301U };
GPBBoolUInt64Dictionary *dict1 =
- [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBBoolUInt64Dictionary *dict1prime =
- [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBBoolUInt64Dictionary *dict2 =
- [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBBoolUInt64Dictionary *dict3 =
- [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBBoolUInt64Dictionary *dict4 =
- [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -789,9 +799,9 @@
const BOOL kKeys[] = { YES, NO };
const uint64_t kValues[] = { 300U, 301U };
GPBBoolUInt64Dictionary *dict =
- [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBBoolUInt64Dictionary *dict2 = [dict copy];
@@ -810,79 +820,81 @@
const BOOL kKeys[] = { YES, NO };
const uint64_t kValues[] = { 300U, 301U };
GPBBoolUInt64Dictionary *dict =
- [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBBoolUInt64Dictionary *dict2 =
- [GPBBoolUInt64Dictionary dictionaryWithDictionary:dict];
+ [[GPBBoolUInt64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBBoolUInt64Dictionary *dict = [GPBBoolUInt64Dictionary dictionary];
+ GPBBoolUInt64Dictionary *dict = [[GPBBoolUInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:300U forKey:YES];
+ [dict setUInt64:300U forKey:YES];
XCTAssertEqual(dict.count, 1U);
const BOOL kKeys[] = { NO };
const uint64_t kValues[] = { 301U };
GPBBoolUInt64Dictionary *dict2 =
- [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 2U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt64:&value forKey:YES]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:NO]);
+ XCTAssertTrue([dict getUInt64:&value forKey:NO]);
XCTAssertEqual(value, 301U);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const BOOL kKeys[] = { YES, NO};
const uint64_t kValues[] = { 300U, 301U };
GPBBoolUInt64Dictionary *dict =
- [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
- [dict removeValueForKey:NO];
+ [dict removeUInt64ForKey:NO];
XCTAssertEqual(dict.count, 1U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt64:&value forKey:YES]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:NO]);
// Remove again does nothing.
- [dict removeValueForKey:NO];
+ [dict removeUInt64ForKey:NO];
XCTAssertEqual(dict.count, 1U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt64:&value forKey:YES]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:NO]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:YES value:NULL]);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:YES]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:NO]);
[dict release];
}
@@ -890,51 +902,51 @@
const BOOL kKeys[] = { YES, NO };
const uint64_t kValues[] = { 300U, 301U };
GPBBoolUInt64Dictionary *dict =
- [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt64:&value forKey:YES]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:NO]);
+ XCTAssertTrue([dict getUInt64:&value forKey:NO]);
XCTAssertEqual(value, 301U);
- [dict setValue:301U forKey:YES];
+ [dict setUInt64:301U forKey:YES];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt64:&value forKey:YES]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:NO]);
+ XCTAssertTrue([dict getUInt64:&value forKey:NO]);
XCTAssertEqual(value, 301U);
- [dict setValue:300U forKey:NO];
+ [dict setUInt64:300U forKey:NO];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt64:&value forKey:YES]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:NO]);
+ XCTAssertTrue([dict getUInt64:&value forKey:NO]);
XCTAssertEqual(value, 300U);
const BOOL kKeys2[] = { NO, YES };
const uint64_t kValues2[] = { 301U, 300U };
GPBBoolUInt64Dictionary *dict2 =
- [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getUInt64:&value forKey:YES]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:NO]);
+ XCTAssertTrue([dict getUInt64:&value forKey:NO]);
XCTAssertEqual(value, 301U);
[dict2 release];
@@ -957,8 +969,8 @@
GPBBoolInt64Dictionary *dict = [[GPBBoolInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:YES value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, int64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt64:NULL forKey:YES]);
+ [dict enumerateKeysAndInt64sUsingBlock:^(BOOL aKey, int64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -966,42 +978,44 @@
}
- (void)testOne {
- GPBBoolInt64Dictionary *dict = [GPBBoolInt64Dictionary dictionaryWithValue:400 forKey:YES];
+ GPBBoolInt64Dictionary *dict = [[GPBBoolInt64Dictionary alloc] init];
+ [dict setInt64:400 forKey:YES];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int64_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt64:&value forKey:YES]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, int64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt64:NULL forKey:NO]);
+ [dict enumerateKeysAndInt64sUsingBlock:^(BOOL aKey, int64_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, YES);
XCTAssertEqual(aValue, 400);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const BOOL kKeys[] = { YES, NO };
const int64_t kValues[] = { 400, 401 };
GPBBoolInt64Dictionary *dict =
- [[GPBBoolInt64Dictionary alloc] initWithValues:kValues
+ [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
int64_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt64:&value forKey:YES]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:NO]);
+ XCTAssertTrue([dict getInt64:&value forKey:NO]);
XCTAssertEqual(value, 401);
__block NSUInteger idx = 0;
BOOL *seenKeys = malloc(2 * sizeof(BOOL));
int64_t *seenValues = malloc(2 * sizeof(int64_t));
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, int64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt64sUsingBlock:^(BOOL aKey, int64_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 2U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1023,7 +1037,7 @@
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, int64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt64sUsingBlock:^(BOOL aKey, int64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 0) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1039,27 +1053,27 @@
const int64_t kValues2[] = { 401, 400 };
const int64_t kValues3[] = { 401 };
GPBBoolInt64Dictionary *dict1 =
- [[GPBBoolInt64Dictionary alloc] initWithValues:kValues1
+ [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBBoolInt64Dictionary *dict1prime =
- [[GPBBoolInt64Dictionary alloc] initWithValues:kValues1
+ [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBBoolInt64Dictionary *dict2 =
- [[GPBBoolInt64Dictionary alloc] initWithValues:kValues2
+ [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBBoolInt64Dictionary *dict3 =
- [[GPBBoolInt64Dictionary alloc] initWithValues:kValues1
+ [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBBoolInt64Dictionary *dict4 =
- [[GPBBoolInt64Dictionary alloc] initWithValues:kValues3
+ [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -1090,7 +1104,7 @@
const BOOL kKeys[] = { YES, NO };
const int64_t kValues[] = { 400, 401 };
GPBBoolInt64Dictionary *dict =
- [[GPBBoolInt64Dictionary alloc] initWithValues:kValues
+ [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -1111,33 +1125,34 @@
const BOOL kKeys[] = { YES, NO };
const int64_t kValues[] = { 400, 401 };
GPBBoolInt64Dictionary *dict =
- [[GPBBoolInt64Dictionary alloc] initWithValues:kValues
+ [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBBoolInt64Dictionary *dict2 =
- [GPBBoolInt64Dictionary dictionaryWithDictionary:dict];
+ [[GPBBoolInt64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBBoolInt64Dictionary *dict = [GPBBoolInt64Dictionary dictionary];
+ GPBBoolInt64Dictionary *dict = [[GPBBoolInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:400 forKey:YES];
+ [dict setInt64:400 forKey:YES];
XCTAssertEqual(dict.count, 1U);
const BOOL kKeys[] = { NO };
const int64_t kValues[] = { 401 };
GPBBoolInt64Dictionary *dict2 =
- [[GPBBoolInt64Dictionary alloc] initWithValues:kValues
+ [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -1145,45 +1160,46 @@
XCTAssertEqual(dict.count, 2U);
int64_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt64:&value forKey:YES]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:NO]);
+ XCTAssertTrue([dict getInt64:&value forKey:NO]);
XCTAssertEqual(value, 401);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const BOOL kKeys[] = { YES, NO};
const int64_t kValues[] = { 400, 401 };
GPBBoolInt64Dictionary *dict =
- [[GPBBoolInt64Dictionary alloc] initWithValues:kValues
+ [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
- [dict removeValueForKey:NO];
+ [dict removeInt64ForKey:NO];
XCTAssertEqual(dict.count, 1U);
int64_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt64:&value forKey:YES]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:NO]);
// Remove again does nothing.
- [dict removeValueForKey:NO];
+ [dict removeInt64ForKey:NO];
XCTAssertEqual(dict.count, 1U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt64:&value forKey:YES]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:NO]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:YES value:NULL]);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:YES]);
+ XCTAssertFalse([dict getInt64:NULL forKey:NO]);
[dict release];
}
@@ -1191,51 +1207,51 @@
const BOOL kKeys[] = { YES, NO };
const int64_t kValues[] = { 400, 401 };
GPBBoolInt64Dictionary *dict =
- [[GPBBoolInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
int64_t value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt64:&value forKey:YES]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:NO]);
+ XCTAssertTrue([dict getInt64:&value forKey:NO]);
XCTAssertEqual(value, 401);
- [dict setValue:401 forKey:YES];
+ [dict setInt64:401 forKey:YES];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt64:&value forKey:YES]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:NO]);
+ XCTAssertTrue([dict getInt64:&value forKey:NO]);
XCTAssertEqual(value, 401);
- [dict setValue:400 forKey:NO];
+ [dict setInt64:400 forKey:NO];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt64:&value forKey:YES]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:NO]);
+ XCTAssertTrue([dict getInt64:&value forKey:NO]);
XCTAssertEqual(value, 400);
const BOOL kKeys2[] = { NO, YES };
const int64_t kValues2[] = { 401, 400 };
GPBBoolInt64Dictionary *dict2 =
- [[GPBBoolInt64Dictionary alloc] initWithValues:kValues2
+ [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:YES]);
+ XCTAssertTrue([dict getInt64:&value forKey:YES]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:NO]);
+ XCTAssertTrue([dict getInt64:&value forKey:NO]);
XCTAssertEqual(value, 401);
[dict2 release];
@@ -1258,8 +1274,8 @@
GPBBoolBoolDictionary *dict = [[GPBBoolBoolDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:YES value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, BOOL aValue, BOOL *stop) {
+ XCTAssertFalse([dict getBool:NULL forKey:YES]);
+ [dict enumerateKeysAndBoolsUsingBlock:^(BOOL aKey, BOOL aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1267,42 +1283,44 @@
}
- (void)testOne {
- GPBBoolBoolDictionary *dict = [GPBBoolBoolDictionary dictionaryWithValue:NO forKey:YES];
+ GPBBoolBoolDictionary *dict = [[GPBBoolBoolDictionary alloc] init];
+ [dict setBool:NO forKey:YES];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
BOOL value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:YES]);
+ XCTAssertTrue([dict getBool:&value forKey:YES]);
XCTAssertEqual(value, NO);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, BOOL aValue, BOOL *stop) {
+ XCTAssertFalse([dict getBool:NULL forKey:NO]);
+ [dict enumerateKeysAndBoolsUsingBlock:^(BOOL aKey, BOOL aValue, BOOL *stop) {
XCTAssertEqual(aKey, YES);
XCTAssertEqual(aValue, NO);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const BOOL kKeys[] = { YES, NO };
const BOOL kValues[] = { NO, YES };
GPBBoolBoolDictionary *dict =
- [[GPBBoolBoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolBoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
BOOL value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:YES]);
+ XCTAssertTrue([dict getBool:&value forKey:YES]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:NO]);
+ XCTAssertTrue([dict getBool:&value forKey:NO]);
XCTAssertEqual(value, YES);
__block NSUInteger idx = 0;
BOOL *seenKeys = malloc(2 * sizeof(BOOL));
BOOL *seenValues = malloc(2 * sizeof(BOOL));
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, BOOL aValue, BOOL *stop) {
+ [dict enumerateKeysAndBoolsUsingBlock:^(BOOL aKey, BOOL aValue, BOOL *stop) {
XCTAssertLessThan(idx, 2U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1324,7 +1342,7 @@
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, BOOL aValue, BOOL *stop) {
+ [dict enumerateKeysAndBoolsUsingBlock:^(BOOL aKey, BOOL aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 0) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1340,29 +1358,29 @@
const BOOL kValues2[] = { YES, NO };
const BOOL kValues3[] = { YES };
GPBBoolBoolDictionary *dict1 =
- [[GPBBoolBoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBBoolBoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBBoolBoolDictionary *dict1prime =
- [[GPBBoolBoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBBoolBoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBBoolBoolDictionary *dict2 =
- [[GPBBoolBoolDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBBoolBoolDictionary alloc] initWithBools:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBBoolBoolDictionary *dict3 =
- [[GPBBoolBoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBBoolBoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBBoolBoolDictionary *dict4 =
- [[GPBBoolBoolDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBBoolBoolDictionary alloc] initWithBools:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -1391,9 +1409,9 @@
const BOOL kKeys[] = { YES, NO };
const BOOL kValues[] = { NO, YES };
GPBBoolBoolDictionary *dict =
- [[GPBBoolBoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolBoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBBoolBoolDictionary *dict2 = [dict copy];
@@ -1412,79 +1430,81 @@
const BOOL kKeys[] = { YES, NO };
const BOOL kValues[] = { NO, YES };
GPBBoolBoolDictionary *dict =
- [[GPBBoolBoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolBoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBBoolBoolDictionary *dict2 =
- [GPBBoolBoolDictionary dictionaryWithDictionary:dict];
+ [[GPBBoolBoolDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBBoolBoolDictionary *dict = [GPBBoolBoolDictionary dictionary];
+ GPBBoolBoolDictionary *dict = [[GPBBoolBoolDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:NO forKey:YES];
+ [dict setBool:NO forKey:YES];
XCTAssertEqual(dict.count, 1U);
const BOOL kKeys[] = { NO };
const BOOL kValues[] = { YES };
GPBBoolBoolDictionary *dict2 =
- [[GPBBoolBoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolBoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 2U);
BOOL value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:YES]);
+ XCTAssertTrue([dict getBool:&value forKey:YES]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:NO]);
+ XCTAssertTrue([dict getBool:&value forKey:NO]);
XCTAssertEqual(value, YES);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const BOOL kKeys[] = { YES, NO};
const BOOL kValues[] = { NO, YES };
GPBBoolBoolDictionary *dict =
- [[GPBBoolBoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolBoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
- [dict removeValueForKey:NO];
+ [dict removeBoolForKey:NO];
XCTAssertEqual(dict.count, 1U);
BOOL value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:YES]);
+ XCTAssertTrue([dict getBool:&value forKey:YES]);
XCTAssertEqual(value, NO);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:NO]);
// Remove again does nothing.
- [dict removeValueForKey:NO];
+ [dict removeBoolForKey:NO];
XCTAssertEqual(dict.count, 1U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:YES]);
+ XCTAssertTrue([dict getBool:&value forKey:YES]);
XCTAssertEqual(value, NO);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:NO]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:YES value:NULL]);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:YES]);
+ XCTAssertFalse([dict getBool:NULL forKey:NO]);
[dict release];
}
@@ -1492,51 +1512,51 @@
const BOOL kKeys[] = { YES, NO };
const BOOL kValues[] = { NO, YES };
GPBBoolBoolDictionary *dict =
- [[GPBBoolBoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolBoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
BOOL value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:YES]);
+ XCTAssertTrue([dict getBool:&value forKey:YES]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:NO]);
+ XCTAssertTrue([dict getBool:&value forKey:NO]);
XCTAssertEqual(value, YES);
- [dict setValue:YES forKey:YES];
+ [dict setBool:YES forKey:YES];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:YES]);
+ XCTAssertTrue([dict getBool:&value forKey:YES]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:NO]);
+ XCTAssertTrue([dict getBool:&value forKey:NO]);
XCTAssertEqual(value, YES);
- [dict setValue:NO forKey:NO];
+ [dict setBool:NO forKey:NO];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:YES]);
+ XCTAssertTrue([dict getBool:&value forKey:YES]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:NO]);
+ XCTAssertTrue([dict getBool:&value forKey:NO]);
XCTAssertEqual(value, NO);
const BOOL kKeys2[] = { NO, YES };
const BOOL kValues2[] = { YES, NO };
GPBBoolBoolDictionary *dict2 =
- [[GPBBoolBoolDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBBoolBoolDictionary alloc] initWithBools:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:YES]);
+ XCTAssertTrue([dict getBool:&value forKey:YES]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:NO]);
+ XCTAssertTrue([dict getBool:&value forKey:NO]);
XCTAssertEqual(value, YES);
[dict2 release];
@@ -1559,8 +1579,8 @@
GPBBoolFloatDictionary *dict = [[GPBBoolFloatDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:YES value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, float aValue, BOOL *stop) {
+ XCTAssertFalse([dict getFloat:NULL forKey:YES]);
+ [dict enumerateKeysAndFloatsUsingBlock:^(BOOL aKey, float aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1568,42 +1588,44 @@
}
- (void)testOne {
- GPBBoolFloatDictionary *dict = [GPBBoolFloatDictionary dictionaryWithValue:500.f forKey:YES];
+ GPBBoolFloatDictionary *dict = [[GPBBoolFloatDictionary alloc] init];
+ [dict setFloat:500.f forKey:YES];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
float value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:YES]);
+ XCTAssertTrue([dict getFloat:&value forKey:YES]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, float aValue, BOOL *stop) {
+ XCTAssertFalse([dict getFloat:NULL forKey:NO]);
+ [dict enumerateKeysAndFloatsUsingBlock:^(BOOL aKey, float aValue, BOOL *stop) {
XCTAssertEqual(aKey, YES);
XCTAssertEqual(aValue, 500.f);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const BOOL kKeys[] = { YES, NO };
const float kValues[] = { 500.f, 501.f };
GPBBoolFloatDictionary *dict =
- [[GPBBoolFloatDictionary alloc] initWithValues:kValues
+ [[GPBBoolFloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
float value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:YES]);
+ XCTAssertTrue([dict getFloat:&value forKey:YES]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:NO]);
+ XCTAssertTrue([dict getFloat:&value forKey:NO]);
XCTAssertEqual(value, 501.f);
__block NSUInteger idx = 0;
BOOL *seenKeys = malloc(2 * sizeof(BOOL));
float *seenValues = malloc(2 * sizeof(float));
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, float aValue, BOOL *stop) {
+ [dict enumerateKeysAndFloatsUsingBlock:^(BOOL aKey, float aValue, BOOL *stop) {
XCTAssertLessThan(idx, 2U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1625,7 +1647,7 @@
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, float aValue, BOOL *stop) {
+ [dict enumerateKeysAndFloatsUsingBlock:^(BOOL aKey, float aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 0) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1641,27 +1663,27 @@
const float kValues2[] = { 501.f, 500.f };
const float kValues3[] = { 501.f };
GPBBoolFloatDictionary *dict1 =
- [[GPBBoolFloatDictionary alloc] initWithValues:kValues1
+ [[GPBBoolFloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBBoolFloatDictionary *dict1prime =
- [[GPBBoolFloatDictionary alloc] initWithValues:kValues1
+ [[GPBBoolFloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBBoolFloatDictionary *dict2 =
- [[GPBBoolFloatDictionary alloc] initWithValues:kValues2
+ [[GPBBoolFloatDictionary alloc] initWithFloats:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBBoolFloatDictionary *dict3 =
- [[GPBBoolFloatDictionary alloc] initWithValues:kValues1
+ [[GPBBoolFloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBBoolFloatDictionary *dict4 =
- [[GPBBoolFloatDictionary alloc] initWithValues:kValues3
+ [[GPBBoolFloatDictionary alloc] initWithFloats:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -1692,7 +1714,7 @@
const BOOL kKeys[] = { YES, NO };
const float kValues[] = { 500.f, 501.f };
GPBBoolFloatDictionary *dict =
- [[GPBBoolFloatDictionary alloc] initWithValues:kValues
+ [[GPBBoolFloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -1713,33 +1735,34 @@
const BOOL kKeys[] = { YES, NO };
const float kValues[] = { 500.f, 501.f };
GPBBoolFloatDictionary *dict =
- [[GPBBoolFloatDictionary alloc] initWithValues:kValues
+ [[GPBBoolFloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBBoolFloatDictionary *dict2 =
- [GPBBoolFloatDictionary dictionaryWithDictionary:dict];
+ [[GPBBoolFloatDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBBoolFloatDictionary *dict = [GPBBoolFloatDictionary dictionary];
+ GPBBoolFloatDictionary *dict = [[GPBBoolFloatDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:500.f forKey:YES];
+ [dict setFloat:500.f forKey:YES];
XCTAssertEqual(dict.count, 1U);
const BOOL kKeys[] = { NO };
const float kValues[] = { 501.f };
GPBBoolFloatDictionary *dict2 =
- [[GPBBoolFloatDictionary alloc] initWithValues:kValues
+ [[GPBBoolFloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -1747,45 +1770,46 @@
XCTAssertEqual(dict.count, 2U);
float value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:YES]);
+ XCTAssertTrue([dict getFloat:&value forKey:YES]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:NO]);
+ XCTAssertTrue([dict getFloat:&value forKey:NO]);
XCTAssertEqual(value, 501.f);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const BOOL kKeys[] = { YES, NO};
const float kValues[] = { 500.f, 501.f };
GPBBoolFloatDictionary *dict =
- [[GPBBoolFloatDictionary alloc] initWithValues:kValues
+ [[GPBBoolFloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
- [dict removeValueForKey:NO];
+ [dict removeFloatForKey:NO];
XCTAssertEqual(dict.count, 1U);
float value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:YES]);
+ XCTAssertTrue([dict getFloat:&value forKey:YES]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:NO]);
// Remove again does nothing.
- [dict removeValueForKey:NO];
+ [dict removeFloatForKey:NO];
XCTAssertEqual(dict.count, 1U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:YES]);
+ XCTAssertTrue([dict getFloat:&value forKey:YES]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:NO]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:YES value:NULL]);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:YES]);
+ XCTAssertFalse([dict getFloat:NULL forKey:NO]);
[dict release];
}
@@ -1793,51 +1817,51 @@
const BOOL kKeys[] = { YES, NO };
const float kValues[] = { 500.f, 501.f };
GPBBoolFloatDictionary *dict =
- [[GPBBoolFloatDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolFloatDictionary alloc] initWithFloats:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
float value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:YES]);
+ XCTAssertTrue([dict getFloat:&value forKey:YES]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:NO]);
+ XCTAssertTrue([dict getFloat:&value forKey:NO]);
XCTAssertEqual(value, 501.f);
- [dict setValue:501.f forKey:YES];
+ [dict setFloat:501.f forKey:YES];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:YES]);
+ XCTAssertTrue([dict getFloat:&value forKey:YES]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:NO]);
+ XCTAssertTrue([dict getFloat:&value forKey:NO]);
XCTAssertEqual(value, 501.f);
- [dict setValue:500.f forKey:NO];
+ [dict setFloat:500.f forKey:NO];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:YES]);
+ XCTAssertTrue([dict getFloat:&value forKey:YES]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:NO]);
+ XCTAssertTrue([dict getFloat:&value forKey:NO]);
XCTAssertEqual(value, 500.f);
const BOOL kKeys2[] = { NO, YES };
const float kValues2[] = { 501.f, 500.f };
GPBBoolFloatDictionary *dict2 =
- [[GPBBoolFloatDictionary alloc] initWithValues:kValues2
+ [[GPBBoolFloatDictionary alloc] initWithFloats:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:YES]);
+ XCTAssertTrue([dict getFloat:&value forKey:YES]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:NO]);
+ XCTAssertTrue([dict getFloat:&value forKey:NO]);
XCTAssertEqual(value, 501.f);
[dict2 release];
@@ -1860,8 +1884,8 @@
GPBBoolDoubleDictionary *dict = [[GPBBoolDoubleDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:YES value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, double aValue, BOOL *stop) {
+ XCTAssertFalse([dict getDouble:NULL forKey:YES]);
+ [dict enumerateKeysAndDoublesUsingBlock:^(BOOL aKey, double aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1869,42 +1893,44 @@
}
- (void)testOne {
- GPBBoolDoubleDictionary *dict = [GPBBoolDoubleDictionary dictionaryWithValue:600. forKey:YES];
+ GPBBoolDoubleDictionary *dict = [[GPBBoolDoubleDictionary alloc] init];
+ [dict setDouble:600. forKey:YES];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
double value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:YES]);
+ XCTAssertTrue([dict getDouble:&value forKey:YES]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, double aValue, BOOL *stop) {
+ XCTAssertFalse([dict getDouble:NULL forKey:NO]);
+ [dict enumerateKeysAndDoublesUsingBlock:^(BOOL aKey, double aValue, BOOL *stop) {
XCTAssertEqual(aKey, YES);
XCTAssertEqual(aValue, 600.);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const BOOL kKeys[] = { YES, NO };
const double kValues[] = { 600., 601. };
GPBBoolDoubleDictionary *dict =
- [[GPBBoolDoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
double value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:YES]);
+ XCTAssertTrue([dict getDouble:&value forKey:YES]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:NO]);
+ XCTAssertTrue([dict getDouble:&value forKey:NO]);
XCTAssertEqual(value, 601.);
__block NSUInteger idx = 0;
BOOL *seenKeys = malloc(2 * sizeof(BOOL));
double *seenValues = malloc(2 * sizeof(double));
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, double aValue, BOOL *stop) {
+ [dict enumerateKeysAndDoublesUsingBlock:^(BOOL aKey, double aValue, BOOL *stop) {
XCTAssertLessThan(idx, 2U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1926,7 +1952,7 @@
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, double aValue, BOOL *stop) {
+ [dict enumerateKeysAndDoublesUsingBlock:^(BOOL aKey, double aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 0) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1942,29 +1968,29 @@
const double kValues2[] = { 601., 600. };
const double kValues3[] = { 601. };
GPBBoolDoubleDictionary *dict1 =
- [[GPBBoolDoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBBoolDoubleDictionary *dict1prime =
- [[GPBBoolDoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBBoolDoubleDictionary *dict2 =
- [[GPBBoolDoubleDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBBoolDoubleDictionary *dict3 =
- [[GPBBoolDoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBBoolDoubleDictionary *dict4 =
- [[GPBBoolDoubleDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -1993,9 +2019,9 @@
const BOOL kKeys[] = { YES, NO };
const double kValues[] = { 600., 601. };
GPBBoolDoubleDictionary *dict =
- [[GPBBoolDoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBBoolDoubleDictionary *dict2 = [dict copy];
@@ -2014,79 +2040,81 @@
const BOOL kKeys[] = { YES, NO };
const double kValues[] = { 600., 601. };
GPBBoolDoubleDictionary *dict =
- [[GPBBoolDoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBBoolDoubleDictionary *dict2 =
- [GPBBoolDoubleDictionary dictionaryWithDictionary:dict];
+ [[GPBBoolDoubleDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBBoolDoubleDictionary *dict = [GPBBoolDoubleDictionary dictionary];
+ GPBBoolDoubleDictionary *dict = [[GPBBoolDoubleDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:600. forKey:YES];
+ [dict setDouble:600. forKey:YES];
XCTAssertEqual(dict.count, 1U);
const BOOL kKeys[] = { NO };
const double kValues[] = { 601. };
GPBBoolDoubleDictionary *dict2 =
- [[GPBBoolDoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 2U);
double value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:YES]);
+ XCTAssertTrue([dict getDouble:&value forKey:YES]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:NO]);
+ XCTAssertTrue([dict getDouble:&value forKey:NO]);
XCTAssertEqual(value, 601.);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const BOOL kKeys[] = { YES, NO};
const double kValues[] = { 600., 601. };
GPBBoolDoubleDictionary *dict =
- [[GPBBoolDoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
- [dict removeValueForKey:NO];
+ [dict removeDoubleForKey:NO];
XCTAssertEqual(dict.count, 1U);
double value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:YES]);
+ XCTAssertTrue([dict getDouble:&value forKey:YES]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:NO]);
// Remove again does nothing.
- [dict removeValueForKey:NO];
+ [dict removeDoubleForKey:NO];
XCTAssertEqual(dict.count, 1U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:YES]);
+ XCTAssertTrue([dict getDouble:&value forKey:YES]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:NO]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:YES value:NULL]);
- XCTAssertFalse([dict valueForKey:NO value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:YES]);
+ XCTAssertFalse([dict getDouble:NULL forKey:NO]);
[dict release];
}
@@ -2094,51 +2122,51 @@
const BOOL kKeys[] = { YES, NO };
const double kValues[] = { 600., 601. };
GPBBoolDoubleDictionary *dict =
- [[GPBBoolDoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
double value;
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:YES]);
+ XCTAssertTrue([dict getDouble:&value forKey:YES]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:NO]);
+ XCTAssertTrue([dict getDouble:&value forKey:NO]);
XCTAssertEqual(value, 601.);
- [dict setValue:601. forKey:YES];
+ [dict setDouble:601. forKey:YES];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:YES]);
+ XCTAssertTrue([dict getDouble:&value forKey:YES]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:NO]);
+ XCTAssertTrue([dict getDouble:&value forKey:NO]);
XCTAssertEqual(value, 601.);
- [dict setValue:600. forKey:NO];
+ [dict setDouble:600. forKey:NO];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:YES]);
+ XCTAssertTrue([dict getDouble:&value forKey:YES]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:NO]);
+ XCTAssertTrue([dict getDouble:&value forKey:NO]);
XCTAssertEqual(value, 600.);
const BOOL kKeys2[] = { NO, YES };
const double kValues2[] = { 601., 600. };
GPBBoolDoubleDictionary *dict2 =
- [[GPBBoolDoubleDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:YES value:NULL]);
- XCTAssertTrue([dict valueForKey:YES value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:YES]);
+ XCTAssertTrue([dict getDouble:&value forKey:YES]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:NO value:NULL]);
- XCTAssertTrue([dict valueForKey:NO value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:NO]);
+ XCTAssertTrue([dict getDouble:&value forKey:NO]);
XCTAssertEqual(value, 601.);
[dict2 release];
@@ -2147,7 +2175,7 @@
@end
-//%PDDM-EXPAND TESTS_FOR_BOOL_KEY_OBJECT_VALUE(Object, id, @"abc", @"def")
+//%PDDM-EXPAND TESTS_FOR_BOOL_KEY_OBJECT_VALUE(Object, NSString*, @"abc", @"def")
// This block of code is generated, do not edit it directly.
#pragma mark - Bool -> Object
@@ -2158,11 +2186,11 @@
@implementation GPBBoolObjectDictionaryTests
- (void)testEmpty {
- GPBBoolObjectDictionary *dict = [[GPBBoolObjectDictionary alloc] init];
+ GPBBoolObjectDictionary<NSString*> *dict = [[GPBBoolObjectDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
XCTAssertNil([dict objectForKey:YES]);
- [dict enumerateKeysAndObjectsUsingBlock:^(BOOL aKey, id aObject, BOOL *stop) {
+ [dict enumerateKeysAndObjectsUsingBlock:^(BOOL aKey, NSString* aObject, BOOL *stop) {
#pragma unused(aKey, aObject, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -2170,22 +2198,24 @@
}
- (void)testOne {
- GPBBoolObjectDictionary *dict = [GPBBoolObjectDictionary dictionaryWithObject:@"abc" forKey:YES];
+ GPBBoolObjectDictionary<NSString*> *dict = [[GPBBoolObjectDictionary alloc] init];
+ [dict setObject:@"abc" forKey:YES];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
XCTAssertEqualObjects([dict objectForKey:YES], @"abc");
XCTAssertNil([dict objectForKey:NO]);
- [dict enumerateKeysAndObjectsUsingBlock:^(BOOL aKey, id aObject, BOOL *stop) {
+ [dict enumerateKeysAndObjectsUsingBlock:^(BOOL aKey, NSString* aObject, BOOL *stop) {
XCTAssertEqual(aKey, YES);
XCTAssertEqualObjects(aObject, @"abc");
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const BOOL kKeys[] = { YES, NO };
- const id kObjects[] = { @"abc", @"def" };
- GPBBoolObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def" };
+ GPBBoolObjectDictionary<NSString*> *dict =
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
@@ -2196,8 +2226,8 @@
__block NSUInteger idx = 0;
BOOL *seenKeys = malloc(2 * sizeof(BOOL));
- id *seenObjects = malloc(2 * sizeof(id));
- [dict enumerateKeysAndObjectsUsingBlock:^(BOOL aKey, id aObject, BOOL *stop) {
+ NSString* *seenObjects = malloc(2 * sizeof(NSString*));
+ [dict enumerateKeysAndObjectsUsingBlock:^(BOOL aKey, NSString* aObject, BOOL *stop) {
XCTAssertLessThan(idx, 2U);
seenKeys[idx] = aKey;
seenObjects[idx] = aObject;
@@ -2219,7 +2249,7 @@
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndObjectsUsingBlock:^(BOOL aKey, id aObject, BOOL *stop) {
+ [dict enumerateKeysAndObjectsUsingBlock:^(BOOL aKey, NSString* aObject, BOOL *stop) {
#pragma unused(aKey, aObject)
if (idx == 0) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -2231,30 +2261,30 @@
- (void)testEquality {
const BOOL kKeys1[] = { YES, NO };
const BOOL kKeys2[] = { NO, YES };
- const id kObjects1[] = { @"abc", @"def" };
- const id kObjects2[] = { @"def", @"abc" };
- const id kObjects3[] = { @"def" };
- GPBBoolObjectDictionary *dict1 =
+ const NSString* kObjects1[] = { @"abc", @"def" };
+ const NSString* kObjects2[] = { @"def", @"abc" };
+ const NSString* kObjects3[] = { @"def" };
+ GPBBoolObjectDictionary<NSString*> *dict1 =
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects1
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects1)];
XCTAssertNotNil(dict1);
- GPBBoolObjectDictionary *dict1prime =
+ GPBBoolObjectDictionary<NSString*> *dict1prime =
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects1
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects1)];
XCTAssertNotNil(dict1prime);
- GPBBoolObjectDictionary *dict2 =
+ GPBBoolObjectDictionary<NSString*> *dict2 =
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects2
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects2)];
XCTAssertNotNil(dict2);
- GPBBoolObjectDictionary *dict3 =
+ GPBBoolObjectDictionary<NSString*> *dict3 =
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects1
forKeys:kKeys2
count:GPBARRAYSIZE(kObjects1)];
XCTAssertNotNil(dict3);
- GPBBoolObjectDictionary *dict4 =
+ GPBBoolObjectDictionary<NSString*> *dict4 =
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects3
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects3)];
@@ -2284,14 +2314,14 @@
- (void)testCopy {
const BOOL kKeys[] = { YES, NO };
- const id kObjects[] = { @"abc", @"def" };
- GPBBoolObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def" };
+ GPBBoolObjectDictionary<NSString*> *dict =
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
- GPBBoolObjectDictionary *dict2 = [dict copy];
+ GPBBoolObjectDictionary<NSString*> *dict2 = [dict copy];
XCTAssertNotNil(dict2);
// Should be new object but equal.
@@ -2305,25 +2335,26 @@
- (void)testDictionaryFromDictionary {
const BOOL kKeys[] = { YES, NO };
- const id kObjects[] = { @"abc", @"def" };
- GPBBoolObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def" };
+ GPBBoolObjectDictionary<NSString*> *dict =
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
- GPBBoolObjectDictionary *dict2 =
- [GPBBoolObjectDictionary dictionaryWithDictionary:dict];
+ GPBBoolObjectDictionary<NSString*> *dict2 =
+ [[GPBBoolObjectDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBBoolObjectDictionary *dict = [GPBBoolObjectDictionary dictionary];
+ GPBBoolObjectDictionary<NSString*> *dict = [[GPBBoolObjectDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@@ -2331,8 +2362,8 @@
XCTAssertEqual(dict.count, 1U);
const BOOL kKeys[] = { NO };
- const id kObjects[] = { @"def" };
- GPBBoolObjectDictionary *dict2 =
+ const NSString* kObjects[] = { @"def" };
+ GPBBoolObjectDictionary<NSString*> *dict2 =
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
@@ -2343,12 +2374,13 @@
XCTAssertEqualObjects([dict objectForKey:YES], @"abc");
XCTAssertEqualObjects([dict objectForKey:NO], @"def");
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const BOOL kKeys[] = { YES, NO};
- const id kObjects[] = { @"abc", @"def" };
- GPBBoolObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def" };
+ GPBBoolObjectDictionary<NSString*> *dict =
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
@@ -2375,11 +2407,11 @@
- (void)testInplaceMutation {
const BOOL kKeys[] = { YES, NO };
- const id kObjects[] = { @"abc", @"def" };
- GPBBoolObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def" };
+ GPBBoolObjectDictionary<NSString*> *dict =
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects
- forKeys:kKeys
- count:GPBARRAYSIZE(kObjects)];
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 2U);
XCTAssertEqualObjects([dict objectForKey:YES], @"abc");
@@ -2396,8 +2428,8 @@
XCTAssertEqualObjects([dict objectForKey:NO], @"abc");
const BOOL kKeys2[] = { NO, YES };
- const id kObjects2[] = { @"def", @"abc" };
- GPBBoolObjectDictionary *dict2 =
+ const NSString* kObjects2[] = { @"def", @"abc" };
+ GPBBoolObjectDictionary<NSString*> *dict2 =
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects2
forKeys:kKeys2
count:GPBARRAYSIZE(kObjects2)];
diff --git a/objectivec/Tests/GPBDictionaryTests+Int32.m b/objectivec/Tests/GPBDictionaryTests+Int32.m
index 21d3f07d..4ba30203 100644
--- a/objectivec/Tests/GPBDictionaryTests+Int32.m
+++ b/objectivec/Tests/GPBDictionaryTests+Int32.m
@@ -45,10 +45,9 @@
// To let the testing macros work, add some extra methods to simplify things.
@interface GPBInt32EnumDictionary (TestingTweak)
-+ (instancetype)dictionaryWithValue:(int32_t)value forKey:(int32_t)key;
-- (instancetype)initWithValues:(const int32_t [])values
- forKeys:(const int32_t [])keys
- count:(NSUInteger)count;
+- (instancetype)initWithEnums:(const int32_t [])values
+ forKeys:(const int32_t [])keys
+ count:(NSUInteger)count;
@end
static BOOL TestingEnum_IsValidValue(int32_t value) {
@@ -64,17 +63,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
@implementation GPBInt32EnumDictionary (TestingTweak)
-+ (instancetype)dictionaryWithValue:(int32_t)value forKey:(int32_t)key {
- // Cast is needed to compiler knows what class we are invoking initWithValues: on to get the
- // type correct.
- return [[(GPBInt32EnumDictionary*)[self alloc] initWithValidationFunction:TestingEnum_IsValidValue
- rawValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-- (instancetype)initWithValues:(const int32_t [])values
- forKeys:(const int32_t [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithEnums:(const int32_t [])values
+ forKeys:(const int32_t [])keys
+ count:(NSUInteger)count {
return [self initWithValidationFunction:TestingEnum_IsValidValue
rawValues:values
forKeys:keys
@@ -94,8 +85,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBInt32UInt32Dictionary *dict = [[GPBInt32UInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, uint32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt32:NULL forKey:11]);
+ [dict enumerateKeysAndUInt32sUsingBlock:^(int32_t aKey, uint32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -103,46 +94,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt32UInt32Dictionary *dict = [GPBInt32UInt32Dictionary dictionaryWithValue:100U forKey:11];
+ GPBInt32UInt32Dictionary *dict = [[GPBInt32UInt32Dictionary alloc] init];
+ [dict setUInt32:100U forKey:11];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt32:&value forKey:11]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, uint32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt32:NULL forKey:12]);
+ [dict enumerateKeysAndUInt32sUsingBlock:^(int32_t aKey, uint32_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 11);
XCTAssertEqual(aValue, 100U);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int32_t kKeys[] = { 11, 12, 13 };
const uint32_t kValues[] = { 100U, 101U, 102U };
GPBInt32UInt32Dictionary *dict =
- [[GPBInt32UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt32:&value forKey:11]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt32:&value forKey:12]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt32:&value forKey:13]);
XCTAssertEqual(value, 102U);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:14]);
__block NSUInteger idx = 0;
int32_t *seenKeys = malloc(3 * sizeof(int32_t));
uint32_t *seenValues = malloc(3 * sizeof(uint32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, uint32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt32sUsingBlock:^(int32_t aKey, uint32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -164,7 +157,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, uint32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt32sUsingBlock:^(int32_t aKey, uint32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -180,29 +173,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kValues2[] = { 100U, 103U, 102U };
const uint32_t kValues3[] = { 100U, 101U, 102U, 103U };
GPBInt32UInt32Dictionary *dict1 =
- [[GPBInt32UInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt32UInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBInt32UInt32Dictionary *dict1prime =
- [[GPBInt32UInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt32UInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBInt32UInt32Dictionary *dict2 =
- [[GPBInt32UInt32Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt32UInt32Dictionary alloc] initWithUInt32s:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBInt32UInt32Dictionary *dict3 =
- [[GPBInt32UInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt32UInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBInt32UInt32Dictionary *dict4 =
- [[GPBInt32UInt32Dictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBInt32UInt32Dictionary alloc] initWithUInt32s:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -231,9 +224,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBInt32UInt32Dictionary *dict =
- [[GPBInt32UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt32UInt32Dictionary *dict2 = [dict copy];
@@ -252,110 +245,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBInt32UInt32Dictionary *dict =
- [[GPBInt32UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt32UInt32Dictionary *dict2 =
- [GPBInt32UInt32Dictionary dictionaryWithDictionary:dict];
+ [[GPBInt32UInt32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt32UInt32Dictionary *dict = [GPBInt32UInt32Dictionary dictionary];
+ GPBInt32UInt32Dictionary *dict = [[GPBInt32UInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:100U forKey:11];
+ [dict setUInt32:100U forKey:11];
XCTAssertEqual(dict.count, 1U);
const int32_t kKeys[] = { 12, 13, 14 };
const uint32_t kValues[] = { 101U, 102U, 103U };
GPBInt32UInt32Dictionary *dict2 =
- [[GPBInt32UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt32:&value forKey:11]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt32:&value forKey:12]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt32:&value forKey:13]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:14]);
+ XCTAssertTrue([dict getUInt32:&value forKey:14]);
XCTAssertEqual(value, 103U);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBInt32UInt32Dictionary *dict =
- [[GPBInt32UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:12];
+ [dict removeUInt32ForKey:12];
XCTAssertEqual(dict.count, 3U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt32:&value forKey:11]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt32:&value forKey:13]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:14]);
+ XCTAssertTrue([dict getUInt32:&value forKey:14]);
XCTAssertEqual(value, 103U);
// Remove again does nothing.
- [dict removeValueForKey:12];
+ [dict removeUInt32ForKey:12];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt32:&value forKey:11]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt32:&value forKey:13]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:14]);
+ XCTAssertTrue([dict getUInt32:&value forKey:14]);
XCTAssertEqual(value, 103U);
- [dict removeValueForKey:14];
+ [dict removeUInt32ForKey:14];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt32:&value forKey:11]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt32:&value forKey:13]);
XCTAssertEqual(value, 102U);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:14]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertFalse([dict valueForKey:13 value:NULL]);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:11]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:12]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:13]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:14]);
[dict release];
}
@@ -363,75 +358,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBInt32UInt32Dictionary *dict =
- [[GPBInt32UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt32:&value forKey:11]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt32:&value forKey:12]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt32:&value forKey:13]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:14]);
+ XCTAssertTrue([dict getUInt32:&value forKey:14]);
XCTAssertEqual(value, 103U);
- [dict setValue:103U forKey:11];
+ [dict setUInt32:103U forKey:11];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt32:&value forKey:11]);
XCTAssertEqual(value, 103U);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt32:&value forKey:12]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt32:&value forKey:13]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:14]);
+ XCTAssertTrue([dict getUInt32:&value forKey:14]);
XCTAssertEqual(value, 103U);
- [dict setValue:101U forKey:14];
+ [dict setUInt32:101U forKey:14];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt32:&value forKey:11]);
XCTAssertEqual(value, 103U);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt32:&value forKey:12]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt32:&value forKey:13]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:14]);
+ XCTAssertTrue([dict getUInt32:&value forKey:14]);
XCTAssertEqual(value, 101U);
const int32_t kKeys2[] = { 12, 13 };
const uint32_t kValues2[] = { 102U, 100U };
GPBInt32UInt32Dictionary *dict2 =
- [[GPBInt32UInt32Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt32UInt32Dictionary alloc] initWithUInt32s:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt32:&value forKey:11]);
XCTAssertEqual(value, 103U);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt32:&value forKey:12]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt32:&value forKey:13]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:14]);
+ XCTAssertTrue([dict getUInt32:&value forKey:14]);
XCTAssertEqual(value, 101U);
[dict2 release];
@@ -451,8 +446,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBInt32Int32Dictionary *dict = [[GPBInt32Int32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt32:NULL forKey:11]);
+ [dict enumerateKeysAndInt32sUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -460,46 +455,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt32Int32Dictionary *dict = [GPBInt32Int32Dictionary dictionaryWithValue:200 forKey:11];
+ GPBInt32Int32Dictionary *dict = [[GPBInt32Int32Dictionary alloc] init];
+ [dict setInt32:200 forKey:11];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getInt32:&value forKey:11]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt32:NULL forKey:12]);
+ [dict enumerateKeysAndInt32sUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 11);
XCTAssertEqual(aValue, 200);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int32_t kKeys[] = { 11, 12, 13 };
const int32_t kValues[] = { 200, 201, 202 };
GPBInt32Int32Dictionary *dict =
- [[GPBInt32Int32Dictionary alloc] initWithValues:kValues
+ [[GPBInt32Int32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getInt32:&value forKey:11]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getInt32:&value forKey:12]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getInt32:&value forKey:13]);
XCTAssertEqual(value, 202);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:14]);
__block NSUInteger idx = 0;
int32_t *seenKeys = malloc(3 * sizeof(int32_t));
int32_t *seenValues = malloc(3 * sizeof(int32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt32sUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -521,7 +518,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt32sUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -537,27 +534,27 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kValues2[] = { 200, 203, 202 };
const int32_t kValues3[] = { 200, 201, 202, 203 };
GPBInt32Int32Dictionary *dict1 =
- [[GPBInt32Int32Dictionary alloc] initWithValues:kValues1
+ [[GPBInt32Int32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBInt32Int32Dictionary *dict1prime =
- [[GPBInt32Int32Dictionary alloc] initWithValues:kValues1
+ [[GPBInt32Int32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBInt32Int32Dictionary *dict2 =
- [[GPBInt32Int32Dictionary alloc] initWithValues:kValues2
+ [[GPBInt32Int32Dictionary alloc] initWithInt32s:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBInt32Int32Dictionary *dict3 =
- [[GPBInt32Int32Dictionary alloc] initWithValues:kValues1
+ [[GPBInt32Int32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBInt32Int32Dictionary *dict4 =
- [[GPBInt32Int32Dictionary alloc] initWithValues:kValues3
+ [[GPBInt32Int32Dictionary alloc] initWithInt32s:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -588,7 +585,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBInt32Int32Dictionary *dict =
- [[GPBInt32Int32Dictionary alloc] initWithValues:kValues
+ [[GPBInt32Int32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -609,33 +606,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBInt32Int32Dictionary *dict =
- [[GPBInt32Int32Dictionary alloc] initWithValues:kValues
+ [[GPBInt32Int32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt32Int32Dictionary *dict2 =
- [GPBInt32Int32Dictionary dictionaryWithDictionary:dict];
+ [[GPBInt32Int32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt32Int32Dictionary *dict = [GPBInt32Int32Dictionary dictionary];
+ GPBInt32Int32Dictionary *dict = [[GPBInt32Int32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:200 forKey:11];
+ [dict setInt32:200 forKey:11];
XCTAssertEqual(dict.count, 1U);
const int32_t kKeys[] = { 12, 13, 14 };
const int32_t kValues[] = { 201, 202, 203 };
GPBInt32Int32Dictionary *dict2 =
- [[GPBInt32Int32Dictionary alloc] initWithValues:kValues
+ [[GPBInt32Int32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -643,76 +641,77 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getInt32:&value forKey:11]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getInt32:&value forKey:12]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getInt32:&value forKey:13]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:14]);
+ XCTAssertTrue([dict getInt32:&value forKey:14]);
XCTAssertEqual(value, 203);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBInt32Int32Dictionary *dict =
- [[GPBInt32Int32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32Int32Dictionary alloc] initWithInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:12];
+ [dict removeInt32ForKey:12];
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getInt32:&value forKey:11]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getInt32:&value forKey:13]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:14]);
+ XCTAssertTrue([dict getInt32:&value forKey:14]);
XCTAssertEqual(value, 203);
// Remove again does nothing.
- [dict removeValueForKey:12];
+ [dict removeInt32ForKey:12];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getInt32:&value forKey:11]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getInt32:&value forKey:13]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:14]);
+ XCTAssertTrue([dict getInt32:&value forKey:14]);
XCTAssertEqual(value, 203);
- [dict removeValueForKey:14];
+ [dict removeInt32ForKey:14];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getInt32:&value forKey:11]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getInt32:&value forKey:13]);
XCTAssertEqual(value, 202);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:14]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertFalse([dict valueForKey:13 value:NULL]);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:11]);
+ XCTAssertFalse([dict getInt32:NULL forKey:12]);
+ XCTAssertFalse([dict getInt32:NULL forKey:13]);
+ XCTAssertFalse([dict getInt32:NULL forKey:14]);
[dict release];
}
@@ -720,75 +719,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBInt32Int32Dictionary *dict =
- [[GPBInt32Int32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32Int32Dictionary alloc] initWithInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getInt32:&value forKey:11]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getInt32:&value forKey:12]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getInt32:&value forKey:13]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:14]);
+ XCTAssertTrue([dict getInt32:&value forKey:14]);
XCTAssertEqual(value, 203);
- [dict setValue:203 forKey:11];
+ [dict setInt32:203 forKey:11];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getInt32:&value forKey:11]);
XCTAssertEqual(value, 203);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getInt32:&value forKey:12]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getInt32:&value forKey:13]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:14]);
+ XCTAssertTrue([dict getInt32:&value forKey:14]);
XCTAssertEqual(value, 203);
- [dict setValue:201 forKey:14];
+ [dict setInt32:201 forKey:14];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getInt32:&value forKey:11]);
XCTAssertEqual(value, 203);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getInt32:&value forKey:12]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getInt32:&value forKey:13]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:14]);
+ XCTAssertTrue([dict getInt32:&value forKey:14]);
XCTAssertEqual(value, 201);
const int32_t kKeys2[] = { 12, 13 };
const int32_t kValues2[] = { 202, 200 };
GPBInt32Int32Dictionary *dict2 =
- [[GPBInt32Int32Dictionary alloc] initWithValues:kValues2
+ [[GPBInt32Int32Dictionary alloc] initWithInt32s:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:11]);
+ XCTAssertTrue([dict getInt32:&value forKey:11]);
XCTAssertEqual(value, 203);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:12]);
+ XCTAssertTrue([dict getInt32:&value forKey:12]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:13]);
+ XCTAssertTrue([dict getInt32:&value forKey:13]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:14]);
+ XCTAssertTrue([dict getInt32:&value forKey:14]);
XCTAssertEqual(value, 201);
[dict2 release];
@@ -808,8 +807,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBInt32UInt64Dictionary *dict = [[GPBInt32UInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, uint64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt64:NULL forKey:11]);
+ [dict enumerateKeysAndUInt64sUsingBlock:^(int32_t aKey, uint64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -817,46 +816,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt32UInt64Dictionary *dict = [GPBInt32UInt64Dictionary dictionaryWithValue:300U forKey:11];
+ GPBInt32UInt64Dictionary *dict = [[GPBInt32UInt64Dictionary alloc] init];
+ [dict setUInt64:300U forKey:11];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt64:&value forKey:11]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, uint64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt64:NULL forKey:12]);
+ [dict enumerateKeysAndUInt64sUsingBlock:^(int32_t aKey, uint64_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 11);
XCTAssertEqual(aValue, 300U);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int32_t kKeys[] = { 11, 12, 13 };
const uint64_t kValues[] = { 300U, 301U, 302U };
GPBInt32UInt64Dictionary *dict =
- [[GPBInt32UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt64:&value forKey:11]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt64:&value forKey:12]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt64:&value forKey:13]);
XCTAssertEqual(value, 302U);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:14]);
__block NSUInteger idx = 0;
int32_t *seenKeys = malloc(3 * sizeof(int32_t));
uint64_t *seenValues = malloc(3 * sizeof(uint64_t));
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, uint64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt64sUsingBlock:^(int32_t aKey, uint64_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -878,7 +879,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, uint64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt64sUsingBlock:^(int32_t aKey, uint64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -894,29 +895,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kValues2[] = { 300U, 303U, 302U };
const uint64_t kValues3[] = { 300U, 301U, 302U, 303U };
GPBInt32UInt64Dictionary *dict1 =
- [[GPBInt32UInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt32UInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBInt32UInt64Dictionary *dict1prime =
- [[GPBInt32UInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt32UInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBInt32UInt64Dictionary *dict2 =
- [[GPBInt32UInt64Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt32UInt64Dictionary alloc] initWithUInt64s:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBInt32UInt64Dictionary *dict3 =
- [[GPBInt32UInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt32UInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBInt32UInt64Dictionary *dict4 =
- [[GPBInt32UInt64Dictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBInt32UInt64Dictionary alloc] initWithUInt64s:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -945,9 +946,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBInt32UInt64Dictionary *dict =
- [[GPBInt32UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt32UInt64Dictionary *dict2 = [dict copy];
@@ -966,110 +967,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBInt32UInt64Dictionary *dict =
- [[GPBInt32UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt32UInt64Dictionary *dict2 =
- [GPBInt32UInt64Dictionary dictionaryWithDictionary:dict];
+ [[GPBInt32UInt64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt32UInt64Dictionary *dict = [GPBInt32UInt64Dictionary dictionary];
+ GPBInt32UInt64Dictionary *dict = [[GPBInt32UInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:300U forKey:11];
+ [dict setUInt64:300U forKey:11];
XCTAssertEqual(dict.count, 1U);
const int32_t kKeys[] = { 12, 13, 14 };
const uint64_t kValues[] = { 301U, 302U, 303U };
GPBInt32UInt64Dictionary *dict2 =
- [[GPBInt32UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt64:&value forKey:11]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt64:&value forKey:12]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt64:&value forKey:13]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:14]);
+ XCTAssertTrue([dict getUInt64:&value forKey:14]);
XCTAssertEqual(value, 303U);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBInt32UInt64Dictionary *dict =
- [[GPBInt32UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:12];
+ [dict removeUInt64ForKey:12];
XCTAssertEqual(dict.count, 3U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt64:&value forKey:11]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt64:&value forKey:13]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:14]);
+ XCTAssertTrue([dict getUInt64:&value forKey:14]);
XCTAssertEqual(value, 303U);
// Remove again does nothing.
- [dict removeValueForKey:12];
+ [dict removeUInt64ForKey:12];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt64:&value forKey:11]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt64:&value forKey:13]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:14]);
+ XCTAssertTrue([dict getUInt64:&value forKey:14]);
XCTAssertEqual(value, 303U);
- [dict removeValueForKey:14];
+ [dict removeUInt64ForKey:14];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt64:&value forKey:11]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt64:&value forKey:13]);
XCTAssertEqual(value, 302U);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:14]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertFalse([dict valueForKey:13 value:NULL]);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:11]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:12]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:13]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:14]);
[dict release];
}
@@ -1077,75 +1080,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBInt32UInt64Dictionary *dict =
- [[GPBInt32UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt64:&value forKey:11]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt64:&value forKey:12]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt64:&value forKey:13]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:14]);
+ XCTAssertTrue([dict getUInt64:&value forKey:14]);
XCTAssertEqual(value, 303U);
- [dict setValue:303U forKey:11];
+ [dict setUInt64:303U forKey:11];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt64:&value forKey:11]);
XCTAssertEqual(value, 303U);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt64:&value forKey:12]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt64:&value forKey:13]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:14]);
+ XCTAssertTrue([dict getUInt64:&value forKey:14]);
XCTAssertEqual(value, 303U);
- [dict setValue:301U forKey:14];
+ [dict setUInt64:301U forKey:14];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt64:&value forKey:11]);
XCTAssertEqual(value, 303U);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt64:&value forKey:12]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt64:&value forKey:13]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:14]);
+ XCTAssertTrue([dict getUInt64:&value forKey:14]);
XCTAssertEqual(value, 301U);
const int32_t kKeys2[] = { 12, 13 };
const uint64_t kValues2[] = { 302U, 300U };
GPBInt32UInt64Dictionary *dict2 =
- [[GPBInt32UInt64Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt32UInt64Dictionary alloc] initWithUInt64s:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getUInt64:&value forKey:11]);
XCTAssertEqual(value, 303U);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getUInt64:&value forKey:12]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getUInt64:&value forKey:13]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:14]);
+ XCTAssertTrue([dict getUInt64:&value forKey:14]);
XCTAssertEqual(value, 301U);
[dict2 release];
@@ -1165,8 +1168,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBInt32Int64Dictionary *dict = [[GPBInt32Int64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, int64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt64:NULL forKey:11]);
+ [dict enumerateKeysAndInt64sUsingBlock:^(int32_t aKey, int64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1174,46 +1177,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt32Int64Dictionary *dict = [GPBInt32Int64Dictionary dictionaryWithValue:400 forKey:11];
+ GPBInt32Int64Dictionary *dict = [[GPBInt32Int64Dictionary alloc] init];
+ [dict setInt64:400 forKey:11];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int64_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getInt64:&value forKey:11]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, int64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt64:NULL forKey:12]);
+ [dict enumerateKeysAndInt64sUsingBlock:^(int32_t aKey, int64_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 11);
XCTAssertEqual(aValue, 400);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int32_t kKeys[] = { 11, 12, 13 };
const int64_t kValues[] = { 400, 401, 402 };
GPBInt32Int64Dictionary *dict =
- [[GPBInt32Int64Dictionary alloc] initWithValues:kValues
+ [[GPBInt32Int64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
int64_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getInt64:&value forKey:11]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getInt64:&value forKey:12]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getInt64:&value forKey:13]);
XCTAssertEqual(value, 402);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:14]);
__block NSUInteger idx = 0;
int32_t *seenKeys = malloc(3 * sizeof(int32_t));
int64_t *seenValues = malloc(3 * sizeof(int64_t));
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, int64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt64sUsingBlock:^(int32_t aKey, int64_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1235,7 +1240,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, int64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt64sUsingBlock:^(int32_t aKey, int64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1251,27 +1256,27 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kValues2[] = { 400, 403, 402 };
const int64_t kValues3[] = { 400, 401, 402, 403 };
GPBInt32Int64Dictionary *dict1 =
- [[GPBInt32Int64Dictionary alloc] initWithValues:kValues1
+ [[GPBInt32Int64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBInt32Int64Dictionary *dict1prime =
- [[GPBInt32Int64Dictionary alloc] initWithValues:kValues1
+ [[GPBInt32Int64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBInt32Int64Dictionary *dict2 =
- [[GPBInt32Int64Dictionary alloc] initWithValues:kValues2
+ [[GPBInt32Int64Dictionary alloc] initWithInt64s:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBInt32Int64Dictionary *dict3 =
- [[GPBInt32Int64Dictionary alloc] initWithValues:kValues1
+ [[GPBInt32Int64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBInt32Int64Dictionary *dict4 =
- [[GPBInt32Int64Dictionary alloc] initWithValues:kValues3
+ [[GPBInt32Int64Dictionary alloc] initWithInt64s:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -1302,7 +1307,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBInt32Int64Dictionary *dict =
- [[GPBInt32Int64Dictionary alloc] initWithValues:kValues
+ [[GPBInt32Int64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -1323,33 +1328,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBInt32Int64Dictionary *dict =
- [[GPBInt32Int64Dictionary alloc] initWithValues:kValues
+ [[GPBInt32Int64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt32Int64Dictionary *dict2 =
- [GPBInt32Int64Dictionary dictionaryWithDictionary:dict];
+ [[GPBInt32Int64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt32Int64Dictionary *dict = [GPBInt32Int64Dictionary dictionary];
+ GPBInt32Int64Dictionary *dict = [[GPBInt32Int64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:400 forKey:11];
+ [dict setInt64:400 forKey:11];
XCTAssertEqual(dict.count, 1U);
const int32_t kKeys[] = { 12, 13, 14 };
const int64_t kValues[] = { 401, 402, 403 };
GPBInt32Int64Dictionary *dict2 =
- [[GPBInt32Int64Dictionary alloc] initWithValues:kValues
+ [[GPBInt32Int64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -1357,76 +1363,77 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 4U);
int64_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getInt64:&value forKey:11]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getInt64:&value forKey:12]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getInt64:&value forKey:13]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:14]);
+ XCTAssertTrue([dict getInt64:&value forKey:14]);
XCTAssertEqual(value, 403);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBInt32Int64Dictionary *dict =
- [[GPBInt32Int64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32Int64Dictionary alloc] initWithInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:12];
+ [dict removeInt64ForKey:12];
XCTAssertEqual(dict.count, 3U);
int64_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getInt64:&value forKey:11]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getInt64:&value forKey:13]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:14]);
+ XCTAssertTrue([dict getInt64:&value forKey:14]);
XCTAssertEqual(value, 403);
// Remove again does nothing.
- [dict removeValueForKey:12];
+ [dict removeInt64ForKey:12];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getInt64:&value forKey:11]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getInt64:&value forKey:13]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:14]);
+ XCTAssertTrue([dict getInt64:&value forKey:14]);
XCTAssertEqual(value, 403);
- [dict removeValueForKey:14];
+ [dict removeInt64ForKey:14];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getInt64:&value forKey:11]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getInt64:&value forKey:13]);
XCTAssertEqual(value, 402);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:14]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertFalse([dict valueForKey:13 value:NULL]);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:11]);
+ XCTAssertFalse([dict getInt64:NULL forKey:12]);
+ XCTAssertFalse([dict getInt64:NULL forKey:13]);
+ XCTAssertFalse([dict getInt64:NULL forKey:14]);
[dict release];
}
@@ -1434,75 +1441,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBInt32Int64Dictionary *dict =
- [[GPBInt32Int64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32Int64Dictionary alloc] initWithInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int64_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getInt64:&value forKey:11]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getInt64:&value forKey:12]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getInt64:&value forKey:13]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:14]);
+ XCTAssertTrue([dict getInt64:&value forKey:14]);
XCTAssertEqual(value, 403);
- [dict setValue:403 forKey:11];
+ [dict setInt64:403 forKey:11];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getInt64:&value forKey:11]);
XCTAssertEqual(value, 403);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getInt64:&value forKey:12]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getInt64:&value forKey:13]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:14]);
+ XCTAssertTrue([dict getInt64:&value forKey:14]);
XCTAssertEqual(value, 403);
- [dict setValue:401 forKey:14];
+ [dict setInt64:401 forKey:14];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getInt64:&value forKey:11]);
XCTAssertEqual(value, 403);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getInt64:&value forKey:12]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getInt64:&value forKey:13]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:14]);
+ XCTAssertTrue([dict getInt64:&value forKey:14]);
XCTAssertEqual(value, 401);
const int32_t kKeys2[] = { 12, 13 };
const int64_t kValues2[] = { 402, 400 };
GPBInt32Int64Dictionary *dict2 =
- [[GPBInt32Int64Dictionary alloc] initWithValues:kValues2
+ [[GPBInt32Int64Dictionary alloc] initWithInt64s:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:11]);
+ XCTAssertTrue([dict getInt64:&value forKey:11]);
XCTAssertEqual(value, 403);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:12]);
+ XCTAssertTrue([dict getInt64:&value forKey:12]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:13]);
+ XCTAssertTrue([dict getInt64:&value forKey:13]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:14]);
+ XCTAssertTrue([dict getInt64:&value forKey:14]);
XCTAssertEqual(value, 401);
[dict2 release];
@@ -1522,8 +1529,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBInt32BoolDictionary *dict = [[GPBInt32BoolDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, BOOL aValue, BOOL *stop) {
+ XCTAssertFalse([dict getBool:NULL forKey:11]);
+ [dict enumerateKeysAndBoolsUsingBlock:^(int32_t aKey, BOOL aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1531,46 +1538,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt32BoolDictionary *dict = [GPBInt32BoolDictionary dictionaryWithValue:YES forKey:11];
+ GPBInt32BoolDictionary *dict = [[GPBInt32BoolDictionary alloc] init];
+ [dict setBool:YES forKey:11];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
BOOL value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:11]);
+ XCTAssertTrue([dict getBool:&value forKey:11]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, BOOL aValue, BOOL *stop) {
+ XCTAssertFalse([dict getBool:NULL forKey:12]);
+ [dict enumerateKeysAndBoolsUsingBlock:^(int32_t aKey, BOOL aValue, BOOL *stop) {
XCTAssertEqual(aKey, 11);
XCTAssertEqual(aValue, YES);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int32_t kKeys[] = { 11, 12, 13 };
const BOOL kValues[] = { YES, YES, NO };
GPBInt32BoolDictionary *dict =
- [[GPBInt32BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
BOOL value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:11]);
+ XCTAssertTrue([dict getBool:&value forKey:11]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:12]);
+ XCTAssertTrue([dict getBool:&value forKey:12]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:13]);
+ XCTAssertTrue([dict getBool:&value forKey:13]);
XCTAssertEqual(value, NO);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:14]);
__block NSUInteger idx = 0;
int32_t *seenKeys = malloc(3 * sizeof(int32_t));
BOOL *seenValues = malloc(3 * sizeof(BOOL));
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, BOOL aValue, BOOL *stop) {
+ [dict enumerateKeysAndBoolsUsingBlock:^(int32_t aKey, BOOL aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1592,7 +1601,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, BOOL aValue, BOOL *stop) {
+ [dict enumerateKeysAndBoolsUsingBlock:^(int32_t aKey, BOOL aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1608,29 +1617,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const BOOL kValues2[] = { YES, NO, NO };
const BOOL kValues3[] = { YES, YES, NO, NO };
GPBInt32BoolDictionary *dict1 =
- [[GPBInt32BoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt32BoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBInt32BoolDictionary *dict1prime =
- [[GPBInt32BoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt32BoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBInt32BoolDictionary *dict2 =
- [[GPBInt32BoolDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt32BoolDictionary alloc] initWithBools:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBInt32BoolDictionary *dict3 =
- [[GPBInt32BoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt32BoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBInt32BoolDictionary *dict4 =
- [[GPBInt32BoolDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBInt32BoolDictionary alloc] initWithBools:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -1659,9 +1668,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBInt32BoolDictionary *dict =
- [[GPBInt32BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt32BoolDictionary *dict2 = [dict copy];
@@ -1680,110 +1689,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBInt32BoolDictionary *dict =
- [[GPBInt32BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt32BoolDictionary *dict2 =
- [GPBInt32BoolDictionary dictionaryWithDictionary:dict];
+ [[GPBInt32BoolDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt32BoolDictionary *dict = [GPBInt32BoolDictionary dictionary];
+ GPBInt32BoolDictionary *dict = [[GPBInt32BoolDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:YES forKey:11];
+ [dict setBool:YES forKey:11];
XCTAssertEqual(dict.count, 1U);
const int32_t kKeys[] = { 12, 13, 14 };
const BOOL kValues[] = { YES, NO, NO };
GPBInt32BoolDictionary *dict2 =
- [[GPBInt32BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
BOOL value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:11]);
+ XCTAssertTrue([dict getBool:&value forKey:11]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:12]);
+ XCTAssertTrue([dict getBool:&value forKey:12]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:13]);
+ XCTAssertTrue([dict getBool:&value forKey:13]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:14]);
+ XCTAssertTrue([dict getBool:&value forKey:14]);
XCTAssertEqual(value, NO);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBInt32BoolDictionary *dict =
- [[GPBInt32BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:12];
+ [dict removeBoolForKey:12];
XCTAssertEqual(dict.count, 3U);
BOOL value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:11]);
+ XCTAssertTrue([dict getBool:&value forKey:11]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getBool:NULL forKey:12]);
+ XCTAssertTrue([dict getBool:NULL forKey:13]);
+ XCTAssertTrue([dict getBool:&value forKey:13]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:14]);
+ XCTAssertTrue([dict getBool:&value forKey:14]);
XCTAssertEqual(value, NO);
// Remove again does nothing.
- [dict removeValueForKey:12];
+ [dict removeBoolForKey:12];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:11]);
+ XCTAssertTrue([dict getBool:&value forKey:11]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getBool:NULL forKey:12]);
+ XCTAssertTrue([dict getBool:NULL forKey:13]);
+ XCTAssertTrue([dict getBool:&value forKey:13]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:14]);
+ XCTAssertTrue([dict getBool:&value forKey:14]);
XCTAssertEqual(value, NO);
- [dict removeValueForKey:14];
+ [dict removeBoolForKey:14];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:11]);
+ XCTAssertTrue([dict getBool:&value forKey:11]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getBool:NULL forKey:12]);
+ XCTAssertTrue([dict getBool:NULL forKey:13]);
+ XCTAssertTrue([dict getBool:&value forKey:13]);
XCTAssertEqual(value, NO);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:14]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertFalse([dict valueForKey:13 value:NULL]);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:11]);
+ XCTAssertFalse([dict getBool:NULL forKey:12]);
+ XCTAssertFalse([dict getBool:NULL forKey:13]);
+ XCTAssertFalse([dict getBool:NULL forKey:14]);
[dict release];
}
@@ -1791,75 +1802,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBInt32BoolDictionary *dict =
- [[GPBInt32BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
BOOL value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:11]);
+ XCTAssertTrue([dict getBool:&value forKey:11]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:12]);
+ XCTAssertTrue([dict getBool:&value forKey:12]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:13]);
+ XCTAssertTrue([dict getBool:&value forKey:13]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:14]);
+ XCTAssertTrue([dict getBool:&value forKey:14]);
XCTAssertEqual(value, NO);
- [dict setValue:NO forKey:11];
+ [dict setBool:NO forKey:11];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:11]);
+ XCTAssertTrue([dict getBool:&value forKey:11]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:12]);
+ XCTAssertTrue([dict getBool:&value forKey:12]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:13]);
+ XCTAssertTrue([dict getBool:&value forKey:13]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:14]);
+ XCTAssertTrue([dict getBool:&value forKey:14]);
XCTAssertEqual(value, NO);
- [dict setValue:YES forKey:14];
+ [dict setBool:YES forKey:14];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:11]);
+ XCTAssertTrue([dict getBool:&value forKey:11]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:12]);
+ XCTAssertTrue([dict getBool:&value forKey:12]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:13]);
+ XCTAssertTrue([dict getBool:&value forKey:13]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:14]);
+ XCTAssertTrue([dict getBool:&value forKey:14]);
XCTAssertEqual(value, YES);
const int32_t kKeys2[] = { 12, 13 };
const BOOL kValues2[] = { NO, YES };
GPBInt32BoolDictionary *dict2 =
- [[GPBInt32BoolDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt32BoolDictionary alloc] initWithBools:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:11]);
+ XCTAssertTrue([dict getBool:&value forKey:11]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:12]);
+ XCTAssertTrue([dict getBool:&value forKey:12]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:13]);
+ XCTAssertTrue([dict getBool:&value forKey:13]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:14]);
+ XCTAssertTrue([dict getBool:&value forKey:14]);
XCTAssertEqual(value, YES);
[dict2 release];
@@ -1879,8 +1890,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBInt32FloatDictionary *dict = [[GPBInt32FloatDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, float aValue, BOOL *stop) {
+ XCTAssertFalse([dict getFloat:NULL forKey:11]);
+ [dict enumerateKeysAndFloatsUsingBlock:^(int32_t aKey, float aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1888,46 +1899,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt32FloatDictionary *dict = [GPBInt32FloatDictionary dictionaryWithValue:500.f forKey:11];
+ GPBInt32FloatDictionary *dict = [[GPBInt32FloatDictionary alloc] init];
+ [dict setFloat:500.f forKey:11];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
float value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:11]);
+ XCTAssertTrue([dict getFloat:&value forKey:11]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, float aValue, BOOL *stop) {
+ XCTAssertFalse([dict getFloat:NULL forKey:12]);
+ [dict enumerateKeysAndFloatsUsingBlock:^(int32_t aKey, float aValue, BOOL *stop) {
XCTAssertEqual(aKey, 11);
XCTAssertEqual(aValue, 500.f);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int32_t kKeys[] = { 11, 12, 13 };
const float kValues[] = { 500.f, 501.f, 502.f };
GPBInt32FloatDictionary *dict =
- [[GPBInt32FloatDictionary alloc] initWithValues:kValues
+ [[GPBInt32FloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
float value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:11]);
+ XCTAssertTrue([dict getFloat:&value forKey:11]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:12]);
+ XCTAssertTrue([dict getFloat:&value forKey:12]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:13]);
+ XCTAssertTrue([dict getFloat:&value forKey:13]);
XCTAssertEqual(value, 502.f);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:14]);
__block NSUInteger idx = 0;
int32_t *seenKeys = malloc(3 * sizeof(int32_t));
float *seenValues = malloc(3 * sizeof(float));
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, float aValue, BOOL *stop) {
+ [dict enumerateKeysAndFloatsUsingBlock:^(int32_t aKey, float aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1949,7 +1962,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, float aValue, BOOL *stop) {
+ [dict enumerateKeysAndFloatsUsingBlock:^(int32_t aKey, float aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1965,27 +1978,27 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const float kValues2[] = { 500.f, 503.f, 502.f };
const float kValues3[] = { 500.f, 501.f, 502.f, 503.f };
GPBInt32FloatDictionary *dict1 =
- [[GPBInt32FloatDictionary alloc] initWithValues:kValues1
+ [[GPBInt32FloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBInt32FloatDictionary *dict1prime =
- [[GPBInt32FloatDictionary alloc] initWithValues:kValues1
+ [[GPBInt32FloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBInt32FloatDictionary *dict2 =
- [[GPBInt32FloatDictionary alloc] initWithValues:kValues2
+ [[GPBInt32FloatDictionary alloc] initWithFloats:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBInt32FloatDictionary *dict3 =
- [[GPBInt32FloatDictionary alloc] initWithValues:kValues1
+ [[GPBInt32FloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBInt32FloatDictionary *dict4 =
- [[GPBInt32FloatDictionary alloc] initWithValues:kValues3
+ [[GPBInt32FloatDictionary alloc] initWithFloats:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -2016,7 +2029,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBInt32FloatDictionary *dict =
- [[GPBInt32FloatDictionary alloc] initWithValues:kValues
+ [[GPBInt32FloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -2037,33 +2050,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBInt32FloatDictionary *dict =
- [[GPBInt32FloatDictionary alloc] initWithValues:kValues
+ [[GPBInt32FloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt32FloatDictionary *dict2 =
- [GPBInt32FloatDictionary dictionaryWithDictionary:dict];
+ [[GPBInt32FloatDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt32FloatDictionary *dict = [GPBInt32FloatDictionary dictionary];
+ GPBInt32FloatDictionary *dict = [[GPBInt32FloatDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:500.f forKey:11];
+ [dict setFloat:500.f forKey:11];
XCTAssertEqual(dict.count, 1U);
const int32_t kKeys[] = { 12, 13, 14 };
const float kValues[] = { 501.f, 502.f, 503.f };
GPBInt32FloatDictionary *dict2 =
- [[GPBInt32FloatDictionary alloc] initWithValues:kValues
+ [[GPBInt32FloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -2071,76 +2085,77 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 4U);
float value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:11]);
+ XCTAssertTrue([dict getFloat:&value forKey:11]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:12]);
+ XCTAssertTrue([dict getFloat:&value forKey:12]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:13]);
+ XCTAssertTrue([dict getFloat:&value forKey:13]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:14]);
+ XCTAssertTrue([dict getFloat:&value forKey:14]);
XCTAssertEqual(value, 503.f);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBInt32FloatDictionary *dict =
- [[GPBInt32FloatDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32FloatDictionary alloc] initWithFloats:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:12];
+ [dict removeFloatForKey:12];
XCTAssertEqual(dict.count, 3U);
float value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:11]);
+ XCTAssertTrue([dict getFloat:&value forKey:11]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getFloat:NULL forKey:12]);
+ XCTAssertTrue([dict getFloat:NULL forKey:13]);
+ XCTAssertTrue([dict getFloat:&value forKey:13]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:14]);
+ XCTAssertTrue([dict getFloat:&value forKey:14]);
XCTAssertEqual(value, 503.f);
// Remove again does nothing.
- [dict removeValueForKey:12];
+ [dict removeFloatForKey:12];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:11]);
+ XCTAssertTrue([dict getFloat:&value forKey:11]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getFloat:NULL forKey:12]);
+ XCTAssertTrue([dict getFloat:NULL forKey:13]);
+ XCTAssertTrue([dict getFloat:&value forKey:13]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:14]);
+ XCTAssertTrue([dict getFloat:&value forKey:14]);
XCTAssertEqual(value, 503.f);
- [dict removeValueForKey:14];
+ [dict removeFloatForKey:14];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:11]);
+ XCTAssertTrue([dict getFloat:&value forKey:11]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getFloat:NULL forKey:12]);
+ XCTAssertTrue([dict getFloat:NULL forKey:13]);
+ XCTAssertTrue([dict getFloat:&value forKey:13]);
XCTAssertEqual(value, 502.f);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:14]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertFalse([dict valueForKey:13 value:NULL]);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:11]);
+ XCTAssertFalse([dict getFloat:NULL forKey:12]);
+ XCTAssertFalse([dict getFloat:NULL forKey:13]);
+ XCTAssertFalse([dict getFloat:NULL forKey:14]);
[dict release];
}
@@ -2148,75 +2163,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBInt32FloatDictionary *dict =
- [[GPBInt32FloatDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32FloatDictionary alloc] initWithFloats:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
float value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:11]);
+ XCTAssertTrue([dict getFloat:&value forKey:11]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:12]);
+ XCTAssertTrue([dict getFloat:&value forKey:12]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:13]);
+ XCTAssertTrue([dict getFloat:&value forKey:13]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:14]);
+ XCTAssertTrue([dict getFloat:&value forKey:14]);
XCTAssertEqual(value, 503.f);
- [dict setValue:503.f forKey:11];
+ [dict setFloat:503.f forKey:11];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:11]);
+ XCTAssertTrue([dict getFloat:&value forKey:11]);
XCTAssertEqual(value, 503.f);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:12]);
+ XCTAssertTrue([dict getFloat:&value forKey:12]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:13]);
+ XCTAssertTrue([dict getFloat:&value forKey:13]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:14]);
+ XCTAssertTrue([dict getFloat:&value forKey:14]);
XCTAssertEqual(value, 503.f);
- [dict setValue:501.f forKey:14];
+ [dict setFloat:501.f forKey:14];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:11]);
+ XCTAssertTrue([dict getFloat:&value forKey:11]);
XCTAssertEqual(value, 503.f);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:12]);
+ XCTAssertTrue([dict getFloat:&value forKey:12]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:13]);
+ XCTAssertTrue([dict getFloat:&value forKey:13]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:14]);
+ XCTAssertTrue([dict getFloat:&value forKey:14]);
XCTAssertEqual(value, 501.f);
const int32_t kKeys2[] = { 12, 13 };
const float kValues2[] = { 502.f, 500.f };
GPBInt32FloatDictionary *dict2 =
- [[GPBInt32FloatDictionary alloc] initWithValues:kValues2
+ [[GPBInt32FloatDictionary alloc] initWithFloats:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:11]);
+ XCTAssertTrue([dict getFloat:&value forKey:11]);
XCTAssertEqual(value, 503.f);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:12]);
+ XCTAssertTrue([dict getFloat:&value forKey:12]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:13]);
+ XCTAssertTrue([dict getFloat:&value forKey:13]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:14]);
+ XCTAssertTrue([dict getFloat:&value forKey:14]);
XCTAssertEqual(value, 501.f);
[dict2 release];
@@ -2236,8 +2251,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBInt32DoubleDictionary *dict = [[GPBInt32DoubleDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, double aValue, BOOL *stop) {
+ XCTAssertFalse([dict getDouble:NULL forKey:11]);
+ [dict enumerateKeysAndDoublesUsingBlock:^(int32_t aKey, double aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -2245,46 +2260,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt32DoubleDictionary *dict = [GPBInt32DoubleDictionary dictionaryWithValue:600. forKey:11];
+ GPBInt32DoubleDictionary *dict = [[GPBInt32DoubleDictionary alloc] init];
+ [dict setDouble:600. forKey:11];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
double value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:11]);
+ XCTAssertTrue([dict getDouble:&value forKey:11]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, double aValue, BOOL *stop) {
+ XCTAssertFalse([dict getDouble:NULL forKey:12]);
+ [dict enumerateKeysAndDoublesUsingBlock:^(int32_t aKey, double aValue, BOOL *stop) {
XCTAssertEqual(aKey, 11);
XCTAssertEqual(aValue, 600.);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int32_t kKeys[] = { 11, 12, 13 };
const double kValues[] = { 600., 601., 602. };
GPBInt32DoubleDictionary *dict =
- [[GPBInt32DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
double value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:11]);
+ XCTAssertTrue([dict getDouble:&value forKey:11]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:12]);
+ XCTAssertTrue([dict getDouble:&value forKey:12]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:13]);
+ XCTAssertTrue([dict getDouble:&value forKey:13]);
XCTAssertEqual(value, 602.);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:14]);
__block NSUInteger idx = 0;
int32_t *seenKeys = malloc(3 * sizeof(int32_t));
double *seenValues = malloc(3 * sizeof(double));
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, double aValue, BOOL *stop) {
+ [dict enumerateKeysAndDoublesUsingBlock:^(int32_t aKey, double aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -2306,7 +2323,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, double aValue, BOOL *stop) {
+ [dict enumerateKeysAndDoublesUsingBlock:^(int32_t aKey, double aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -2322,29 +2339,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const double kValues2[] = { 600., 603., 602. };
const double kValues3[] = { 600., 601., 602., 603. };
GPBInt32DoubleDictionary *dict1 =
- [[GPBInt32DoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt32DoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBInt32DoubleDictionary *dict1prime =
- [[GPBInt32DoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt32DoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBInt32DoubleDictionary *dict2 =
- [[GPBInt32DoubleDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt32DoubleDictionary alloc] initWithDoubles:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBInt32DoubleDictionary *dict3 =
- [[GPBInt32DoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt32DoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBInt32DoubleDictionary *dict4 =
- [[GPBInt32DoubleDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBInt32DoubleDictionary alloc] initWithDoubles:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -2373,9 +2390,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const double kValues[] = { 600., 601., 602., 603. };
GPBInt32DoubleDictionary *dict =
- [[GPBInt32DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt32DoubleDictionary *dict2 = [dict copy];
@@ -2394,110 +2411,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const double kValues[] = { 600., 601., 602., 603. };
GPBInt32DoubleDictionary *dict =
- [[GPBInt32DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt32DoubleDictionary *dict2 =
- [GPBInt32DoubleDictionary dictionaryWithDictionary:dict];
+ [[GPBInt32DoubleDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt32DoubleDictionary *dict = [GPBInt32DoubleDictionary dictionary];
+ GPBInt32DoubleDictionary *dict = [[GPBInt32DoubleDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:600. forKey:11];
+ [dict setDouble:600. forKey:11];
XCTAssertEqual(dict.count, 1U);
const int32_t kKeys[] = { 12, 13, 14 };
const double kValues[] = { 601., 602., 603. };
GPBInt32DoubleDictionary *dict2 =
- [[GPBInt32DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
double value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:11]);
+ XCTAssertTrue([dict getDouble:&value forKey:11]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:12]);
+ XCTAssertTrue([dict getDouble:&value forKey:12]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:13]);
+ XCTAssertTrue([dict getDouble:&value forKey:13]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:14]);
+ XCTAssertTrue([dict getDouble:&value forKey:14]);
XCTAssertEqual(value, 603.);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const double kValues[] = { 600., 601., 602., 603. };
GPBInt32DoubleDictionary *dict =
- [[GPBInt32DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:12];
+ [dict removeDoubleForKey:12];
XCTAssertEqual(dict.count, 3U);
double value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:11]);
+ XCTAssertTrue([dict getDouble:&value forKey:11]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getDouble:NULL forKey:12]);
+ XCTAssertTrue([dict getDouble:NULL forKey:13]);
+ XCTAssertTrue([dict getDouble:&value forKey:13]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:14]);
+ XCTAssertTrue([dict getDouble:&value forKey:14]);
XCTAssertEqual(value, 603.);
// Remove again does nothing.
- [dict removeValueForKey:12];
+ [dict removeDoubleForKey:12];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:11]);
+ XCTAssertTrue([dict getDouble:&value forKey:11]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getDouble:NULL forKey:12]);
+ XCTAssertTrue([dict getDouble:NULL forKey:13]);
+ XCTAssertTrue([dict getDouble:&value forKey:13]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:14]);
+ XCTAssertTrue([dict getDouble:&value forKey:14]);
XCTAssertEqual(value, 603.);
- [dict removeValueForKey:14];
+ [dict removeDoubleForKey:14];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:11]);
+ XCTAssertTrue([dict getDouble:&value forKey:11]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getDouble:NULL forKey:12]);
+ XCTAssertTrue([dict getDouble:NULL forKey:13]);
+ XCTAssertTrue([dict getDouble:&value forKey:13]);
XCTAssertEqual(value, 602.);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:14]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertFalse([dict valueForKey:13 value:NULL]);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:11]);
+ XCTAssertFalse([dict getDouble:NULL forKey:12]);
+ XCTAssertFalse([dict getDouble:NULL forKey:13]);
+ XCTAssertFalse([dict getDouble:NULL forKey:14]);
[dict release];
}
@@ -2505,75 +2524,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const double kValues[] = { 600., 601., 602., 603. };
GPBInt32DoubleDictionary *dict =
- [[GPBInt32DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
double value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:11]);
+ XCTAssertTrue([dict getDouble:&value forKey:11]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:12]);
+ XCTAssertTrue([dict getDouble:&value forKey:12]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:13]);
+ XCTAssertTrue([dict getDouble:&value forKey:13]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:14]);
+ XCTAssertTrue([dict getDouble:&value forKey:14]);
XCTAssertEqual(value, 603.);
- [dict setValue:603. forKey:11];
+ [dict setDouble:603. forKey:11];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:11]);
+ XCTAssertTrue([dict getDouble:&value forKey:11]);
XCTAssertEqual(value, 603.);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:12]);
+ XCTAssertTrue([dict getDouble:&value forKey:12]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:13]);
+ XCTAssertTrue([dict getDouble:&value forKey:13]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:14]);
+ XCTAssertTrue([dict getDouble:&value forKey:14]);
XCTAssertEqual(value, 603.);
- [dict setValue:601. forKey:14];
+ [dict setDouble:601. forKey:14];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:11]);
+ XCTAssertTrue([dict getDouble:&value forKey:11]);
XCTAssertEqual(value, 603.);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:12]);
+ XCTAssertTrue([dict getDouble:&value forKey:12]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:13]);
+ XCTAssertTrue([dict getDouble:&value forKey:13]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:14]);
+ XCTAssertTrue([dict getDouble:&value forKey:14]);
XCTAssertEqual(value, 601.);
const int32_t kKeys2[] = { 12, 13 };
const double kValues2[] = { 602., 600. };
GPBInt32DoubleDictionary *dict2 =
- [[GPBInt32DoubleDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt32DoubleDictionary alloc] initWithDoubles:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:11]);
+ XCTAssertTrue([dict getDouble:&value forKey:11]);
XCTAssertEqual(value, 603.);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:12]);
+ XCTAssertTrue([dict getDouble:&value forKey:12]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:13]);
+ XCTAssertTrue([dict getDouble:&value forKey:13]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:14]);
+ XCTAssertTrue([dict getDouble:&value forKey:14]);
XCTAssertEqual(value, 601.);
[dict2 release];
@@ -2593,8 +2612,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBInt32EnumDictionary *dict = [[GPBInt32EnumDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getEnum:NULL forKey:11]);
+ [dict enumerateKeysAndEnumsUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -2602,46 +2621,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt32EnumDictionary *dict = [GPBInt32EnumDictionary dictionaryWithValue:700 forKey:11];
+ GPBInt32EnumDictionary *dict = [[GPBInt32EnumDictionary alloc] init];
+ [dict setEnum:700 forKey:11];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:11]);
+ XCTAssertTrue([dict getEnum:&value forKey:11]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getEnum:NULL forKey:12]);
+ [dict enumerateKeysAndEnumsUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 11);
XCTAssertEqual(aValue, 700);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int32_t kKeys[] = { 11, 12, 13 };
const int32_t kValues[] = { 700, 701, 702 };
GPBInt32EnumDictionary *dict =
- [[GPBInt32EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:11]);
+ XCTAssertTrue([dict getEnum:&value forKey:11]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:12]);
+ XCTAssertTrue([dict getEnum:&value forKey:12]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:14]);
__block NSUInteger idx = 0;
int32_t *seenKeys = malloc(3 * sizeof(int32_t));
int32_t *seenValues = malloc(3 * sizeof(int32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndEnumsUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -2663,7 +2684,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndEnumsUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -2679,29 +2700,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kValues2[] = { 700, 703, 702 };
const int32_t kValues3[] = { 700, 701, 702, 703 };
GPBInt32EnumDictionary *dict1 =
- [[GPBInt32EnumDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt32EnumDictionary alloc] initWithEnums:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBInt32EnumDictionary *dict1prime =
- [[GPBInt32EnumDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt32EnumDictionary alloc] initWithEnums:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBInt32EnumDictionary *dict2 =
- [[GPBInt32EnumDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt32EnumDictionary alloc] initWithEnums:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBInt32EnumDictionary *dict3 =
- [[GPBInt32EnumDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt32EnumDictionary alloc] initWithEnums:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBInt32EnumDictionary *dict4 =
- [[GPBInt32EnumDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBInt32EnumDictionary alloc] initWithEnums:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -2730,9 +2751,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBInt32EnumDictionary *dict =
- [[GPBInt32EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt32EnumDictionary *dict2 = [dict copy];
@@ -2751,110 +2772,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBInt32EnumDictionary *dict =
- [[GPBInt32EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt32EnumDictionary *dict2 =
- [GPBInt32EnumDictionary dictionaryWithDictionary:dict];
+ [[GPBInt32EnumDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt32EnumDictionary *dict = [GPBInt32EnumDictionary dictionary];
+ GPBInt32EnumDictionary *dict = [[GPBInt32EnumDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:700 forKey:11];
+ [dict setEnum:700 forKey:11];
XCTAssertEqual(dict.count, 1U);
const int32_t kKeys[] = { 12, 13, 14 };
const int32_t kValues[] = { 701, 702, 703 };
GPBInt32EnumDictionary *dict2 =
- [[GPBInt32EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:11]);
+ XCTAssertTrue([dict getEnum:&value forKey:11]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:12]);
+ XCTAssertTrue([dict getEnum:&value forKey:12]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:14]);
+ XCTAssertTrue([dict getEnum:&value forKey:14]);
XCTAssertEqual(value, 703);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBInt32EnumDictionary *dict =
- [[GPBInt32EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:12];
+ [dict removeEnumForKey:12];
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:11]);
+ XCTAssertTrue([dict getEnum:&value forKey:11]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:12]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:14]);
+ XCTAssertTrue([dict getEnum:&value forKey:14]);
XCTAssertEqual(value, 703);
// Remove again does nothing.
- [dict removeValueForKey:12];
+ [dict removeEnumForKey:12];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:11]);
+ XCTAssertTrue([dict getEnum:&value forKey:11]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:12]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:14]);
+ XCTAssertTrue([dict getEnum:&value forKey:14]);
XCTAssertEqual(value, 703);
- [dict removeValueForKey:14];
+ [dict removeEnumForKey:14];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:11]);
+ XCTAssertTrue([dict getEnum:&value forKey:11]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:12]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:14]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertFalse([dict valueForKey:13 value:NULL]);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:11]);
+ XCTAssertFalse([dict getEnum:NULL forKey:12]);
+ XCTAssertFalse([dict getEnum:NULL forKey:13]);
+ XCTAssertFalse([dict getEnum:NULL forKey:14]);
[dict release];
}
@@ -2862,75 +2885,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 12, 13, 14 };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBInt32EnumDictionary *dict =
- [[GPBInt32EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:11]);
+ XCTAssertTrue([dict getEnum:&value forKey:11]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:12]);
+ XCTAssertTrue([dict getEnum:&value forKey:12]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:14]);
+ XCTAssertTrue([dict getEnum:&value forKey:14]);
XCTAssertEqual(value, 703);
- [dict setValue:703 forKey:11];
+ [dict setEnum:703 forKey:11];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:11]);
+ XCTAssertTrue([dict getEnum:&value forKey:11]);
XCTAssertEqual(value, 703);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:12]);
+ XCTAssertTrue([dict getEnum:&value forKey:12]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:14]);
+ XCTAssertTrue([dict getEnum:&value forKey:14]);
XCTAssertEqual(value, 703);
- [dict setValue:701 forKey:14];
+ [dict setEnum:701 forKey:14];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:11]);
+ XCTAssertTrue([dict getEnum:&value forKey:11]);
XCTAssertEqual(value, 703);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:12]);
+ XCTAssertTrue([dict getEnum:&value forKey:12]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:14]);
+ XCTAssertTrue([dict getEnum:&value forKey:14]);
XCTAssertEqual(value, 701);
const int32_t kKeys2[] = { 12, 13 };
const int32_t kValues2[] = { 702, 700 };
GPBInt32EnumDictionary *dict2 =
- [[GPBInt32EnumDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt32EnumDictionary alloc] initWithEnums:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:11]);
+ XCTAssertTrue([dict getEnum:&value forKey:11]);
XCTAssertEqual(value, 703);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:12]);
+ XCTAssertTrue([dict getEnum:&value forKey:12]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:14]);
+ XCTAssertTrue([dict getEnum:&value forKey:14]);
XCTAssertEqual(value, 701);
[dict2 release];
@@ -2958,24 +2981,24 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 3U);
XCTAssertTrue(dict.validationFunc == TestingEnum_IsValidValue); // Pointer comparison
int32_t value;
- XCTAssertTrue([dict valueForKey:11 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:11 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:11]);
+ XCTAssertTrue([dict getRawValue:&value forKey:11]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:12]);
+ XCTAssertTrue([dict getEnum:&value forKey:12]);
XCTAssertEqual(value, kGPBUnrecognizedEnumeratorValue);
- XCTAssertTrue([dict valueForKey:12 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:12 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:12]);
+ XCTAssertTrue([dict getRawValue:&value forKey:12]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:13 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:13 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:13]);
+ XCTAssertTrue([dict getRawValue:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:14 rawValue:NULL]);
+ XCTAssertFalse([dict getRawValue:NULL forKey:14]);
__block NSUInteger idx = 0;
int32_t *seenKeys = malloc(3 * sizeof(int32_t));
int32_t *seenValues = malloc(3 * sizeof(int32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndEnumsUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -3120,23 +3143,24 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBInt32EnumDictionary *dict2 =
- [GPBInt32EnumDictionary dictionaryWithDictionary:dict];
+ [[GPBInt32EnumDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
XCTAssertEqual(dict.validationFunc, dict2.validationFunc); // Pointer comparison
+ [dict2 release];
[dict release];
}
- (void)testUnknownAdds {
GPBInt32EnumDictionary *dict =
- [GPBInt32EnumDictionary dictionaryWithValidationFunction:TestingEnum_IsValidValue];
+ [[GPBInt32EnumDictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertThrowsSpecificNamed([dict setValue:801 forKey:12], // Unknown
+ XCTAssertThrowsSpecificNamed([dict setEnum:801 forKey:12], // Unknown
NSException, NSInvalidArgumentException);
XCTAssertEqual(dict.count, 0U);
[dict setRawValue:801 forKey:12]; // Unknown
@@ -3145,33 +3169,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kKeys[] = { 11, 13, 14 };
const int32_t kValues[] = { 700, 702, 803 }; // Unknown
GPBInt32EnumDictionary *dict2 =
- [[GPBInt32EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt32EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:11]);
+ XCTAssertTrue([dict getEnum:&value forKey:11]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:12]);
+ XCTAssertTrue([dict getEnum:&value forKey:12]);
XCTAssertEqual(value, kGPBUnrecognizedEnumeratorValue);
- XCTAssertTrue([dict valueForKey:12 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:12 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:12]);
+ XCTAssertTrue([dict getRawValue:&value forKey:12]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:14]);
+ XCTAssertTrue([dict getEnum:&value forKey:14]);
XCTAssertEqual(value, kGPBUnrecognizedEnumeratorValue);
- XCTAssertTrue([dict valueForKey:14 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:14 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:14]);
+ XCTAssertTrue([dict getRawValue:&value forKey:14]);
XCTAssertEqual(value, 803);
[dict2 release];
+ [dict release];
}
- (void)testUnknownRemove {
@@ -3185,51 +3210,51 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:12];
+ [dict removeEnumForKey:12];
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:11]);
+ XCTAssertTrue([dict getEnum:&value forKey:11]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:12]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:14 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:14 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:14]);
+ XCTAssertTrue([dict getRawValue:&value forKey:14]);
XCTAssertEqual(value, 803);
// Remove again does nothing.
- [dict removeValueForKey:12];
+ [dict removeEnumForKey:12];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:11]);
+ XCTAssertTrue([dict getEnum:&value forKey:11]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:12]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:14 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:14 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:14]);
+ XCTAssertTrue([dict getRawValue:&value forKey:14]);
XCTAssertEqual(value, 803);
- [dict removeValueForKey:14];
+ [dict removeEnumForKey:14];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:11]);
+ XCTAssertTrue([dict getEnum:&value forKey:11]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:12]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:14]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:11 value:NULL]);
- XCTAssertFalse([dict valueForKey:12 value:NULL]);
- XCTAssertFalse([dict valueForKey:13 value:NULL]);
- XCTAssertFalse([dict valueForKey:14 value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:11]);
+ XCTAssertFalse([dict getEnum:NULL forKey:12]);
+ XCTAssertFalse([dict getEnum:NULL forKey:13]);
+ XCTAssertFalse([dict getEnum:NULL forKey:14]);
[dict release];
}
@@ -3244,63 +3269,63 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:11]);
+ XCTAssertTrue([dict getEnum:&value forKey:11]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:12 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:12 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:12]);
+ XCTAssertTrue([dict getRawValue:&value forKey:12]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:14 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:14 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:14]);
+ XCTAssertTrue([dict getRawValue:&value forKey:14]);
XCTAssertEqual(value, 803);
- XCTAssertThrowsSpecificNamed([dict setValue:803 forKey:11], // Unknown
+ XCTAssertThrowsSpecificNamed([dict setEnum:803 forKey:11], // Unknown
NSException, NSInvalidArgumentException);
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 value:NULL]);
- XCTAssertTrue([dict valueForKey:11 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:11]);
+ XCTAssertTrue([dict getEnum:&value forKey:11]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:12 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:12 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:12]);
+ XCTAssertTrue([dict getRawValue:&value forKey:12]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:14 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:14 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:14]);
+ XCTAssertTrue([dict getRawValue:&value forKey:14]);
XCTAssertEqual(value, 803);
[dict setRawValue:803 forKey:11]; // Unknown
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:11 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:11]);
+ XCTAssertTrue([dict getRawValue:&value forKey:11]);
XCTAssertEqual(value, 803);
- XCTAssertTrue([dict valueForKey:12 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:12 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:12]);
+ XCTAssertTrue([dict getRawValue:&value forKey:12]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:14 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:14 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:14]);
+ XCTAssertTrue([dict getRawValue:&value forKey:14]);
XCTAssertEqual(value, 803);
[dict setRawValue:700 forKey:14];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:11 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:11]);
+ XCTAssertTrue([dict getRawValue:&value forKey:11]);
XCTAssertEqual(value, 803);
- XCTAssertTrue([dict valueForKey:12 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:12 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:12]);
+ XCTAssertTrue([dict getRawValue:&value forKey:12]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:13 value:NULL]);
- XCTAssertTrue([dict valueForKey:13 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:13]);
+ XCTAssertTrue([dict getEnum:&value forKey:13]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:14]);
+ XCTAssertTrue([dict getEnum:&value forKey:14]);
XCTAssertEqual(value, 700);
const int32_t kKeys2[] = { 12, 13 };
@@ -3313,17 +3338,17 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:11 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:11 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:11]);
+ XCTAssertTrue([dict getRawValue:&value forKey:11]);
XCTAssertEqual(value, 803);
- XCTAssertTrue([dict valueForKey:12 value:NULL]);
- XCTAssertTrue([dict valueForKey:12 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:12]);
+ XCTAssertTrue([dict getEnum:&value forKey:12]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:13 rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:13 rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:13]);
+ XCTAssertTrue([dict getRawValue:&value forKey:13]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:14 value:NULL]);
- XCTAssertTrue([dict valueForKey:14 value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:14]);
+ XCTAssertTrue([dict getEnum:&value forKey:14]);
XCTAssertEqual(value, 700);
[dict2 release];
@@ -3363,11 +3388,11 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
@implementation GPBInt32ObjectDictionaryTests
- (void)testEmpty {
- GPBInt32ObjectDictionary *dict = [[GPBInt32ObjectDictionary alloc] init];
+ GPBInt32ObjectDictionary<NSString*> *dict = [[GPBInt32ObjectDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
XCTAssertNil([dict objectForKey:11]);
- [dict enumerateKeysAndObjectsUsingBlock:^(int32_t aKey, id aObject, BOOL *stop) {
+ [dict enumerateKeysAndObjectsUsingBlock:^(int32_t aKey, NSString* aObject, BOOL *stop) {
#pragma unused(aKey, aObject, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -3375,22 +3400,24 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt32ObjectDictionary *dict = [GPBInt32ObjectDictionary dictionaryWithObject:@"abc" forKey:11];
+ GPBInt32ObjectDictionary<NSString*> *dict = [[GPBInt32ObjectDictionary alloc] init];
+ [dict setObject:@"abc" forKey:11];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
XCTAssertEqualObjects([dict objectForKey:11], @"abc");
XCTAssertNil([dict objectForKey:12]);
- [dict enumerateKeysAndObjectsUsingBlock:^(int32_t aKey, id aObject, BOOL *stop) {
+ [dict enumerateKeysAndObjectsUsingBlock:^(int32_t aKey, NSString* aObject, BOOL *stop) {
XCTAssertEqual(aKey, 11);
XCTAssertEqualObjects(aObject, @"abc");
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int32_t kKeys[] = { 11, 12, 13 };
- const id kObjects[] = { @"abc", @"def", @"ghi" };
- GPBInt32ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi" };
+ GPBInt32ObjectDictionary<NSString*> *dict =
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
@@ -3403,8 +3430,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
__block NSUInteger idx = 0;
int32_t *seenKeys = malloc(3 * sizeof(int32_t));
- id *seenObjects = malloc(3 * sizeof(id));
- [dict enumerateKeysAndObjectsUsingBlock:^(int32_t aKey, id aObject, BOOL *stop) {
+ NSString* *seenObjects = malloc(3 * sizeof(NSString*));
+ [dict enumerateKeysAndObjectsUsingBlock:^(int32_t aKey, NSString* aObject, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenObjects[idx] = aObject;
@@ -3426,7 +3453,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndObjectsUsingBlock:^(int32_t aKey, id aObject, BOOL *stop) {
+ [dict enumerateKeysAndObjectsUsingBlock:^(int32_t aKey, NSString* aObject, BOOL *stop) {
#pragma unused(aKey, aObject)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -3438,30 +3465,30 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
- (void)testEquality {
const int32_t kKeys1[] = { 11, 12, 13, 14 };
const int32_t kKeys2[] = { 12, 11, 14 };
- const id kObjects1[] = { @"abc", @"def", @"ghi" };
- const id kObjects2[] = { @"abc", @"jkl", @"ghi" };
- const id kObjects3[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBInt32ObjectDictionary *dict1 =
+ const NSString* kObjects1[] = { @"abc", @"def", @"ghi" };
+ const NSString* kObjects2[] = { @"abc", @"jkl", @"ghi" };
+ const NSString* kObjects3[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBInt32ObjectDictionary<NSString*> *dict1 =
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects1
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects1)];
XCTAssertNotNil(dict1);
- GPBInt32ObjectDictionary *dict1prime =
+ GPBInt32ObjectDictionary<NSString*> *dict1prime =
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects1
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects1)];
XCTAssertNotNil(dict1prime);
- GPBInt32ObjectDictionary *dict2 =
+ GPBInt32ObjectDictionary<NSString*> *dict2 =
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects2
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects2)];
XCTAssertNotNil(dict2);
- GPBInt32ObjectDictionary *dict3 =
+ GPBInt32ObjectDictionary<NSString*> *dict3 =
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects1
forKeys:kKeys2
count:GPBARRAYSIZE(kObjects1)];
XCTAssertNotNil(dict3);
- GPBInt32ObjectDictionary *dict4 =
+ GPBInt32ObjectDictionary<NSString*> *dict4 =
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects3
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects3)];
@@ -3491,14 +3518,14 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
- (void)testCopy {
const int32_t kKeys[] = { 11, 12, 13, 14 };
- const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBInt32ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBInt32ObjectDictionary<NSString*> *dict =
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
- GPBInt32ObjectDictionary *dict2 = [dict copy];
+ GPBInt32ObjectDictionary<NSString*> *dict2 = [dict copy];
XCTAssertNotNil(dict2);
// Should be new object but equal.
@@ -3512,25 +3539,26 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
- (void)testDictionaryFromDictionary {
const int32_t kKeys[] = { 11, 12, 13, 14 };
- const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBInt32ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBInt32ObjectDictionary<NSString*> *dict =
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
- GPBInt32ObjectDictionary *dict2 =
- [GPBInt32ObjectDictionary dictionaryWithDictionary:dict];
+ GPBInt32ObjectDictionary<NSString*> *dict2 =
+ [[GPBInt32ObjectDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt32ObjectDictionary *dict = [GPBInt32ObjectDictionary dictionary];
+ GPBInt32ObjectDictionary<NSString*> *dict = [[GPBInt32ObjectDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@@ -3538,8 +3566,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 1U);
const int32_t kKeys[] = { 12, 13, 14 };
- const id kObjects[] = { @"def", @"ghi", @"jkl" };
- GPBInt32ObjectDictionary *dict2 =
+ const NSString* kObjects[] = { @"def", @"ghi", @"jkl" };
+ GPBInt32ObjectDictionary<NSString*> *dict2 =
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
@@ -3552,15 +3580,16 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqualObjects([dict objectForKey:13], @"ghi");
XCTAssertEqualObjects([dict objectForKey:14], @"jkl");
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int32_t kKeys[] = { 11, 12, 13, 14 };
- const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBInt32ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBInt32ObjectDictionary<NSString*> *dict =
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects
- forKeys:kKeys
- count:GPBARRAYSIZE(kObjects)];
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
@@ -3597,11 +3626,11 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
- (void)testInplaceMutation {
const int32_t kKeys[] = { 11, 12, 13, 14 };
- const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBInt32ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBInt32ObjectDictionary<NSString*> *dict =
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects
- forKeys:kKeys
- count:GPBARRAYSIZE(kObjects)];
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
XCTAssertEqualObjects([dict objectForKey:11], @"abc");
@@ -3624,8 +3653,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqualObjects([dict objectForKey:14], @"def");
const int32_t kKeys2[] = { 12, 13 };
- const id kObjects2[] = { @"ghi", @"abc" };
- GPBInt32ObjectDictionary *dict2 =
+ const NSString* kObjects2[] = { @"ghi", @"abc" };
+ GPBInt32ObjectDictionary<NSString*> *dict2 =
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects2
forKeys:kKeys2
count:GPBARRAYSIZE(kObjects2)];
diff --git a/objectivec/Tests/GPBDictionaryTests+Int64.m b/objectivec/Tests/GPBDictionaryTests+Int64.m
index 27f77f28..966024b7 100644
--- a/objectivec/Tests/GPBDictionaryTests+Int64.m
+++ b/objectivec/Tests/GPBDictionaryTests+Int64.m
@@ -45,10 +45,9 @@
// To let the testing macros work, add some extra methods to simplify things.
@interface GPBInt64EnumDictionary (TestingTweak)
-+ (instancetype)dictionaryWithValue:(int32_t)value forKey:(int64_t)key;
-- (instancetype)initWithValues:(const int32_t [])values
- forKeys:(const int64_t [])keys
- count:(NSUInteger)count;
+- (instancetype)initWithEnums:(const int32_t [])values
+ forKeys:(const int64_t [])keys
+ count:(NSUInteger)count;
@end
static BOOL TestingEnum_IsValidValue(int32_t value) {
@@ -64,17 +63,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
@implementation GPBInt64EnumDictionary (TestingTweak)
-+ (instancetype)dictionaryWithValue:(int32_t)value forKey:(int64_t)key {
- // Cast is needed to compiler knows what class we are invoking initWithValues: on to get the
- // type correct.
- return [[(GPBInt64EnumDictionary*)[self alloc] initWithValidationFunction:TestingEnum_IsValidValue
- rawValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-- (instancetype)initWithValues:(const int32_t [])values
- forKeys:(const int64_t [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithEnums:(const int32_t [])values
+ forKeys:(const int64_t [])keys
+ count:(NSUInteger)count {
return [self initWithValidationFunction:TestingEnum_IsValidValue
rawValues:values
forKeys:keys
@@ -94,8 +85,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBInt64UInt32Dictionary *dict = [[GPBInt64UInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, uint32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt32:NULL forKey:21LL]);
+ [dict enumerateKeysAndUInt32sUsingBlock:^(int64_t aKey, uint32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -103,46 +94,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt64UInt32Dictionary *dict = [GPBInt64UInt32Dictionary dictionaryWithValue:100U forKey:21LL];
+ GPBInt64UInt32Dictionary *dict = [[GPBInt64UInt32Dictionary alloc] init];
+ [dict setUInt32:100U forKey:21LL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:21LL]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, uint32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt32:NULL forKey:22LL]);
+ [dict enumerateKeysAndUInt32sUsingBlock:^(int64_t aKey, uint32_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 21LL);
XCTAssertEqual(aValue, 100U);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int64_t kKeys[] = { 21LL, 22LL, 23LL };
const uint32_t kValues[] = { 100U, 101U, 102U };
GPBInt64UInt32Dictionary *dict =
- [[GPBInt64UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:21LL]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:22LL]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:23LL]);
XCTAssertEqual(value, 102U);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:24LL]);
__block NSUInteger idx = 0;
int64_t *seenKeys = malloc(3 * sizeof(int64_t));
uint32_t *seenValues = malloc(3 * sizeof(uint32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, uint32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt32sUsingBlock:^(int64_t aKey, uint32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -164,7 +157,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, uint32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt32sUsingBlock:^(int64_t aKey, uint32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -180,29 +173,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kValues2[] = { 100U, 103U, 102U };
const uint32_t kValues3[] = { 100U, 101U, 102U, 103U };
GPBInt64UInt32Dictionary *dict1 =
- [[GPBInt64UInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt64UInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBInt64UInt32Dictionary *dict1prime =
- [[GPBInt64UInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt64UInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBInt64UInt32Dictionary *dict2 =
- [[GPBInt64UInt32Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt64UInt32Dictionary alloc] initWithUInt32s:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBInt64UInt32Dictionary *dict3 =
- [[GPBInt64UInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt64UInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBInt64UInt32Dictionary *dict4 =
- [[GPBInt64UInt32Dictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBInt64UInt32Dictionary alloc] initWithUInt32s:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -231,9 +224,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBInt64UInt32Dictionary *dict =
- [[GPBInt64UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt64UInt32Dictionary *dict2 = [dict copy];
@@ -252,110 +245,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBInt64UInt32Dictionary *dict =
- [[GPBInt64UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt64UInt32Dictionary *dict2 =
- [GPBInt64UInt32Dictionary dictionaryWithDictionary:dict];
+ [[GPBInt64UInt32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt64UInt32Dictionary *dict = [GPBInt64UInt32Dictionary dictionary];
+ GPBInt64UInt32Dictionary *dict = [[GPBInt64UInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:100U forKey:21LL];
+ [dict setUInt32:100U forKey:21LL];
XCTAssertEqual(dict.count, 1U);
const int64_t kKeys[] = { 22LL, 23LL, 24LL };
const uint32_t kValues[] = { 101U, 102U, 103U };
GPBInt64UInt32Dictionary *dict2 =
- [[GPBInt64UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:21LL]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:22LL]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:23LL]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:24LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:24LL]);
XCTAssertEqual(value, 103U);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBInt64UInt32Dictionary *dict =
- [[GPBInt64UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:22LL];
+ [dict removeUInt32ForKey:22LL];
XCTAssertEqual(dict.count, 3U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:21LL]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:23LL]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:24LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:24LL]);
XCTAssertEqual(value, 103U);
// Remove again does nothing.
- [dict removeValueForKey:22LL];
+ [dict removeUInt32ForKey:22LL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:21LL]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:23LL]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:24LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:24LL]);
XCTAssertEqual(value, 103U);
- [dict removeValueForKey:24LL];
+ [dict removeUInt32ForKey:24LL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:21LL]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:23LL]);
XCTAssertEqual(value, 102U);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:24LL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertFalse([dict valueForKey:23LL value:NULL]);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:21LL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:22LL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:23LL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:24LL]);
[dict release];
}
@@ -363,75 +358,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBInt64UInt32Dictionary *dict =
- [[GPBInt64UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:21LL]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:22LL]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:23LL]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:24LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:24LL]);
XCTAssertEqual(value, 103U);
- [dict setValue:103U forKey:21LL];
+ [dict setUInt32:103U forKey:21LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:21LL]);
XCTAssertEqual(value, 103U);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:22LL]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:23LL]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:24LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:24LL]);
XCTAssertEqual(value, 103U);
- [dict setValue:101U forKey:24LL];
+ [dict setUInt32:101U forKey:24LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:21LL]);
XCTAssertEqual(value, 103U);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:22LL]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:23LL]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:24LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:24LL]);
XCTAssertEqual(value, 101U);
const int64_t kKeys2[] = { 22LL, 23LL };
const uint32_t kValues2[] = { 102U, 100U };
GPBInt64UInt32Dictionary *dict2 =
- [[GPBInt64UInt32Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt64UInt32Dictionary alloc] initWithUInt32s:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:21LL]);
XCTAssertEqual(value, 103U);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:22LL]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:23LL]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:24LL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:24LL]);
XCTAssertEqual(value, 101U);
[dict2 release];
@@ -451,8 +446,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBInt64Int32Dictionary *dict = [[GPBInt64Int32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt32:NULL forKey:21LL]);
+ [dict enumerateKeysAndInt32sUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -460,46 +455,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt64Int32Dictionary *dict = [GPBInt64Int32Dictionary dictionaryWithValue:200 forKey:21LL];
+ GPBInt64Int32Dictionary *dict = [[GPBInt64Int32Dictionary alloc] init];
+ [dict setInt32:200 forKey:21LL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:21LL]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt32:NULL forKey:22LL]);
+ [dict enumerateKeysAndInt32sUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 21LL);
XCTAssertEqual(aValue, 200);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int64_t kKeys[] = { 21LL, 22LL, 23LL };
const int32_t kValues[] = { 200, 201, 202 };
GPBInt64Int32Dictionary *dict =
- [[GPBInt64Int32Dictionary alloc] initWithValues:kValues
+ [[GPBInt64Int32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:21LL]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:22LL]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:23LL]);
XCTAssertEqual(value, 202);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:24LL]);
__block NSUInteger idx = 0;
int64_t *seenKeys = malloc(3 * sizeof(int64_t));
int32_t *seenValues = malloc(3 * sizeof(int32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt32sUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -521,7 +518,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt32sUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -537,27 +534,27 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kValues2[] = { 200, 203, 202 };
const int32_t kValues3[] = { 200, 201, 202, 203 };
GPBInt64Int32Dictionary *dict1 =
- [[GPBInt64Int32Dictionary alloc] initWithValues:kValues1
+ [[GPBInt64Int32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBInt64Int32Dictionary *dict1prime =
- [[GPBInt64Int32Dictionary alloc] initWithValues:kValues1
+ [[GPBInt64Int32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBInt64Int32Dictionary *dict2 =
- [[GPBInt64Int32Dictionary alloc] initWithValues:kValues2
+ [[GPBInt64Int32Dictionary alloc] initWithInt32s:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBInt64Int32Dictionary *dict3 =
- [[GPBInt64Int32Dictionary alloc] initWithValues:kValues1
+ [[GPBInt64Int32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBInt64Int32Dictionary *dict4 =
- [[GPBInt64Int32Dictionary alloc] initWithValues:kValues3
+ [[GPBInt64Int32Dictionary alloc] initWithInt32s:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -588,7 +585,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBInt64Int32Dictionary *dict =
- [[GPBInt64Int32Dictionary alloc] initWithValues:kValues
+ [[GPBInt64Int32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -609,33 +606,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBInt64Int32Dictionary *dict =
- [[GPBInt64Int32Dictionary alloc] initWithValues:kValues
+ [[GPBInt64Int32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt64Int32Dictionary *dict2 =
- [GPBInt64Int32Dictionary dictionaryWithDictionary:dict];
+ [[GPBInt64Int32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt64Int32Dictionary *dict = [GPBInt64Int32Dictionary dictionary];
+ GPBInt64Int32Dictionary *dict = [[GPBInt64Int32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:200 forKey:21LL];
+ [dict setInt32:200 forKey:21LL];
XCTAssertEqual(dict.count, 1U);
const int64_t kKeys[] = { 22LL, 23LL, 24LL };
const int32_t kValues[] = { 201, 202, 203 };
GPBInt64Int32Dictionary *dict2 =
- [[GPBInt64Int32Dictionary alloc] initWithValues:kValues
+ [[GPBInt64Int32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -643,76 +641,77 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:21LL]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:22LL]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:23LL]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:24LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:24LL]);
XCTAssertEqual(value, 203);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBInt64Int32Dictionary *dict =
- [[GPBInt64Int32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64Int32Dictionary alloc] initWithInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:22LL];
+ [dict removeInt32ForKey:22LL];
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:21LL]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:23LL]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:24LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:24LL]);
XCTAssertEqual(value, 203);
// Remove again does nothing.
- [dict removeValueForKey:22LL];
+ [dict removeInt32ForKey:22LL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:21LL]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:23LL]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:24LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:24LL]);
XCTAssertEqual(value, 203);
- [dict removeValueForKey:24LL];
+ [dict removeInt32ForKey:24LL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:21LL]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:23LL]);
XCTAssertEqual(value, 202);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:24LL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertFalse([dict valueForKey:23LL value:NULL]);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:21LL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:22LL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:23LL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:24LL]);
[dict release];
}
@@ -720,75 +719,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBInt64Int32Dictionary *dict =
- [[GPBInt64Int32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64Int32Dictionary alloc] initWithInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:21LL]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:22LL]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:23LL]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:24LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:24LL]);
XCTAssertEqual(value, 203);
- [dict setValue:203 forKey:21LL];
+ [dict setInt32:203 forKey:21LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:21LL]);
XCTAssertEqual(value, 203);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:22LL]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:23LL]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:24LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:24LL]);
XCTAssertEqual(value, 203);
- [dict setValue:201 forKey:24LL];
+ [dict setInt32:201 forKey:24LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:21LL]);
XCTAssertEqual(value, 203);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:22LL]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:23LL]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:24LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:24LL]);
XCTAssertEqual(value, 201);
const int64_t kKeys2[] = { 22LL, 23LL };
const int32_t kValues2[] = { 202, 200 };
GPBInt64Int32Dictionary *dict2 =
- [[GPBInt64Int32Dictionary alloc] initWithValues:kValues2
+ [[GPBInt64Int32Dictionary alloc] initWithInt32s:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:21LL]);
XCTAssertEqual(value, 203);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:22LL]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:23LL]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:24LL]);
+ XCTAssertTrue([dict getInt32:&value forKey:24LL]);
XCTAssertEqual(value, 201);
[dict2 release];
@@ -808,8 +807,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBInt64UInt64Dictionary *dict = [[GPBInt64UInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, uint64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt64:NULL forKey:21LL]);
+ [dict enumerateKeysAndUInt64sUsingBlock:^(int64_t aKey, uint64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -817,46 +816,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt64UInt64Dictionary *dict = [GPBInt64UInt64Dictionary dictionaryWithValue:300U forKey:21LL];
+ GPBInt64UInt64Dictionary *dict = [[GPBInt64UInt64Dictionary alloc] init];
+ [dict setUInt64:300U forKey:21LL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:21LL]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, uint64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt64:NULL forKey:22LL]);
+ [dict enumerateKeysAndUInt64sUsingBlock:^(int64_t aKey, uint64_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 21LL);
XCTAssertEqual(aValue, 300U);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int64_t kKeys[] = { 21LL, 22LL, 23LL };
const uint64_t kValues[] = { 300U, 301U, 302U };
GPBInt64UInt64Dictionary *dict =
- [[GPBInt64UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:21LL]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:22LL]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:23LL]);
XCTAssertEqual(value, 302U);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:24LL]);
__block NSUInteger idx = 0;
int64_t *seenKeys = malloc(3 * sizeof(int64_t));
uint64_t *seenValues = malloc(3 * sizeof(uint64_t));
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, uint64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt64sUsingBlock:^(int64_t aKey, uint64_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -878,7 +879,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, uint64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt64sUsingBlock:^(int64_t aKey, uint64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -894,29 +895,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kValues2[] = { 300U, 303U, 302U };
const uint64_t kValues3[] = { 300U, 301U, 302U, 303U };
GPBInt64UInt64Dictionary *dict1 =
- [[GPBInt64UInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt64UInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBInt64UInt64Dictionary *dict1prime =
- [[GPBInt64UInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt64UInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBInt64UInt64Dictionary *dict2 =
- [[GPBInt64UInt64Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt64UInt64Dictionary alloc] initWithUInt64s:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBInt64UInt64Dictionary *dict3 =
- [[GPBInt64UInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt64UInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBInt64UInt64Dictionary *dict4 =
- [[GPBInt64UInt64Dictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBInt64UInt64Dictionary alloc] initWithUInt64s:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -945,9 +946,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBInt64UInt64Dictionary *dict =
- [[GPBInt64UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt64UInt64Dictionary *dict2 = [dict copy];
@@ -966,110 +967,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBInt64UInt64Dictionary *dict =
- [[GPBInt64UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt64UInt64Dictionary *dict2 =
- [GPBInt64UInt64Dictionary dictionaryWithDictionary:dict];
+ [[GPBInt64UInt64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt64UInt64Dictionary *dict = [GPBInt64UInt64Dictionary dictionary];
+ GPBInt64UInt64Dictionary *dict = [[GPBInt64UInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:300U forKey:21LL];
+ [dict setUInt64:300U forKey:21LL];
XCTAssertEqual(dict.count, 1U);
const int64_t kKeys[] = { 22LL, 23LL, 24LL };
const uint64_t kValues[] = { 301U, 302U, 303U };
GPBInt64UInt64Dictionary *dict2 =
- [[GPBInt64UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:21LL]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:22LL]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:23LL]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:24LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:24LL]);
XCTAssertEqual(value, 303U);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBInt64UInt64Dictionary *dict =
- [[GPBInt64UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:22LL];
+ [dict removeUInt64ForKey:22LL];
XCTAssertEqual(dict.count, 3U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:21LL]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:23LL]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:24LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:24LL]);
XCTAssertEqual(value, 303U);
// Remove again does nothing.
- [dict removeValueForKey:22LL];
+ [dict removeUInt64ForKey:22LL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:21LL]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:23LL]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:24LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:24LL]);
XCTAssertEqual(value, 303U);
- [dict removeValueForKey:24LL];
+ [dict removeUInt64ForKey:24LL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:21LL]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:23LL]);
XCTAssertEqual(value, 302U);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:24LL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertFalse([dict valueForKey:23LL value:NULL]);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:21LL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:22LL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:23LL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:24LL]);
[dict release];
}
@@ -1077,75 +1080,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBInt64UInt64Dictionary *dict =
- [[GPBInt64UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:21LL]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:22LL]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:23LL]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:24LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:24LL]);
XCTAssertEqual(value, 303U);
- [dict setValue:303U forKey:21LL];
+ [dict setUInt64:303U forKey:21LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:21LL]);
XCTAssertEqual(value, 303U);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:22LL]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:23LL]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:24LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:24LL]);
XCTAssertEqual(value, 303U);
- [dict setValue:301U forKey:24LL];
+ [dict setUInt64:301U forKey:24LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:21LL]);
XCTAssertEqual(value, 303U);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:22LL]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:23LL]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:24LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:24LL]);
XCTAssertEqual(value, 301U);
const int64_t kKeys2[] = { 22LL, 23LL };
const uint64_t kValues2[] = { 302U, 300U };
GPBInt64UInt64Dictionary *dict2 =
- [[GPBInt64UInt64Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt64UInt64Dictionary alloc] initWithUInt64s:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:21LL]);
XCTAssertEqual(value, 303U);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:22LL]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:23LL]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:24LL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:24LL]);
XCTAssertEqual(value, 301U);
[dict2 release];
@@ -1165,8 +1168,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBInt64Int64Dictionary *dict = [[GPBInt64Int64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, int64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt64:NULL forKey:21LL]);
+ [dict enumerateKeysAndInt64sUsingBlock:^(int64_t aKey, int64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1174,46 +1177,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt64Int64Dictionary *dict = [GPBInt64Int64Dictionary dictionaryWithValue:400 forKey:21LL];
+ GPBInt64Int64Dictionary *dict = [[GPBInt64Int64Dictionary alloc] init];
+ [dict setInt64:400 forKey:21LL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int64_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:21LL]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, int64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt64:NULL forKey:22LL]);
+ [dict enumerateKeysAndInt64sUsingBlock:^(int64_t aKey, int64_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 21LL);
XCTAssertEqual(aValue, 400);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int64_t kKeys[] = { 21LL, 22LL, 23LL };
const int64_t kValues[] = { 400, 401, 402 };
GPBInt64Int64Dictionary *dict =
- [[GPBInt64Int64Dictionary alloc] initWithValues:kValues
+ [[GPBInt64Int64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
int64_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:21LL]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:22LL]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:23LL]);
XCTAssertEqual(value, 402);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:24LL]);
__block NSUInteger idx = 0;
int64_t *seenKeys = malloc(3 * sizeof(int64_t));
int64_t *seenValues = malloc(3 * sizeof(int64_t));
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, int64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt64sUsingBlock:^(int64_t aKey, int64_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1235,7 +1240,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, int64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt64sUsingBlock:^(int64_t aKey, int64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1251,27 +1256,27 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kValues2[] = { 400, 403, 402 };
const int64_t kValues3[] = { 400, 401, 402, 403 };
GPBInt64Int64Dictionary *dict1 =
- [[GPBInt64Int64Dictionary alloc] initWithValues:kValues1
+ [[GPBInt64Int64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBInt64Int64Dictionary *dict1prime =
- [[GPBInt64Int64Dictionary alloc] initWithValues:kValues1
+ [[GPBInt64Int64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBInt64Int64Dictionary *dict2 =
- [[GPBInt64Int64Dictionary alloc] initWithValues:kValues2
+ [[GPBInt64Int64Dictionary alloc] initWithInt64s:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBInt64Int64Dictionary *dict3 =
- [[GPBInt64Int64Dictionary alloc] initWithValues:kValues1
+ [[GPBInt64Int64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBInt64Int64Dictionary *dict4 =
- [[GPBInt64Int64Dictionary alloc] initWithValues:kValues3
+ [[GPBInt64Int64Dictionary alloc] initWithInt64s:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -1302,7 +1307,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBInt64Int64Dictionary *dict =
- [[GPBInt64Int64Dictionary alloc] initWithValues:kValues
+ [[GPBInt64Int64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -1323,33 +1328,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBInt64Int64Dictionary *dict =
- [[GPBInt64Int64Dictionary alloc] initWithValues:kValues
+ [[GPBInt64Int64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt64Int64Dictionary *dict2 =
- [GPBInt64Int64Dictionary dictionaryWithDictionary:dict];
+ [[GPBInt64Int64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt64Int64Dictionary *dict = [GPBInt64Int64Dictionary dictionary];
+ GPBInt64Int64Dictionary *dict = [[GPBInt64Int64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:400 forKey:21LL];
+ [dict setInt64:400 forKey:21LL];
XCTAssertEqual(dict.count, 1U);
const int64_t kKeys[] = { 22LL, 23LL, 24LL };
const int64_t kValues[] = { 401, 402, 403 };
GPBInt64Int64Dictionary *dict2 =
- [[GPBInt64Int64Dictionary alloc] initWithValues:kValues
+ [[GPBInt64Int64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -1357,76 +1363,77 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 4U);
int64_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:21LL]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:22LL]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:23LL]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:24LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:24LL]);
XCTAssertEqual(value, 403);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBInt64Int64Dictionary *dict =
- [[GPBInt64Int64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64Int64Dictionary alloc] initWithInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:22LL];
+ [dict removeInt64ForKey:22LL];
XCTAssertEqual(dict.count, 3U);
int64_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:21LL]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:23LL]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:24LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:24LL]);
XCTAssertEqual(value, 403);
// Remove again does nothing.
- [dict removeValueForKey:22LL];
+ [dict removeInt64ForKey:22LL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:21LL]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:23LL]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:24LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:24LL]);
XCTAssertEqual(value, 403);
- [dict removeValueForKey:24LL];
+ [dict removeInt64ForKey:24LL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:21LL]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:23LL]);
XCTAssertEqual(value, 402);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:24LL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertFalse([dict valueForKey:23LL value:NULL]);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:21LL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:22LL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:23LL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:24LL]);
[dict release];
}
@@ -1434,75 +1441,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBInt64Int64Dictionary *dict =
- [[GPBInt64Int64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64Int64Dictionary alloc] initWithInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int64_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:21LL]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:22LL]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:23LL]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:24LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:24LL]);
XCTAssertEqual(value, 403);
- [dict setValue:403 forKey:21LL];
+ [dict setInt64:403 forKey:21LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:21LL]);
XCTAssertEqual(value, 403);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:22LL]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:23LL]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:24LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:24LL]);
XCTAssertEqual(value, 403);
- [dict setValue:401 forKey:24LL];
+ [dict setInt64:401 forKey:24LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:21LL]);
XCTAssertEqual(value, 403);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:22LL]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:23LL]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:24LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:24LL]);
XCTAssertEqual(value, 401);
const int64_t kKeys2[] = { 22LL, 23LL };
const int64_t kValues2[] = { 402, 400 };
GPBInt64Int64Dictionary *dict2 =
- [[GPBInt64Int64Dictionary alloc] initWithValues:kValues2
+ [[GPBInt64Int64Dictionary alloc] initWithInt64s:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:21LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:21LL]);
XCTAssertEqual(value, 403);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:22LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:22LL]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:23LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:23LL]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:24LL]);
+ XCTAssertTrue([dict getInt64:&value forKey:24LL]);
XCTAssertEqual(value, 401);
[dict2 release];
@@ -1522,8 +1529,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBInt64BoolDictionary *dict = [[GPBInt64BoolDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, BOOL aValue, BOOL *stop) {
+ XCTAssertFalse([dict getBool:NULL forKey:21LL]);
+ [dict enumerateKeysAndBoolsUsingBlock:^(int64_t aKey, BOOL aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1531,46 +1538,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt64BoolDictionary *dict = [GPBInt64BoolDictionary dictionaryWithValue:YES forKey:21LL];
+ GPBInt64BoolDictionary *dict = [[GPBInt64BoolDictionary alloc] init];
+ [dict setBool:YES forKey:21LL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
BOOL value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:21LL]);
+ XCTAssertTrue([dict getBool:&value forKey:21LL]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, BOOL aValue, BOOL *stop) {
+ XCTAssertFalse([dict getBool:NULL forKey:22LL]);
+ [dict enumerateKeysAndBoolsUsingBlock:^(int64_t aKey, BOOL aValue, BOOL *stop) {
XCTAssertEqual(aKey, 21LL);
XCTAssertEqual(aValue, YES);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int64_t kKeys[] = { 21LL, 22LL, 23LL };
const BOOL kValues[] = { YES, YES, NO };
GPBInt64BoolDictionary *dict =
- [[GPBInt64BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
BOOL value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:21LL]);
+ XCTAssertTrue([dict getBool:&value forKey:21LL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:22LL]);
+ XCTAssertTrue([dict getBool:&value forKey:22LL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:23LL]);
+ XCTAssertTrue([dict getBool:&value forKey:23LL]);
XCTAssertEqual(value, NO);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:24LL]);
__block NSUInteger idx = 0;
int64_t *seenKeys = malloc(3 * sizeof(int64_t));
BOOL *seenValues = malloc(3 * sizeof(BOOL));
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, BOOL aValue, BOOL *stop) {
+ [dict enumerateKeysAndBoolsUsingBlock:^(int64_t aKey, BOOL aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1592,7 +1601,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, BOOL aValue, BOOL *stop) {
+ [dict enumerateKeysAndBoolsUsingBlock:^(int64_t aKey, BOOL aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1608,29 +1617,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const BOOL kValues2[] = { YES, NO, NO };
const BOOL kValues3[] = { YES, YES, NO, NO };
GPBInt64BoolDictionary *dict1 =
- [[GPBInt64BoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt64BoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBInt64BoolDictionary *dict1prime =
- [[GPBInt64BoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt64BoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBInt64BoolDictionary *dict2 =
- [[GPBInt64BoolDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt64BoolDictionary alloc] initWithBools:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBInt64BoolDictionary *dict3 =
- [[GPBInt64BoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt64BoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBInt64BoolDictionary *dict4 =
- [[GPBInt64BoolDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBInt64BoolDictionary alloc] initWithBools:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -1659,9 +1668,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBInt64BoolDictionary *dict =
- [[GPBInt64BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt64BoolDictionary *dict2 = [dict copy];
@@ -1680,110 +1689,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBInt64BoolDictionary *dict =
- [[GPBInt64BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt64BoolDictionary *dict2 =
- [GPBInt64BoolDictionary dictionaryWithDictionary:dict];
+ [[GPBInt64BoolDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt64BoolDictionary *dict = [GPBInt64BoolDictionary dictionary];
+ GPBInt64BoolDictionary *dict = [[GPBInt64BoolDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:YES forKey:21LL];
+ [dict setBool:YES forKey:21LL];
XCTAssertEqual(dict.count, 1U);
const int64_t kKeys[] = { 22LL, 23LL, 24LL };
const BOOL kValues[] = { YES, NO, NO };
GPBInt64BoolDictionary *dict2 =
- [[GPBInt64BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
BOOL value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:21LL]);
+ XCTAssertTrue([dict getBool:&value forKey:21LL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:22LL]);
+ XCTAssertTrue([dict getBool:&value forKey:22LL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:23LL]);
+ XCTAssertTrue([dict getBool:&value forKey:23LL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:24LL]);
+ XCTAssertTrue([dict getBool:&value forKey:24LL]);
XCTAssertEqual(value, NO);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBInt64BoolDictionary *dict =
- [[GPBInt64BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:22LL];
+ [dict removeBoolForKey:22LL];
XCTAssertEqual(dict.count, 3U);
BOOL value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:21LL]);
+ XCTAssertTrue([dict getBool:&value forKey:21LL]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getBool:NULL forKey:22LL]);
+ XCTAssertTrue([dict getBool:NULL forKey:23LL]);
+ XCTAssertTrue([dict getBool:&value forKey:23LL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:24LL]);
+ XCTAssertTrue([dict getBool:&value forKey:24LL]);
XCTAssertEqual(value, NO);
// Remove again does nothing.
- [dict removeValueForKey:22LL];
+ [dict removeBoolForKey:22LL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:21LL]);
+ XCTAssertTrue([dict getBool:&value forKey:21LL]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getBool:NULL forKey:22LL]);
+ XCTAssertTrue([dict getBool:NULL forKey:23LL]);
+ XCTAssertTrue([dict getBool:&value forKey:23LL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:24LL]);
+ XCTAssertTrue([dict getBool:&value forKey:24LL]);
XCTAssertEqual(value, NO);
- [dict removeValueForKey:24LL];
+ [dict removeBoolForKey:24LL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:21LL]);
+ XCTAssertTrue([dict getBool:&value forKey:21LL]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getBool:NULL forKey:22LL]);
+ XCTAssertTrue([dict getBool:NULL forKey:23LL]);
+ XCTAssertTrue([dict getBool:&value forKey:23LL]);
XCTAssertEqual(value, NO);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:24LL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertFalse([dict valueForKey:23LL value:NULL]);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:21LL]);
+ XCTAssertFalse([dict getBool:NULL forKey:22LL]);
+ XCTAssertFalse([dict getBool:NULL forKey:23LL]);
+ XCTAssertFalse([dict getBool:NULL forKey:24LL]);
[dict release];
}
@@ -1791,75 +1802,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBInt64BoolDictionary *dict =
- [[GPBInt64BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
BOOL value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:21LL]);
+ XCTAssertTrue([dict getBool:&value forKey:21LL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:22LL]);
+ XCTAssertTrue([dict getBool:&value forKey:22LL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:23LL]);
+ XCTAssertTrue([dict getBool:&value forKey:23LL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:24LL]);
+ XCTAssertTrue([dict getBool:&value forKey:24LL]);
XCTAssertEqual(value, NO);
- [dict setValue:NO forKey:21LL];
+ [dict setBool:NO forKey:21LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:21LL]);
+ XCTAssertTrue([dict getBool:&value forKey:21LL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:22LL]);
+ XCTAssertTrue([dict getBool:&value forKey:22LL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:23LL]);
+ XCTAssertTrue([dict getBool:&value forKey:23LL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:24LL]);
+ XCTAssertTrue([dict getBool:&value forKey:24LL]);
XCTAssertEqual(value, NO);
- [dict setValue:YES forKey:24LL];
+ [dict setBool:YES forKey:24LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:21LL]);
+ XCTAssertTrue([dict getBool:&value forKey:21LL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:22LL]);
+ XCTAssertTrue([dict getBool:&value forKey:22LL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:23LL]);
+ XCTAssertTrue([dict getBool:&value forKey:23LL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:24LL]);
+ XCTAssertTrue([dict getBool:&value forKey:24LL]);
XCTAssertEqual(value, YES);
const int64_t kKeys2[] = { 22LL, 23LL };
const BOOL kValues2[] = { NO, YES };
GPBInt64BoolDictionary *dict2 =
- [[GPBInt64BoolDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt64BoolDictionary alloc] initWithBools:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:21LL]);
+ XCTAssertTrue([dict getBool:&value forKey:21LL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:22LL]);
+ XCTAssertTrue([dict getBool:&value forKey:22LL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:23LL]);
+ XCTAssertTrue([dict getBool:&value forKey:23LL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:24LL]);
+ XCTAssertTrue([dict getBool:&value forKey:24LL]);
XCTAssertEqual(value, YES);
[dict2 release];
@@ -1879,8 +1890,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBInt64FloatDictionary *dict = [[GPBInt64FloatDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, float aValue, BOOL *stop) {
+ XCTAssertFalse([dict getFloat:NULL forKey:21LL]);
+ [dict enumerateKeysAndFloatsUsingBlock:^(int64_t aKey, float aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1888,46 +1899,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt64FloatDictionary *dict = [GPBInt64FloatDictionary dictionaryWithValue:500.f forKey:21LL];
+ GPBInt64FloatDictionary *dict = [[GPBInt64FloatDictionary alloc] init];
+ [dict setFloat:500.f forKey:21LL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
float value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:21LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:21LL]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, float aValue, BOOL *stop) {
+ XCTAssertFalse([dict getFloat:NULL forKey:22LL]);
+ [dict enumerateKeysAndFloatsUsingBlock:^(int64_t aKey, float aValue, BOOL *stop) {
XCTAssertEqual(aKey, 21LL);
XCTAssertEqual(aValue, 500.f);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int64_t kKeys[] = { 21LL, 22LL, 23LL };
const float kValues[] = { 500.f, 501.f, 502.f };
GPBInt64FloatDictionary *dict =
- [[GPBInt64FloatDictionary alloc] initWithValues:kValues
+ [[GPBInt64FloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
float value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:21LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:21LL]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:22LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:22LL]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:23LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:23LL]);
XCTAssertEqual(value, 502.f);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:24LL]);
__block NSUInteger idx = 0;
int64_t *seenKeys = malloc(3 * sizeof(int64_t));
float *seenValues = malloc(3 * sizeof(float));
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, float aValue, BOOL *stop) {
+ [dict enumerateKeysAndFloatsUsingBlock:^(int64_t aKey, float aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1949,7 +1962,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, float aValue, BOOL *stop) {
+ [dict enumerateKeysAndFloatsUsingBlock:^(int64_t aKey, float aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1965,27 +1978,27 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const float kValues2[] = { 500.f, 503.f, 502.f };
const float kValues3[] = { 500.f, 501.f, 502.f, 503.f };
GPBInt64FloatDictionary *dict1 =
- [[GPBInt64FloatDictionary alloc] initWithValues:kValues1
+ [[GPBInt64FloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBInt64FloatDictionary *dict1prime =
- [[GPBInt64FloatDictionary alloc] initWithValues:kValues1
+ [[GPBInt64FloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBInt64FloatDictionary *dict2 =
- [[GPBInt64FloatDictionary alloc] initWithValues:kValues2
+ [[GPBInt64FloatDictionary alloc] initWithFloats:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBInt64FloatDictionary *dict3 =
- [[GPBInt64FloatDictionary alloc] initWithValues:kValues1
+ [[GPBInt64FloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBInt64FloatDictionary *dict4 =
- [[GPBInt64FloatDictionary alloc] initWithValues:kValues3
+ [[GPBInt64FloatDictionary alloc] initWithFloats:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -2016,7 +2029,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBInt64FloatDictionary *dict =
- [[GPBInt64FloatDictionary alloc] initWithValues:kValues
+ [[GPBInt64FloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -2037,33 +2050,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBInt64FloatDictionary *dict =
- [[GPBInt64FloatDictionary alloc] initWithValues:kValues
+ [[GPBInt64FloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt64FloatDictionary *dict2 =
- [GPBInt64FloatDictionary dictionaryWithDictionary:dict];
+ [[GPBInt64FloatDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt64FloatDictionary *dict = [GPBInt64FloatDictionary dictionary];
+ GPBInt64FloatDictionary *dict = [[GPBInt64FloatDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:500.f forKey:21LL];
+ [dict setFloat:500.f forKey:21LL];
XCTAssertEqual(dict.count, 1U);
const int64_t kKeys[] = { 22LL, 23LL, 24LL };
const float kValues[] = { 501.f, 502.f, 503.f };
GPBInt64FloatDictionary *dict2 =
- [[GPBInt64FloatDictionary alloc] initWithValues:kValues
+ [[GPBInt64FloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -2071,76 +2085,77 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 4U);
float value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:21LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:21LL]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:22LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:22LL]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:23LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:23LL]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:24LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:24LL]);
XCTAssertEqual(value, 503.f);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBInt64FloatDictionary *dict =
- [[GPBInt64FloatDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64FloatDictionary alloc] initWithFloats:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:22LL];
+ [dict removeFloatForKey:22LL];
XCTAssertEqual(dict.count, 3U);
float value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:21LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:21LL]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getFloat:NULL forKey:22LL]);
+ XCTAssertTrue([dict getFloat:NULL forKey:23LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:23LL]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:24LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:24LL]);
XCTAssertEqual(value, 503.f);
// Remove again does nothing.
- [dict removeValueForKey:22LL];
+ [dict removeFloatForKey:22LL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:21LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:21LL]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getFloat:NULL forKey:22LL]);
+ XCTAssertTrue([dict getFloat:NULL forKey:23LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:23LL]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:24LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:24LL]);
XCTAssertEqual(value, 503.f);
- [dict removeValueForKey:24LL];
+ [dict removeFloatForKey:24LL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:21LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:21LL]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getFloat:NULL forKey:22LL]);
+ XCTAssertTrue([dict getFloat:NULL forKey:23LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:23LL]);
XCTAssertEqual(value, 502.f);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:24LL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertFalse([dict valueForKey:23LL value:NULL]);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:21LL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:22LL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:23LL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:24LL]);
[dict release];
}
@@ -2148,75 +2163,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBInt64FloatDictionary *dict =
- [[GPBInt64FloatDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64FloatDictionary alloc] initWithFloats:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
float value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:21LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:21LL]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:22LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:22LL]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:23LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:23LL]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:24LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:24LL]);
XCTAssertEqual(value, 503.f);
- [dict setValue:503.f forKey:21LL];
+ [dict setFloat:503.f forKey:21LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:21LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:21LL]);
XCTAssertEqual(value, 503.f);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:22LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:22LL]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:23LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:23LL]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:24LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:24LL]);
XCTAssertEqual(value, 503.f);
- [dict setValue:501.f forKey:24LL];
+ [dict setFloat:501.f forKey:24LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:21LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:21LL]);
XCTAssertEqual(value, 503.f);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:22LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:22LL]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:23LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:23LL]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:24LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:24LL]);
XCTAssertEqual(value, 501.f);
const int64_t kKeys2[] = { 22LL, 23LL };
const float kValues2[] = { 502.f, 500.f };
GPBInt64FloatDictionary *dict2 =
- [[GPBInt64FloatDictionary alloc] initWithValues:kValues2
+ [[GPBInt64FloatDictionary alloc] initWithFloats:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:21LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:21LL]);
XCTAssertEqual(value, 503.f);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:22LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:22LL]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:23LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:23LL]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:24LL]);
+ XCTAssertTrue([dict getFloat:&value forKey:24LL]);
XCTAssertEqual(value, 501.f);
[dict2 release];
@@ -2236,8 +2251,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBInt64DoubleDictionary *dict = [[GPBInt64DoubleDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, double aValue, BOOL *stop) {
+ XCTAssertFalse([dict getDouble:NULL forKey:21LL]);
+ [dict enumerateKeysAndDoublesUsingBlock:^(int64_t aKey, double aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -2245,46 +2260,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt64DoubleDictionary *dict = [GPBInt64DoubleDictionary dictionaryWithValue:600. forKey:21LL];
+ GPBInt64DoubleDictionary *dict = [[GPBInt64DoubleDictionary alloc] init];
+ [dict setDouble:600. forKey:21LL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
double value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:21LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:21LL]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, double aValue, BOOL *stop) {
+ XCTAssertFalse([dict getDouble:NULL forKey:22LL]);
+ [dict enumerateKeysAndDoublesUsingBlock:^(int64_t aKey, double aValue, BOOL *stop) {
XCTAssertEqual(aKey, 21LL);
XCTAssertEqual(aValue, 600.);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int64_t kKeys[] = { 21LL, 22LL, 23LL };
const double kValues[] = { 600., 601., 602. };
GPBInt64DoubleDictionary *dict =
- [[GPBInt64DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
double value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:21LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:21LL]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:22LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:22LL]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:23LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:23LL]);
XCTAssertEqual(value, 602.);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:24LL]);
__block NSUInteger idx = 0;
int64_t *seenKeys = malloc(3 * sizeof(int64_t));
double *seenValues = malloc(3 * sizeof(double));
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, double aValue, BOOL *stop) {
+ [dict enumerateKeysAndDoublesUsingBlock:^(int64_t aKey, double aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -2306,7 +2323,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, double aValue, BOOL *stop) {
+ [dict enumerateKeysAndDoublesUsingBlock:^(int64_t aKey, double aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -2322,29 +2339,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const double kValues2[] = { 600., 603., 602. };
const double kValues3[] = { 600., 601., 602., 603. };
GPBInt64DoubleDictionary *dict1 =
- [[GPBInt64DoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt64DoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBInt64DoubleDictionary *dict1prime =
- [[GPBInt64DoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt64DoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBInt64DoubleDictionary *dict2 =
- [[GPBInt64DoubleDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt64DoubleDictionary alloc] initWithDoubles:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBInt64DoubleDictionary *dict3 =
- [[GPBInt64DoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt64DoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBInt64DoubleDictionary *dict4 =
- [[GPBInt64DoubleDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBInt64DoubleDictionary alloc] initWithDoubles:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -2373,9 +2390,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const double kValues[] = { 600., 601., 602., 603. };
GPBInt64DoubleDictionary *dict =
- [[GPBInt64DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt64DoubleDictionary *dict2 = [dict copy];
@@ -2394,110 +2411,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const double kValues[] = { 600., 601., 602., 603. };
GPBInt64DoubleDictionary *dict =
- [[GPBInt64DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt64DoubleDictionary *dict2 =
- [GPBInt64DoubleDictionary dictionaryWithDictionary:dict];
+ [[GPBInt64DoubleDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt64DoubleDictionary *dict = [GPBInt64DoubleDictionary dictionary];
+ GPBInt64DoubleDictionary *dict = [[GPBInt64DoubleDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:600. forKey:21LL];
+ [dict setDouble:600. forKey:21LL];
XCTAssertEqual(dict.count, 1U);
const int64_t kKeys[] = { 22LL, 23LL, 24LL };
const double kValues[] = { 601., 602., 603. };
GPBInt64DoubleDictionary *dict2 =
- [[GPBInt64DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
double value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:21LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:21LL]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:22LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:22LL]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:23LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:23LL]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:24LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:24LL]);
XCTAssertEqual(value, 603.);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const double kValues[] = { 600., 601., 602., 603. };
GPBInt64DoubleDictionary *dict =
- [[GPBInt64DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:22LL];
+ [dict removeDoubleForKey:22LL];
XCTAssertEqual(dict.count, 3U);
double value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:21LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:21LL]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getDouble:NULL forKey:22LL]);
+ XCTAssertTrue([dict getDouble:NULL forKey:23LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:23LL]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:24LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:24LL]);
XCTAssertEqual(value, 603.);
// Remove again does nothing.
- [dict removeValueForKey:22LL];
+ [dict removeDoubleForKey:22LL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:21LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:21LL]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getDouble:NULL forKey:22LL]);
+ XCTAssertTrue([dict getDouble:NULL forKey:23LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:23LL]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:24LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:24LL]);
XCTAssertEqual(value, 603.);
- [dict removeValueForKey:24LL];
+ [dict removeDoubleForKey:24LL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:21LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:21LL]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getDouble:NULL forKey:22LL]);
+ XCTAssertTrue([dict getDouble:NULL forKey:23LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:23LL]);
XCTAssertEqual(value, 602.);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:24LL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertFalse([dict valueForKey:23LL value:NULL]);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:21LL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:22LL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:23LL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:24LL]);
[dict release];
}
@@ -2505,75 +2524,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const double kValues[] = { 600., 601., 602., 603. };
GPBInt64DoubleDictionary *dict =
- [[GPBInt64DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
double value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:21LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:21LL]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:22LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:22LL]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:23LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:23LL]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:24LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:24LL]);
XCTAssertEqual(value, 603.);
- [dict setValue:603. forKey:21LL];
+ [dict setDouble:603. forKey:21LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:21LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:21LL]);
XCTAssertEqual(value, 603.);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:22LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:22LL]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:23LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:23LL]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:24LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:24LL]);
XCTAssertEqual(value, 603.);
- [dict setValue:601. forKey:24LL];
+ [dict setDouble:601. forKey:24LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:21LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:21LL]);
XCTAssertEqual(value, 603.);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:22LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:22LL]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:23LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:23LL]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:24LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:24LL]);
XCTAssertEqual(value, 601.);
const int64_t kKeys2[] = { 22LL, 23LL };
const double kValues2[] = { 602., 600. };
GPBInt64DoubleDictionary *dict2 =
- [[GPBInt64DoubleDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt64DoubleDictionary alloc] initWithDoubles:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:21LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:21LL]);
XCTAssertEqual(value, 603.);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:22LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:22LL]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:23LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:23LL]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:24LL]);
+ XCTAssertTrue([dict getDouble:&value forKey:24LL]);
XCTAssertEqual(value, 601.);
[dict2 release];
@@ -2593,8 +2612,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBInt64EnumDictionary *dict = [[GPBInt64EnumDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getEnum:NULL forKey:21LL]);
+ [dict enumerateKeysAndEnumsUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -2602,46 +2621,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt64EnumDictionary *dict = [GPBInt64EnumDictionary dictionaryWithValue:700 forKey:21LL];
+ GPBInt64EnumDictionary *dict = [[GPBInt64EnumDictionary alloc] init];
+ [dict setEnum:700 forKey:21LL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:21LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:21LL]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getEnum:NULL forKey:22LL]);
+ [dict enumerateKeysAndEnumsUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 21LL);
XCTAssertEqual(aValue, 700);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int64_t kKeys[] = { 21LL, 22LL, 23LL };
const int32_t kValues[] = { 700, 701, 702 };
GPBInt64EnumDictionary *dict =
- [[GPBInt64EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:21LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:21LL]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:22LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:22LL]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:24LL]);
__block NSUInteger idx = 0;
int64_t *seenKeys = malloc(3 * sizeof(int64_t));
int32_t *seenValues = malloc(3 * sizeof(int32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndEnumsUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -2663,7 +2684,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndEnumsUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -2679,29 +2700,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kValues2[] = { 700, 703, 702 };
const int32_t kValues3[] = { 700, 701, 702, 703 };
GPBInt64EnumDictionary *dict1 =
- [[GPBInt64EnumDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt64EnumDictionary alloc] initWithEnums:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBInt64EnumDictionary *dict1prime =
- [[GPBInt64EnumDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt64EnumDictionary alloc] initWithEnums:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBInt64EnumDictionary *dict2 =
- [[GPBInt64EnumDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt64EnumDictionary alloc] initWithEnums:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBInt64EnumDictionary *dict3 =
- [[GPBInt64EnumDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBInt64EnumDictionary alloc] initWithEnums:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBInt64EnumDictionary *dict4 =
- [[GPBInt64EnumDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBInt64EnumDictionary alloc] initWithEnums:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -2730,9 +2751,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBInt64EnumDictionary *dict =
- [[GPBInt64EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt64EnumDictionary *dict2 = [dict copy];
@@ -2751,110 +2772,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBInt64EnumDictionary *dict =
- [[GPBInt64EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBInt64EnumDictionary *dict2 =
- [GPBInt64EnumDictionary dictionaryWithDictionary:dict];
+ [[GPBInt64EnumDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt64EnumDictionary *dict = [GPBInt64EnumDictionary dictionary];
+ GPBInt64EnumDictionary *dict = [[GPBInt64EnumDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:700 forKey:21LL];
+ [dict setEnum:700 forKey:21LL];
XCTAssertEqual(dict.count, 1U);
const int64_t kKeys[] = { 22LL, 23LL, 24LL };
const int32_t kValues[] = { 701, 702, 703 };
GPBInt64EnumDictionary *dict2 =
- [[GPBInt64EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:21LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:21LL]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:22LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:22LL]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:24LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:24LL]);
XCTAssertEqual(value, 703);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBInt64EnumDictionary *dict =
- [[GPBInt64EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:22LL];
+ [dict removeEnumForKey:22LL];
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:21LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:21LL]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:22LL]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:24LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:24LL]);
XCTAssertEqual(value, 703);
// Remove again does nothing.
- [dict removeValueForKey:22LL];
+ [dict removeEnumForKey:22LL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:21LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:21LL]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:22LL]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:24LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:24LL]);
XCTAssertEqual(value, 703);
- [dict removeValueForKey:24LL];
+ [dict removeEnumForKey:24LL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:21LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:21LL]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:22LL]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:24LL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertFalse([dict valueForKey:23LL value:NULL]);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:21LL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:22LL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:23LL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:24LL]);
[dict release];
}
@@ -2862,75 +2885,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBInt64EnumDictionary *dict =
- [[GPBInt64EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:21LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:21LL]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:22LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:22LL]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:24LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:24LL]);
XCTAssertEqual(value, 703);
- [dict setValue:703 forKey:21LL];
+ [dict setEnum:703 forKey:21LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:21LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:21LL]);
XCTAssertEqual(value, 703);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:22LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:22LL]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:24LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:24LL]);
XCTAssertEqual(value, 703);
- [dict setValue:701 forKey:24LL];
+ [dict setEnum:701 forKey:24LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:21LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:21LL]);
XCTAssertEqual(value, 703);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:22LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:22LL]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:24LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:24LL]);
XCTAssertEqual(value, 701);
const int64_t kKeys2[] = { 22LL, 23LL };
const int32_t kValues2[] = { 702, 700 };
GPBInt64EnumDictionary *dict2 =
- [[GPBInt64EnumDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBInt64EnumDictionary alloc] initWithEnums:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:21LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:21LL]);
XCTAssertEqual(value, 703);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:22LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:22LL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:24LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:24LL]);
XCTAssertEqual(value, 701);
[dict2 release];
@@ -2958,24 +2981,24 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 3U);
XCTAssertTrue(dict.validationFunc == TestingEnum_IsValidValue); // Pointer comparison
int32_t value;
- XCTAssertTrue([dict valueForKey:21LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:21LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:21LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:21LL]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:22LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:22LL]);
XCTAssertEqual(value, kGPBUnrecognizedEnumeratorValue);
- XCTAssertTrue([dict valueForKey:22LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:22LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:22LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:22LL]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:23LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:23LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:23LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:24LL rawValue:NULL]);
+ XCTAssertFalse([dict getRawValue:NULL forKey:24LL]);
__block NSUInteger idx = 0;
int64_t *seenKeys = malloc(3 * sizeof(int64_t));
int32_t *seenValues = malloc(3 * sizeof(int32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndEnumsUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -3120,23 +3143,24 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBInt64EnumDictionary *dict2 =
- [GPBInt64EnumDictionary dictionaryWithDictionary:dict];
+ [[GPBInt64EnumDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
XCTAssertEqual(dict.validationFunc, dict2.validationFunc); // Pointer comparison
+ [dict2 release];
[dict release];
}
- (void)testUnknownAdds {
GPBInt64EnumDictionary *dict =
- [GPBInt64EnumDictionary dictionaryWithValidationFunction:TestingEnum_IsValidValue];
+ [[GPBInt64EnumDictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertThrowsSpecificNamed([dict setValue:801 forKey:22LL], // Unknown
+ XCTAssertThrowsSpecificNamed([dict setEnum:801 forKey:22LL], // Unknown
NSException, NSInvalidArgumentException);
XCTAssertEqual(dict.count, 0U);
[dict setRawValue:801 forKey:22LL]; // Unknown
@@ -3145,33 +3169,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kKeys[] = { 21LL, 23LL, 24LL };
const int32_t kValues[] = { 700, 702, 803 }; // Unknown
GPBInt64EnumDictionary *dict2 =
- [[GPBInt64EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBInt64EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:21LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:21LL]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:22LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:22LL]);
XCTAssertEqual(value, kGPBUnrecognizedEnumeratorValue);
- XCTAssertTrue([dict valueForKey:22LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:22LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:22LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:22LL]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:24LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:24LL]);
XCTAssertEqual(value, kGPBUnrecognizedEnumeratorValue);
- XCTAssertTrue([dict valueForKey:24LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:24LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:24LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:24LL]);
XCTAssertEqual(value, 803);
[dict2 release];
+ [dict release];
}
- (void)testUnknownRemove {
@@ -3185,51 +3210,51 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:22LL];
+ [dict removeEnumForKey:22LL];
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:21LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:21LL]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:22LL]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:24LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:24LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:24LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:24LL]);
XCTAssertEqual(value, 803);
// Remove again does nothing.
- [dict removeValueForKey:22LL];
+ [dict removeEnumForKey:22LL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:21LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:21LL]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:22LL]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:24LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:24LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:24LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:24LL]);
XCTAssertEqual(value, 803);
- [dict removeValueForKey:24LL];
+ [dict removeEnumForKey:24LL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:21LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:21LL]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:22LL]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:24LL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:21LL value:NULL]);
- XCTAssertFalse([dict valueForKey:22LL value:NULL]);
- XCTAssertFalse([dict valueForKey:23LL value:NULL]);
- XCTAssertFalse([dict valueForKey:24LL value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:21LL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:22LL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:23LL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:24LL]);
[dict release];
}
@@ -3244,63 +3269,63 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:21LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:21LL]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:22LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:22LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:22LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:22LL]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:24LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:24LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:24LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:24LL]);
XCTAssertEqual(value, 803);
- XCTAssertThrowsSpecificNamed([dict setValue:803 forKey:21LL], // Unknown
+ XCTAssertThrowsSpecificNamed([dict setEnum:803 forKey:21LL], // Unknown
NSException, NSInvalidArgumentException);
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL value:NULL]);
- XCTAssertTrue([dict valueForKey:21LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:21LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:21LL]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:22LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:22LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:22LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:22LL]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:24LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:24LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:24LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:24LL]);
XCTAssertEqual(value, 803);
[dict setRawValue:803 forKey:21LL]; // Unknown
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:21LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:21LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:21LL]);
XCTAssertEqual(value, 803);
- XCTAssertTrue([dict valueForKey:22LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:22LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:22LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:22LL]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:24LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:24LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:24LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:24LL]);
XCTAssertEqual(value, 803);
[dict setRawValue:700 forKey:24LL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:21LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:21LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:21LL]);
XCTAssertEqual(value, 803);
- XCTAssertTrue([dict valueForKey:22LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:22LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:22LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:22LL]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:23LL value:NULL]);
- XCTAssertTrue([dict valueForKey:23LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:23LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:23LL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:24LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:24LL]);
XCTAssertEqual(value, 700);
const int64_t kKeys2[] = { 22LL, 23LL };
@@ -3313,17 +3338,17 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:21LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:21LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:21LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:21LL]);
XCTAssertEqual(value, 803);
- XCTAssertTrue([dict valueForKey:22LL value:NULL]);
- XCTAssertTrue([dict valueForKey:22LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:22LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:22LL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:23LL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:23LL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:23LL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:23LL]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:24LL value:NULL]);
- XCTAssertTrue([dict valueForKey:24LL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:24LL]);
+ XCTAssertTrue([dict getEnum:&value forKey:24LL]);
XCTAssertEqual(value, 700);
[dict2 release];
@@ -3363,11 +3388,11 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
@implementation GPBInt64ObjectDictionaryTests
- (void)testEmpty {
- GPBInt64ObjectDictionary *dict = [[GPBInt64ObjectDictionary alloc] init];
+ GPBInt64ObjectDictionary<NSString*> *dict = [[GPBInt64ObjectDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
XCTAssertNil([dict objectForKey:21LL]);
- [dict enumerateKeysAndObjectsUsingBlock:^(int64_t aKey, id aObject, BOOL *stop) {
+ [dict enumerateKeysAndObjectsUsingBlock:^(int64_t aKey, NSString* aObject, BOOL *stop) {
#pragma unused(aKey, aObject, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -3375,22 +3400,24 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBInt64ObjectDictionary *dict = [GPBInt64ObjectDictionary dictionaryWithObject:@"abc" forKey:21LL];
+ GPBInt64ObjectDictionary<NSString*> *dict = [[GPBInt64ObjectDictionary alloc] init];
+ [dict setObject:@"abc" forKey:21LL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
XCTAssertEqualObjects([dict objectForKey:21LL], @"abc");
XCTAssertNil([dict objectForKey:22LL]);
- [dict enumerateKeysAndObjectsUsingBlock:^(int64_t aKey, id aObject, BOOL *stop) {
+ [dict enumerateKeysAndObjectsUsingBlock:^(int64_t aKey, NSString* aObject, BOOL *stop) {
XCTAssertEqual(aKey, 21LL);
XCTAssertEqualObjects(aObject, @"abc");
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const int64_t kKeys[] = { 21LL, 22LL, 23LL };
- const id kObjects[] = { @"abc", @"def", @"ghi" };
- GPBInt64ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi" };
+ GPBInt64ObjectDictionary<NSString*> *dict =
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
@@ -3403,8 +3430,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
__block NSUInteger idx = 0;
int64_t *seenKeys = malloc(3 * sizeof(int64_t));
- id *seenObjects = malloc(3 * sizeof(id));
- [dict enumerateKeysAndObjectsUsingBlock:^(int64_t aKey, id aObject, BOOL *stop) {
+ NSString* *seenObjects = malloc(3 * sizeof(NSString*));
+ [dict enumerateKeysAndObjectsUsingBlock:^(int64_t aKey, NSString* aObject, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenObjects[idx] = aObject;
@@ -3426,7 +3453,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndObjectsUsingBlock:^(int64_t aKey, id aObject, BOOL *stop) {
+ [dict enumerateKeysAndObjectsUsingBlock:^(int64_t aKey, NSString* aObject, BOOL *stop) {
#pragma unused(aKey, aObject)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -3438,30 +3465,30 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
- (void)testEquality {
const int64_t kKeys1[] = { 21LL, 22LL, 23LL, 24LL };
const int64_t kKeys2[] = { 22LL, 21LL, 24LL };
- const id kObjects1[] = { @"abc", @"def", @"ghi" };
- const id kObjects2[] = { @"abc", @"jkl", @"ghi" };
- const id kObjects3[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBInt64ObjectDictionary *dict1 =
+ const NSString* kObjects1[] = { @"abc", @"def", @"ghi" };
+ const NSString* kObjects2[] = { @"abc", @"jkl", @"ghi" };
+ const NSString* kObjects3[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBInt64ObjectDictionary<NSString*> *dict1 =
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects1
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects1)];
XCTAssertNotNil(dict1);
- GPBInt64ObjectDictionary *dict1prime =
+ GPBInt64ObjectDictionary<NSString*> *dict1prime =
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects1
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects1)];
XCTAssertNotNil(dict1prime);
- GPBInt64ObjectDictionary *dict2 =
+ GPBInt64ObjectDictionary<NSString*> *dict2 =
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects2
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects2)];
XCTAssertNotNil(dict2);
- GPBInt64ObjectDictionary *dict3 =
+ GPBInt64ObjectDictionary<NSString*> *dict3 =
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects1
forKeys:kKeys2
count:GPBARRAYSIZE(kObjects1)];
XCTAssertNotNil(dict3);
- GPBInt64ObjectDictionary *dict4 =
+ GPBInt64ObjectDictionary<NSString*> *dict4 =
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects3
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects3)];
@@ -3491,14 +3518,14 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
- (void)testCopy {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
- const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBInt64ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBInt64ObjectDictionary<NSString*> *dict =
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
- GPBInt64ObjectDictionary *dict2 = [dict copy];
+ GPBInt64ObjectDictionary<NSString*> *dict2 = [dict copy];
XCTAssertNotNil(dict2);
// Should be new object but equal.
@@ -3512,25 +3539,26 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
- (void)testDictionaryFromDictionary {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
- const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBInt64ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBInt64ObjectDictionary<NSString*> *dict =
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
- GPBInt64ObjectDictionary *dict2 =
- [GPBInt64ObjectDictionary dictionaryWithDictionary:dict];
+ GPBInt64ObjectDictionary<NSString*> *dict2 =
+ [[GPBInt64ObjectDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBInt64ObjectDictionary *dict = [GPBInt64ObjectDictionary dictionary];
+ GPBInt64ObjectDictionary<NSString*> *dict = [[GPBInt64ObjectDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@@ -3538,8 +3566,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 1U);
const int64_t kKeys[] = { 22LL, 23LL, 24LL };
- const id kObjects[] = { @"def", @"ghi", @"jkl" };
- GPBInt64ObjectDictionary *dict2 =
+ const NSString* kObjects[] = { @"def", @"ghi", @"jkl" };
+ GPBInt64ObjectDictionary<NSString*> *dict2 =
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
@@ -3552,15 +3580,16 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqualObjects([dict objectForKey:23LL], @"ghi");
XCTAssertEqualObjects([dict objectForKey:24LL], @"jkl");
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
- const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBInt64ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBInt64ObjectDictionary<NSString*> *dict =
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects
- forKeys:kKeys
- count:GPBARRAYSIZE(kObjects)];
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
@@ -3597,11 +3626,11 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
- (void)testInplaceMutation {
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
- const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBInt64ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBInt64ObjectDictionary<NSString*> *dict =
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects
- forKeys:kKeys
- count:GPBARRAYSIZE(kObjects)];
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
XCTAssertEqualObjects([dict objectForKey:21LL], @"abc");
@@ -3624,8 +3653,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqualObjects([dict objectForKey:24LL], @"def");
const int64_t kKeys2[] = { 22LL, 23LL };
- const id kObjects2[] = { @"ghi", @"abc" };
- GPBInt64ObjectDictionary *dict2 =
+ const NSString* kObjects2[] = { @"ghi", @"abc" };
+ GPBInt64ObjectDictionary<NSString*> *dict2 =
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects2
forKeys:kKeys2
count:GPBARRAYSIZE(kObjects2)];
diff --git a/objectivec/Tests/GPBDictionaryTests+String.m b/objectivec/Tests/GPBDictionaryTests+String.m
index bfa10b19..82d7952b 100644
--- a/objectivec/Tests/GPBDictionaryTests+String.m
+++ b/objectivec/Tests/GPBDictionaryTests+String.m
@@ -45,10 +45,9 @@
// To let the testing macros work, add some extra methods to simplify things.
@interface GPBStringEnumDictionary (TestingTweak)
-+ (instancetype)dictionaryWithValue:(int32_t)value forKey:(NSString *)key;
-- (instancetype)initWithValues:(const int32_t [])values
- forKeys:(const NSString * [])keys
- count:(NSUInteger)count;
+- (instancetype)initWithEnums:(const int32_t [])values
+ forKeys:(const NSString * [])keys
+ count:(NSUInteger)count;
@end
static BOOL TestingEnum_IsValidValue(int32_t value) {
@@ -64,17 +63,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
@implementation GPBStringEnumDictionary (TestingTweak)
-+ (instancetype)dictionaryWithValue:(int32_t)value forKey:(NSString *)key {
- // Cast is needed to compiler knows what class we are invoking initWithValues: on to get the
- // type correct.
- return [[(GPBStringEnumDictionary*)[self alloc] initWithValidationFunction:TestingEnum_IsValidValue
- rawValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-- (instancetype)initWithValues:(const int32_t [])values
- forKeys:(const NSString * [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithEnums:(const int32_t [])values
+ forKeys:(const NSString * [])keys
+ count:(NSUInteger)count {
return [self initWithValidationFunction:TestingEnum_IsValidValue
rawValues:values
forKeys:keys
@@ -94,8 +85,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBStringUInt32Dictionary *dict = [[GPBStringUInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, uint32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt32:NULL forKey:@"foo"]);
+ [dict enumerateKeysAndUInt32sUsingBlock:^(NSString *aKey, uint32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -103,46 +94,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBStringUInt32Dictionary *dict = [GPBStringUInt32Dictionary dictionaryWithValue:100U forKey:@"foo"];
+ GPBStringUInt32Dictionary *dict = [[GPBStringUInt32Dictionary alloc] init];
+ [dict setUInt32:100U forKey:@"foo"];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, uint32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt32:NULL forKey:@"bar"]);
+ [dict enumerateKeysAndUInt32sUsingBlock:^(NSString *aKey, uint32_t aValue, BOOL *stop) {
XCTAssertEqualObjects(aKey, @"foo");
XCTAssertEqual(aValue, 100U);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const NSString *kKeys[] = { @"foo", @"bar", @"baz" };
const uint32_t kValues[] = { 100U, 101U, 102U };
GPBStringUInt32Dictionary *dict =
- [[GPBStringUInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringUInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"bar"]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 102U);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:@"mumble"]);
__block NSUInteger idx = 0;
NSString **seenKeys = malloc(3 * sizeof(NSString*));
uint32_t *seenValues = malloc(3 * sizeof(uint32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, uint32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt32sUsingBlock:^(NSString *aKey, uint32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -164,7 +157,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, uint32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt32sUsingBlock:^(NSString *aKey, uint32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -180,29 +173,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kValues2[] = { 100U, 103U, 102U };
const uint32_t kValues3[] = { 100U, 101U, 102U, 103U };
GPBStringUInt32Dictionary *dict1 =
- [[GPBStringUInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBStringUInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBStringUInt32Dictionary *dict1prime =
- [[GPBStringUInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBStringUInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBStringUInt32Dictionary *dict2 =
- [[GPBStringUInt32Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBStringUInt32Dictionary alloc] initWithUInt32s:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBStringUInt32Dictionary *dict3 =
- [[GPBStringUInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBStringUInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBStringUInt32Dictionary *dict4 =
- [[GPBStringUInt32Dictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBStringUInt32Dictionary alloc] initWithUInt32s:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -231,9 +224,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBStringUInt32Dictionary *dict =
- [[GPBStringUInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringUInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBStringUInt32Dictionary *dict2 = [dict copy];
@@ -252,110 +245,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBStringUInt32Dictionary *dict =
- [[GPBStringUInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringUInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBStringUInt32Dictionary *dict2 =
- [GPBStringUInt32Dictionary dictionaryWithDictionary:dict];
+ [[GPBStringUInt32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBStringUInt32Dictionary *dict = [GPBStringUInt32Dictionary dictionary];
+ GPBStringUInt32Dictionary *dict = [[GPBStringUInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:100U forKey:@"foo"];
+ [dict setUInt32:100U forKey:@"foo"];
XCTAssertEqual(dict.count, 1U);
const NSString *kKeys[] = { @"bar", @"baz", @"mumble" };
const uint32_t kValues[] = { 101U, 102U, 103U };
GPBStringUInt32Dictionary *dict2 =
- [[GPBStringUInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringUInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"bar"]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"mumble"]);
XCTAssertEqual(value, 103U);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBStringUInt32Dictionary *dict =
- [[GPBStringUInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringUInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:@"bar"];
+ [dict removeUInt32ForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"mumble"]);
XCTAssertEqual(value, 103U);
// Remove again does nothing.
- [dict removeValueForKey:@"bar"];
+ [dict removeUInt32ForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"mumble"]);
XCTAssertEqual(value, 103U);
- [dict removeValueForKey:@"mumble"];
+ [dict removeUInt32ForKey:@"mumble"];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 102U);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:@"mumble"]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"baz" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:@"foo"]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:@"bar"]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:@"baz"]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:@"mumble"]);
[dict release];
}
@@ -363,75 +358,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBStringUInt32Dictionary *dict =
- [[GPBStringUInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringUInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"bar"]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"mumble"]);
XCTAssertEqual(value, 103U);
- [dict setValue:103U forKey:@"foo"];
+ [dict setUInt32:103U forKey:@"foo"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 103U);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"bar"]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"mumble"]);
XCTAssertEqual(value, 103U);
- [dict setValue:101U forKey:@"mumble"];
+ [dict setUInt32:101U forKey:@"mumble"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 103U);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"bar"]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"mumble"]);
XCTAssertEqual(value, 101U);
const NSString *kKeys2[] = { @"bar", @"baz" };
const uint32_t kValues2[] = { 102U, 100U };
GPBStringUInt32Dictionary *dict2 =
- [[GPBStringUInt32Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBStringUInt32Dictionary alloc] initWithUInt32s:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 103U);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"bar"]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getUInt32:&value forKey:@"mumble"]);
XCTAssertEqual(value, 101U);
[dict2 release];
@@ -451,8 +446,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBStringInt32Dictionary *dict = [[GPBStringInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt32:NULL forKey:@"foo"]);
+ [dict enumerateKeysAndInt32sUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -460,46 +455,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBStringInt32Dictionary *dict = [GPBStringInt32Dictionary dictionaryWithValue:200 forKey:@"foo"];
+ GPBStringInt32Dictionary *dict = [[GPBStringInt32Dictionary alloc] init];
+ [dict setInt32:200 forKey:@"foo"];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt32:NULL forKey:@"bar"]);
+ [dict enumerateKeysAndInt32sUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
XCTAssertEqualObjects(aKey, @"foo");
XCTAssertEqual(aValue, 200);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const NSString *kKeys[] = { @"foo", @"bar", @"baz" };
const int32_t kValues[] = { 200, 201, 202 };
GPBStringInt32Dictionary *dict =
- [[GPBStringInt32Dictionary alloc] initWithValues:kValues
+ [[GPBStringInt32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"bar"]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 202);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:@"mumble"]);
__block NSUInteger idx = 0;
NSString **seenKeys = malloc(3 * sizeof(NSString*));
int32_t *seenValues = malloc(3 * sizeof(int32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt32sUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -521,7 +518,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt32sUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -537,27 +534,27 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kValues2[] = { 200, 203, 202 };
const int32_t kValues3[] = { 200, 201, 202, 203 };
GPBStringInt32Dictionary *dict1 =
- [[GPBStringInt32Dictionary alloc] initWithValues:kValues1
+ [[GPBStringInt32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBStringInt32Dictionary *dict1prime =
- [[GPBStringInt32Dictionary alloc] initWithValues:kValues1
+ [[GPBStringInt32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBStringInt32Dictionary *dict2 =
- [[GPBStringInt32Dictionary alloc] initWithValues:kValues2
+ [[GPBStringInt32Dictionary alloc] initWithInt32s:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBStringInt32Dictionary *dict3 =
- [[GPBStringInt32Dictionary alloc] initWithValues:kValues1
+ [[GPBStringInt32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBStringInt32Dictionary *dict4 =
- [[GPBStringInt32Dictionary alloc] initWithValues:kValues3
+ [[GPBStringInt32Dictionary alloc] initWithInt32s:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -588,7 +585,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBStringInt32Dictionary *dict =
- [[GPBStringInt32Dictionary alloc] initWithValues:kValues
+ [[GPBStringInt32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -609,33 +606,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBStringInt32Dictionary *dict =
- [[GPBStringInt32Dictionary alloc] initWithValues:kValues
+ [[GPBStringInt32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBStringInt32Dictionary *dict2 =
- [GPBStringInt32Dictionary dictionaryWithDictionary:dict];
+ [[GPBStringInt32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBStringInt32Dictionary *dict = [GPBStringInt32Dictionary dictionary];
+ GPBStringInt32Dictionary *dict = [[GPBStringInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:200 forKey:@"foo"];
+ [dict setInt32:200 forKey:@"foo"];
XCTAssertEqual(dict.count, 1U);
const NSString *kKeys[] = { @"bar", @"baz", @"mumble" };
const int32_t kValues[] = { 201, 202, 203 };
GPBStringInt32Dictionary *dict2 =
- [[GPBStringInt32Dictionary alloc] initWithValues:kValues
+ [[GPBStringInt32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -643,76 +641,77 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"bar"]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"mumble"]);
XCTAssertEqual(value, 203);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBStringInt32Dictionary *dict =
- [[GPBStringInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringInt32Dictionary alloc] initWithInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:@"bar"];
+ [dict removeInt32ForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"mumble"]);
XCTAssertEqual(value, 203);
// Remove again does nothing.
- [dict removeValueForKey:@"bar"];
+ [dict removeInt32ForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"mumble"]);
XCTAssertEqual(value, 203);
- [dict removeValueForKey:@"mumble"];
+ [dict removeInt32ForKey:@"mumble"];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 202);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:@"mumble"]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"baz" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:@"foo"]);
+ XCTAssertFalse([dict getInt32:NULL forKey:@"bar"]);
+ XCTAssertFalse([dict getInt32:NULL forKey:@"baz"]);
+ XCTAssertFalse([dict getInt32:NULL forKey:@"mumble"]);
[dict release];
}
@@ -720,75 +719,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBStringInt32Dictionary *dict =
- [[GPBStringInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringInt32Dictionary alloc] initWithInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"bar"]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"mumble"]);
XCTAssertEqual(value, 203);
- [dict setValue:203 forKey:@"foo"];
+ [dict setInt32:203 forKey:@"foo"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 203);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"bar"]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"mumble"]);
XCTAssertEqual(value, 203);
- [dict setValue:201 forKey:@"mumble"];
+ [dict setInt32:201 forKey:@"mumble"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 203);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"bar"]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"mumble"]);
XCTAssertEqual(value, 201);
const NSString *kKeys2[] = { @"bar", @"baz" };
const int32_t kValues2[] = { 202, 200 };
GPBStringInt32Dictionary *dict2 =
- [[GPBStringInt32Dictionary alloc] initWithValues:kValues2
+ [[GPBStringInt32Dictionary alloc] initWithInt32s:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"foo"]);
XCTAssertEqual(value, 203);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"bar"]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"baz"]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getInt32:&value forKey:@"mumble"]);
XCTAssertEqual(value, 201);
[dict2 release];
@@ -808,8 +807,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBStringUInt64Dictionary *dict = [[GPBStringUInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, uint64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt64:NULL forKey:@"foo"]);
+ [dict enumerateKeysAndUInt64sUsingBlock:^(NSString *aKey, uint64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -817,46 +816,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBStringUInt64Dictionary *dict = [GPBStringUInt64Dictionary dictionaryWithValue:300U forKey:@"foo"];
+ GPBStringUInt64Dictionary *dict = [[GPBStringUInt64Dictionary alloc] init];
+ [dict setUInt64:300U forKey:@"foo"];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, uint64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt64:NULL forKey:@"bar"]);
+ [dict enumerateKeysAndUInt64sUsingBlock:^(NSString *aKey, uint64_t aValue, BOOL *stop) {
XCTAssertEqualObjects(aKey, @"foo");
XCTAssertEqual(aValue, 300U);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const NSString *kKeys[] = { @"foo", @"bar", @"baz" };
const uint64_t kValues[] = { 300U, 301U, 302U };
GPBStringUInt64Dictionary *dict =
- [[GPBStringUInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringUInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"bar"]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 302U);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:@"mumble"]);
__block NSUInteger idx = 0;
NSString **seenKeys = malloc(3 * sizeof(NSString*));
uint64_t *seenValues = malloc(3 * sizeof(uint64_t));
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, uint64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt64sUsingBlock:^(NSString *aKey, uint64_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -878,7 +879,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, uint64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt64sUsingBlock:^(NSString *aKey, uint64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -894,29 +895,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kValues2[] = { 300U, 303U, 302U };
const uint64_t kValues3[] = { 300U, 301U, 302U, 303U };
GPBStringUInt64Dictionary *dict1 =
- [[GPBStringUInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBStringUInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBStringUInt64Dictionary *dict1prime =
- [[GPBStringUInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBStringUInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBStringUInt64Dictionary *dict2 =
- [[GPBStringUInt64Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBStringUInt64Dictionary alloc] initWithUInt64s:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBStringUInt64Dictionary *dict3 =
- [[GPBStringUInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBStringUInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBStringUInt64Dictionary *dict4 =
- [[GPBStringUInt64Dictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBStringUInt64Dictionary alloc] initWithUInt64s:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -945,9 +946,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBStringUInt64Dictionary *dict =
- [[GPBStringUInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringUInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBStringUInt64Dictionary *dict2 = [dict copy];
@@ -966,110 +967,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBStringUInt64Dictionary *dict =
- [[GPBStringUInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringUInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBStringUInt64Dictionary *dict2 =
- [GPBStringUInt64Dictionary dictionaryWithDictionary:dict];
+ [[GPBStringUInt64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBStringUInt64Dictionary *dict = [GPBStringUInt64Dictionary dictionary];
+ GPBStringUInt64Dictionary *dict = [[GPBStringUInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:300U forKey:@"foo"];
+ [dict setUInt64:300U forKey:@"foo"];
XCTAssertEqual(dict.count, 1U);
const NSString *kKeys[] = { @"bar", @"baz", @"mumble" };
const uint64_t kValues[] = { 301U, 302U, 303U };
GPBStringUInt64Dictionary *dict2 =
- [[GPBStringUInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringUInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"bar"]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"mumble"]);
XCTAssertEqual(value, 303U);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBStringUInt64Dictionary *dict =
- [[GPBStringUInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringUInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:@"bar"];
+ [dict removeUInt64ForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"mumble"]);
XCTAssertEqual(value, 303U);
// Remove again does nothing.
- [dict removeValueForKey:@"bar"];
+ [dict removeUInt64ForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"mumble"]);
XCTAssertEqual(value, 303U);
- [dict removeValueForKey:@"mumble"];
+ [dict removeUInt64ForKey:@"mumble"];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 302U);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:@"mumble"]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"baz" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:@"foo"]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:@"bar"]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:@"baz"]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:@"mumble"]);
[dict release];
}
@@ -1077,75 +1080,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBStringUInt64Dictionary *dict =
- [[GPBStringUInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringUInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"bar"]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"mumble"]);
XCTAssertEqual(value, 303U);
- [dict setValue:303U forKey:@"foo"];
+ [dict setUInt64:303U forKey:@"foo"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 303U);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"bar"]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"mumble"]);
XCTAssertEqual(value, 303U);
- [dict setValue:301U forKey:@"mumble"];
+ [dict setUInt64:301U forKey:@"mumble"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 303U);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"bar"]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"mumble"]);
XCTAssertEqual(value, 301U);
const NSString *kKeys2[] = { @"bar", @"baz" };
const uint64_t kValues2[] = { 302U, 300U };
GPBStringUInt64Dictionary *dict2 =
- [[GPBStringUInt64Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBStringUInt64Dictionary alloc] initWithUInt64s:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 303U);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"bar"]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getUInt64:&value forKey:@"mumble"]);
XCTAssertEqual(value, 301U);
[dict2 release];
@@ -1165,8 +1168,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBStringInt64Dictionary *dict = [[GPBStringInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, int64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt64:NULL forKey:@"foo"]);
+ [dict enumerateKeysAndInt64sUsingBlock:^(NSString *aKey, int64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1174,46 +1177,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBStringInt64Dictionary *dict = [GPBStringInt64Dictionary dictionaryWithValue:400 forKey:@"foo"];
+ GPBStringInt64Dictionary *dict = [[GPBStringInt64Dictionary alloc] init];
+ [dict setInt64:400 forKey:@"foo"];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int64_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, int64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt64:NULL forKey:@"bar"]);
+ [dict enumerateKeysAndInt64sUsingBlock:^(NSString *aKey, int64_t aValue, BOOL *stop) {
XCTAssertEqualObjects(aKey, @"foo");
XCTAssertEqual(aValue, 400);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const NSString *kKeys[] = { @"foo", @"bar", @"baz" };
const int64_t kValues[] = { 400, 401, 402 };
GPBStringInt64Dictionary *dict =
- [[GPBStringInt64Dictionary alloc] initWithValues:kValues
+ [[GPBStringInt64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
int64_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"bar"]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 402);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:@"mumble"]);
__block NSUInteger idx = 0;
NSString **seenKeys = malloc(3 * sizeof(NSString*));
int64_t *seenValues = malloc(3 * sizeof(int64_t));
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, int64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt64sUsingBlock:^(NSString *aKey, int64_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1235,7 +1240,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, int64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt64sUsingBlock:^(NSString *aKey, int64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1251,27 +1256,27 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kValues2[] = { 400, 403, 402 };
const int64_t kValues3[] = { 400, 401, 402, 403 };
GPBStringInt64Dictionary *dict1 =
- [[GPBStringInt64Dictionary alloc] initWithValues:kValues1
+ [[GPBStringInt64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBStringInt64Dictionary *dict1prime =
- [[GPBStringInt64Dictionary alloc] initWithValues:kValues1
+ [[GPBStringInt64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBStringInt64Dictionary *dict2 =
- [[GPBStringInt64Dictionary alloc] initWithValues:kValues2
+ [[GPBStringInt64Dictionary alloc] initWithInt64s:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBStringInt64Dictionary *dict3 =
- [[GPBStringInt64Dictionary alloc] initWithValues:kValues1
+ [[GPBStringInt64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBStringInt64Dictionary *dict4 =
- [[GPBStringInt64Dictionary alloc] initWithValues:kValues3
+ [[GPBStringInt64Dictionary alloc] initWithInt64s:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -1302,7 +1307,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBStringInt64Dictionary *dict =
- [[GPBStringInt64Dictionary alloc] initWithValues:kValues
+ [[GPBStringInt64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -1323,33 +1328,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBStringInt64Dictionary *dict =
- [[GPBStringInt64Dictionary alloc] initWithValues:kValues
+ [[GPBStringInt64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBStringInt64Dictionary *dict2 =
- [GPBStringInt64Dictionary dictionaryWithDictionary:dict];
+ [[GPBStringInt64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBStringInt64Dictionary *dict = [GPBStringInt64Dictionary dictionary];
+ GPBStringInt64Dictionary *dict = [[GPBStringInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:400 forKey:@"foo"];
+ [dict setInt64:400 forKey:@"foo"];
XCTAssertEqual(dict.count, 1U);
const NSString *kKeys[] = { @"bar", @"baz", @"mumble" };
const int64_t kValues[] = { 401, 402, 403 };
GPBStringInt64Dictionary *dict2 =
- [[GPBStringInt64Dictionary alloc] initWithValues:kValues
+ [[GPBStringInt64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -1357,76 +1363,77 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 4U);
int64_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"bar"]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"mumble"]);
XCTAssertEqual(value, 403);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBStringInt64Dictionary *dict =
- [[GPBStringInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringInt64Dictionary alloc] initWithInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:@"bar"];
+ [dict removeInt64ForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
int64_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"mumble"]);
XCTAssertEqual(value, 403);
// Remove again does nothing.
- [dict removeValueForKey:@"bar"];
+ [dict removeInt64ForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"mumble"]);
XCTAssertEqual(value, 403);
- [dict removeValueForKey:@"mumble"];
+ [dict removeInt64ForKey:@"mumble"];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 402);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:@"mumble"]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"baz" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:@"foo"]);
+ XCTAssertFalse([dict getInt64:NULL forKey:@"bar"]);
+ XCTAssertFalse([dict getInt64:NULL forKey:@"baz"]);
+ XCTAssertFalse([dict getInt64:NULL forKey:@"mumble"]);
[dict release];
}
@@ -1434,75 +1441,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBStringInt64Dictionary *dict =
- [[GPBStringInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringInt64Dictionary alloc] initWithInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int64_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"bar"]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"mumble"]);
XCTAssertEqual(value, 403);
- [dict setValue:403 forKey:@"foo"];
+ [dict setInt64:403 forKey:@"foo"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 403);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"bar"]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"mumble"]);
XCTAssertEqual(value, 403);
- [dict setValue:401 forKey:@"mumble"];
+ [dict setInt64:401 forKey:@"mumble"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 403);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"bar"]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"mumble"]);
XCTAssertEqual(value, 401);
const NSString *kKeys2[] = { @"bar", @"baz" };
const int64_t kValues2[] = { 402, 400 };
GPBStringInt64Dictionary *dict2 =
- [[GPBStringInt64Dictionary alloc] initWithValues:kValues2
+ [[GPBStringInt64Dictionary alloc] initWithInt64s:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"foo"]);
XCTAssertEqual(value, 403);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"bar"]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"baz"]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getInt64:&value forKey:@"mumble"]);
XCTAssertEqual(value, 401);
[dict2 release];
@@ -1522,8 +1529,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBStringBoolDictionary *dict = [[GPBStringBoolDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, BOOL aValue, BOOL *stop) {
+ XCTAssertFalse([dict getBool:NULL forKey:@"foo"]);
+ [dict enumerateKeysAndBoolsUsingBlock:^(NSString *aKey, BOOL aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1531,46 +1538,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBStringBoolDictionary *dict = [GPBStringBoolDictionary dictionaryWithValue:YES forKey:@"foo"];
+ GPBStringBoolDictionary *dict = [[GPBStringBoolDictionary alloc] init];
+ [dict setBool:YES forKey:@"foo"];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
BOOL value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"foo"]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, BOOL aValue, BOOL *stop) {
+ XCTAssertFalse([dict getBool:NULL forKey:@"bar"]);
+ [dict enumerateKeysAndBoolsUsingBlock:^(NSString *aKey, BOOL aValue, BOOL *stop) {
XCTAssertEqualObjects(aKey, @"foo");
XCTAssertEqual(aValue, YES);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const NSString *kKeys[] = { @"foo", @"bar", @"baz" };
const BOOL kValues[] = { YES, YES, NO };
GPBStringBoolDictionary *dict =
- [[GPBStringBoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringBoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
BOOL value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"foo"]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"bar"]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"baz"]);
XCTAssertEqual(value, NO);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:@"mumble"]);
__block NSUInteger idx = 0;
NSString **seenKeys = malloc(3 * sizeof(NSString*));
BOOL *seenValues = malloc(3 * sizeof(BOOL));
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, BOOL aValue, BOOL *stop) {
+ [dict enumerateKeysAndBoolsUsingBlock:^(NSString *aKey, BOOL aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1592,7 +1601,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, BOOL aValue, BOOL *stop) {
+ [dict enumerateKeysAndBoolsUsingBlock:^(NSString *aKey, BOOL aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1608,29 +1617,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const BOOL kValues2[] = { YES, NO, NO };
const BOOL kValues3[] = { YES, YES, NO, NO };
GPBStringBoolDictionary *dict1 =
- [[GPBStringBoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBStringBoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBStringBoolDictionary *dict1prime =
- [[GPBStringBoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBStringBoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBStringBoolDictionary *dict2 =
- [[GPBStringBoolDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBStringBoolDictionary alloc] initWithBools:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBStringBoolDictionary *dict3 =
- [[GPBStringBoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBStringBoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBStringBoolDictionary *dict4 =
- [[GPBStringBoolDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBStringBoolDictionary alloc] initWithBools:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -1659,9 +1668,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBStringBoolDictionary *dict =
- [[GPBStringBoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringBoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBStringBoolDictionary *dict2 = [dict copy];
@@ -1680,110 +1689,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBStringBoolDictionary *dict =
- [[GPBStringBoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringBoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBStringBoolDictionary *dict2 =
- [GPBStringBoolDictionary dictionaryWithDictionary:dict];
+ [[GPBStringBoolDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBStringBoolDictionary *dict = [GPBStringBoolDictionary dictionary];
+ GPBStringBoolDictionary *dict = [[GPBStringBoolDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:YES forKey:@"foo"];
+ [dict setBool:YES forKey:@"foo"];
XCTAssertEqual(dict.count, 1U);
const NSString *kKeys[] = { @"bar", @"baz", @"mumble" };
const BOOL kValues[] = { YES, NO, NO };
GPBStringBoolDictionary *dict2 =
- [[GPBStringBoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringBoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
BOOL value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"foo"]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"bar"]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"baz"]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"mumble"]);
XCTAssertEqual(value, NO);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBStringBoolDictionary *dict =
- [[GPBStringBoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringBoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:@"bar"];
+ [dict removeBoolForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
BOOL value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"foo"]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getBool:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"baz"]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"mumble"]);
XCTAssertEqual(value, NO);
// Remove again does nothing.
- [dict removeValueForKey:@"bar"];
+ [dict removeBoolForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"foo"]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getBool:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"baz"]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"mumble"]);
XCTAssertEqual(value, NO);
- [dict removeValueForKey:@"mumble"];
+ [dict removeBoolForKey:@"mumble"];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"foo"]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getBool:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"baz"]);
XCTAssertEqual(value, NO);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:@"mumble"]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"baz" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:@"foo"]);
+ XCTAssertFalse([dict getBool:NULL forKey:@"bar"]);
+ XCTAssertFalse([dict getBool:NULL forKey:@"baz"]);
+ XCTAssertFalse([dict getBool:NULL forKey:@"mumble"]);
[dict release];
}
@@ -1791,75 +1802,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBStringBoolDictionary *dict =
- [[GPBStringBoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringBoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
BOOL value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"foo"]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"bar"]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"baz"]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"mumble"]);
XCTAssertEqual(value, NO);
- [dict setValue:NO forKey:@"foo"];
+ [dict setBool:NO forKey:@"foo"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"foo"]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"bar"]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"baz"]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"mumble"]);
XCTAssertEqual(value, NO);
- [dict setValue:YES forKey:@"mumble"];
+ [dict setBool:YES forKey:@"mumble"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"foo"]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"bar"]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"baz"]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"mumble"]);
XCTAssertEqual(value, YES);
const NSString *kKeys2[] = { @"bar", @"baz" };
const BOOL kValues2[] = { NO, YES };
GPBStringBoolDictionary *dict2 =
- [[GPBStringBoolDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBStringBoolDictionary alloc] initWithBools:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"foo"]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"bar"]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"baz"]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getBool:&value forKey:@"mumble"]);
XCTAssertEqual(value, YES);
[dict2 release];
@@ -1879,8 +1890,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBStringFloatDictionary *dict = [[GPBStringFloatDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, float aValue, BOOL *stop) {
+ XCTAssertFalse([dict getFloat:NULL forKey:@"foo"]);
+ [dict enumerateKeysAndFloatsUsingBlock:^(NSString *aKey, float aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1888,46 +1899,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBStringFloatDictionary *dict = [GPBStringFloatDictionary dictionaryWithValue:500.f forKey:@"foo"];
+ GPBStringFloatDictionary *dict = [[GPBStringFloatDictionary alloc] init];
+ [dict setFloat:500.f forKey:@"foo"];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
float value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"foo"]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, float aValue, BOOL *stop) {
+ XCTAssertFalse([dict getFloat:NULL forKey:@"bar"]);
+ [dict enumerateKeysAndFloatsUsingBlock:^(NSString *aKey, float aValue, BOOL *stop) {
XCTAssertEqualObjects(aKey, @"foo");
XCTAssertEqual(aValue, 500.f);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const NSString *kKeys[] = { @"foo", @"bar", @"baz" };
const float kValues[] = { 500.f, 501.f, 502.f };
GPBStringFloatDictionary *dict =
- [[GPBStringFloatDictionary alloc] initWithValues:kValues
+ [[GPBStringFloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
float value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"foo"]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"bar"]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"baz"]);
XCTAssertEqual(value, 502.f);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:@"mumble"]);
__block NSUInteger idx = 0;
NSString **seenKeys = malloc(3 * sizeof(NSString*));
float *seenValues = malloc(3 * sizeof(float));
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, float aValue, BOOL *stop) {
+ [dict enumerateKeysAndFloatsUsingBlock:^(NSString *aKey, float aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1949,7 +1962,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, float aValue, BOOL *stop) {
+ [dict enumerateKeysAndFloatsUsingBlock:^(NSString *aKey, float aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1965,27 +1978,27 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const float kValues2[] = { 500.f, 503.f, 502.f };
const float kValues3[] = { 500.f, 501.f, 502.f, 503.f };
GPBStringFloatDictionary *dict1 =
- [[GPBStringFloatDictionary alloc] initWithValues:kValues1
+ [[GPBStringFloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBStringFloatDictionary *dict1prime =
- [[GPBStringFloatDictionary alloc] initWithValues:kValues1
+ [[GPBStringFloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBStringFloatDictionary *dict2 =
- [[GPBStringFloatDictionary alloc] initWithValues:kValues2
+ [[GPBStringFloatDictionary alloc] initWithFloats:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBStringFloatDictionary *dict3 =
- [[GPBStringFloatDictionary alloc] initWithValues:kValues1
+ [[GPBStringFloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBStringFloatDictionary *dict4 =
- [[GPBStringFloatDictionary alloc] initWithValues:kValues3
+ [[GPBStringFloatDictionary alloc] initWithFloats:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -2016,7 +2029,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBStringFloatDictionary *dict =
- [[GPBStringFloatDictionary alloc] initWithValues:kValues
+ [[GPBStringFloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -2037,33 +2050,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBStringFloatDictionary *dict =
- [[GPBStringFloatDictionary alloc] initWithValues:kValues
+ [[GPBStringFloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBStringFloatDictionary *dict2 =
- [GPBStringFloatDictionary dictionaryWithDictionary:dict];
+ [[GPBStringFloatDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBStringFloatDictionary *dict = [GPBStringFloatDictionary dictionary];
+ GPBStringFloatDictionary *dict = [[GPBStringFloatDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:500.f forKey:@"foo"];
+ [dict setFloat:500.f forKey:@"foo"];
XCTAssertEqual(dict.count, 1U);
const NSString *kKeys[] = { @"bar", @"baz", @"mumble" };
const float kValues[] = { 501.f, 502.f, 503.f };
GPBStringFloatDictionary *dict2 =
- [[GPBStringFloatDictionary alloc] initWithValues:kValues
+ [[GPBStringFloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -2071,76 +2085,77 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 4U);
float value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"foo"]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"bar"]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"baz"]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"mumble"]);
XCTAssertEqual(value, 503.f);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBStringFloatDictionary *dict =
- [[GPBStringFloatDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringFloatDictionary alloc] initWithFloats:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:@"bar"];
+ [dict removeFloatForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
float value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"foo"]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getFloat:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"baz"]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"mumble"]);
XCTAssertEqual(value, 503.f);
// Remove again does nothing.
- [dict removeValueForKey:@"bar"];
+ [dict removeFloatForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"foo"]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getFloat:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"baz"]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"mumble"]);
XCTAssertEqual(value, 503.f);
- [dict removeValueForKey:@"mumble"];
+ [dict removeFloatForKey:@"mumble"];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"foo"]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getFloat:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"baz"]);
XCTAssertEqual(value, 502.f);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:@"mumble"]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"baz" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:@"foo"]);
+ XCTAssertFalse([dict getFloat:NULL forKey:@"bar"]);
+ XCTAssertFalse([dict getFloat:NULL forKey:@"baz"]);
+ XCTAssertFalse([dict getFloat:NULL forKey:@"mumble"]);
[dict release];
}
@@ -2148,75 +2163,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBStringFloatDictionary *dict =
- [[GPBStringFloatDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringFloatDictionary alloc] initWithFloats:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
float value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"foo"]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"bar"]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"baz"]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"mumble"]);
XCTAssertEqual(value, 503.f);
- [dict setValue:503.f forKey:@"foo"];
+ [dict setFloat:503.f forKey:@"foo"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"foo"]);
XCTAssertEqual(value, 503.f);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"bar"]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"baz"]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"mumble"]);
XCTAssertEqual(value, 503.f);
- [dict setValue:501.f forKey:@"mumble"];
+ [dict setFloat:501.f forKey:@"mumble"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"foo"]);
XCTAssertEqual(value, 503.f);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"bar"]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"baz"]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"mumble"]);
XCTAssertEqual(value, 501.f);
const NSString *kKeys2[] = { @"bar", @"baz" };
const float kValues2[] = { 502.f, 500.f };
GPBStringFloatDictionary *dict2 =
- [[GPBStringFloatDictionary alloc] initWithValues:kValues2
+ [[GPBStringFloatDictionary alloc] initWithFloats:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"foo"]);
XCTAssertEqual(value, 503.f);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"bar"]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"baz"]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getFloat:&value forKey:@"mumble"]);
XCTAssertEqual(value, 501.f);
[dict2 release];
@@ -2236,8 +2251,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBStringDoubleDictionary *dict = [[GPBStringDoubleDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, double aValue, BOOL *stop) {
+ XCTAssertFalse([dict getDouble:NULL forKey:@"foo"]);
+ [dict enumerateKeysAndDoublesUsingBlock:^(NSString *aKey, double aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -2245,46 +2260,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBStringDoubleDictionary *dict = [GPBStringDoubleDictionary dictionaryWithValue:600. forKey:@"foo"];
+ GPBStringDoubleDictionary *dict = [[GPBStringDoubleDictionary alloc] init];
+ [dict setDouble:600. forKey:@"foo"];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
double value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"foo"]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, double aValue, BOOL *stop) {
+ XCTAssertFalse([dict getDouble:NULL forKey:@"bar"]);
+ [dict enumerateKeysAndDoublesUsingBlock:^(NSString *aKey, double aValue, BOOL *stop) {
XCTAssertEqualObjects(aKey, @"foo");
XCTAssertEqual(aValue, 600.);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const NSString *kKeys[] = { @"foo", @"bar", @"baz" };
const double kValues[] = { 600., 601., 602. };
GPBStringDoubleDictionary *dict =
- [[GPBStringDoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringDoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
double value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"foo"]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"bar"]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"baz"]);
XCTAssertEqual(value, 602.);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:@"mumble"]);
__block NSUInteger idx = 0;
NSString **seenKeys = malloc(3 * sizeof(NSString*));
double *seenValues = malloc(3 * sizeof(double));
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, double aValue, BOOL *stop) {
+ [dict enumerateKeysAndDoublesUsingBlock:^(NSString *aKey, double aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -2306,7 +2323,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, double aValue, BOOL *stop) {
+ [dict enumerateKeysAndDoublesUsingBlock:^(NSString *aKey, double aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -2322,29 +2339,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const double kValues2[] = { 600., 603., 602. };
const double kValues3[] = { 600., 601., 602., 603. };
GPBStringDoubleDictionary *dict1 =
- [[GPBStringDoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBStringDoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBStringDoubleDictionary *dict1prime =
- [[GPBStringDoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBStringDoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBStringDoubleDictionary *dict2 =
- [[GPBStringDoubleDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBStringDoubleDictionary alloc] initWithDoubles:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBStringDoubleDictionary *dict3 =
- [[GPBStringDoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBStringDoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBStringDoubleDictionary *dict4 =
- [[GPBStringDoubleDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBStringDoubleDictionary alloc] initWithDoubles:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -2373,9 +2390,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const double kValues[] = { 600., 601., 602., 603. };
GPBStringDoubleDictionary *dict =
- [[GPBStringDoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringDoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBStringDoubleDictionary *dict2 = [dict copy];
@@ -2394,110 +2411,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const double kValues[] = { 600., 601., 602., 603. };
GPBStringDoubleDictionary *dict =
- [[GPBStringDoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringDoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBStringDoubleDictionary *dict2 =
- [GPBStringDoubleDictionary dictionaryWithDictionary:dict];
+ [[GPBStringDoubleDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBStringDoubleDictionary *dict = [GPBStringDoubleDictionary dictionary];
+ GPBStringDoubleDictionary *dict = [[GPBStringDoubleDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:600. forKey:@"foo"];
+ [dict setDouble:600. forKey:@"foo"];
XCTAssertEqual(dict.count, 1U);
const NSString *kKeys[] = { @"bar", @"baz", @"mumble" };
const double kValues[] = { 601., 602., 603. };
GPBStringDoubleDictionary *dict2 =
- [[GPBStringDoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringDoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
double value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"foo"]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"bar"]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"baz"]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"mumble"]);
XCTAssertEqual(value, 603.);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const double kValues[] = { 600., 601., 602., 603. };
GPBStringDoubleDictionary *dict =
- [[GPBStringDoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringDoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:@"bar"];
+ [dict removeDoubleForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
double value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"foo"]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getDouble:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"baz"]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"mumble"]);
XCTAssertEqual(value, 603.);
// Remove again does nothing.
- [dict removeValueForKey:@"bar"];
+ [dict removeDoubleForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"foo"]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getDouble:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"baz"]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"mumble"]);
XCTAssertEqual(value, 603.);
- [dict removeValueForKey:@"mumble"];
+ [dict removeDoubleForKey:@"mumble"];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"foo"]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getDouble:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"baz"]);
XCTAssertEqual(value, 602.);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:@"mumble"]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"baz" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:@"foo"]);
+ XCTAssertFalse([dict getDouble:NULL forKey:@"bar"]);
+ XCTAssertFalse([dict getDouble:NULL forKey:@"baz"]);
+ XCTAssertFalse([dict getDouble:NULL forKey:@"mumble"]);
[dict release];
}
@@ -2505,75 +2524,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const double kValues[] = { 600., 601., 602., 603. };
GPBStringDoubleDictionary *dict =
- [[GPBStringDoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringDoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
double value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"foo"]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"bar"]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"baz"]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"mumble"]);
XCTAssertEqual(value, 603.);
- [dict setValue:603. forKey:@"foo"];
+ [dict setDouble:603. forKey:@"foo"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"foo"]);
XCTAssertEqual(value, 603.);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"bar"]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"baz"]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"mumble"]);
XCTAssertEqual(value, 603.);
- [dict setValue:601. forKey:@"mumble"];
+ [dict setDouble:601. forKey:@"mumble"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"foo"]);
XCTAssertEqual(value, 603.);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"bar"]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"baz"]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"mumble"]);
XCTAssertEqual(value, 601.);
const NSString *kKeys2[] = { @"bar", @"baz" };
const double kValues2[] = { 602., 600. };
GPBStringDoubleDictionary *dict2 =
- [[GPBStringDoubleDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBStringDoubleDictionary alloc] initWithDoubles:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"foo"]);
XCTAssertEqual(value, 603.);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"bar"]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"baz"]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getDouble:&value forKey:@"mumble"]);
XCTAssertEqual(value, 601.);
[dict2 release];
@@ -2593,8 +2612,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBStringEnumDictionary *dict = [[GPBStringEnumDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getEnum:NULL forKey:@"foo"]);
+ [dict enumerateKeysAndEnumsUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -2602,46 +2621,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBStringEnumDictionary *dict = [GPBStringEnumDictionary dictionaryWithValue:700 forKey:@"foo"];
+ GPBStringEnumDictionary *dict = [[GPBStringEnumDictionary alloc] init];
+ [dict setEnum:700 forKey:@"foo"];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"foo"]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getEnum:NULL forKey:@"bar"]);
+ [dict enumerateKeysAndEnumsUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
XCTAssertEqualObjects(aKey, @"foo");
XCTAssertEqual(aValue, 700);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const NSString *kKeys[] = { @"foo", @"bar", @"baz" };
const int32_t kValues[] = { 700, 701, 702 };
GPBStringEnumDictionary *dict =
- [[GPBStringEnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringEnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"foo"]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"bar"]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"mumble"]);
__block NSUInteger idx = 0;
NSString **seenKeys = malloc(3 * sizeof(NSString*));
int32_t *seenValues = malloc(3 * sizeof(int32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndEnumsUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -2663,7 +2684,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndEnumsUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -2679,29 +2700,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kValues2[] = { 700, 703, 702 };
const int32_t kValues3[] = { 700, 701, 702, 703 };
GPBStringEnumDictionary *dict1 =
- [[GPBStringEnumDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBStringEnumDictionary alloc] initWithEnums:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBStringEnumDictionary *dict1prime =
- [[GPBStringEnumDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBStringEnumDictionary alloc] initWithEnums:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBStringEnumDictionary *dict2 =
- [[GPBStringEnumDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBStringEnumDictionary alloc] initWithEnums:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBStringEnumDictionary *dict3 =
- [[GPBStringEnumDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBStringEnumDictionary alloc] initWithEnums:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBStringEnumDictionary *dict4 =
- [[GPBStringEnumDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBStringEnumDictionary alloc] initWithEnums:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -2730,9 +2751,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBStringEnumDictionary *dict =
- [[GPBStringEnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringEnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBStringEnumDictionary *dict2 = [dict copy];
@@ -2751,110 +2772,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBStringEnumDictionary *dict =
- [[GPBStringEnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringEnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBStringEnumDictionary *dict2 =
- [GPBStringEnumDictionary dictionaryWithDictionary:dict];
+ [[GPBStringEnumDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBStringEnumDictionary *dict = [GPBStringEnumDictionary dictionary];
+ GPBStringEnumDictionary *dict = [[GPBStringEnumDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:700 forKey:@"foo"];
+ [dict setEnum:700 forKey:@"foo"];
XCTAssertEqual(dict.count, 1U);
const NSString *kKeys[] = { @"bar", @"baz", @"mumble" };
const int32_t kValues[] = { 701, 702, 703 };
GPBStringEnumDictionary *dict2 =
- [[GPBStringEnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringEnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"foo"]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"bar"]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"mumble"]);
XCTAssertEqual(value, 703);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBStringEnumDictionary *dict =
- [[GPBStringEnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringEnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:@"bar"];
+ [dict removeEnumForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"foo"]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"mumble"]);
XCTAssertEqual(value, 703);
// Remove again does nothing.
- [dict removeValueForKey:@"bar"];
+ [dict removeEnumForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"foo"]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"mumble"]);
XCTAssertEqual(value, 703);
- [dict removeValueForKey:@"mumble"];
+ [dict removeEnumForKey:@"mumble"];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"foo"]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"mumble"]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"baz" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"mumble"]);
[dict release];
}
@@ -2862,75 +2885,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"bar", @"baz", @"mumble" };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBStringEnumDictionary *dict =
- [[GPBStringEnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringEnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"foo"]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"bar"]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"mumble"]);
XCTAssertEqual(value, 703);
- [dict setValue:703 forKey:@"foo"];
+ [dict setEnum:703 forKey:@"foo"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"foo"]);
XCTAssertEqual(value, 703);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"bar"]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"mumble"]);
XCTAssertEqual(value, 703);
- [dict setValue:701 forKey:@"mumble"];
+ [dict setEnum:701 forKey:@"mumble"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"foo"]);
XCTAssertEqual(value, 703);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"bar"]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"mumble"]);
XCTAssertEqual(value, 701);
const NSString *kKeys2[] = { @"bar", @"baz" };
const int32_t kValues2[] = { 702, 700 };
GPBStringEnumDictionary *dict2 =
- [[GPBStringEnumDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBStringEnumDictionary alloc] initWithEnums:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"foo"]);
XCTAssertEqual(value, 703);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"bar"]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"mumble"]);
XCTAssertEqual(value, 701);
[dict2 release];
@@ -2958,24 +2981,24 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 3U);
XCTAssertTrue(dict.validationFunc == TestingEnum_IsValidValue); // Pointer comparison
int32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"foo"]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"bar"]);
XCTAssertEqual(value, kGPBUnrecognizedEnumeratorValue);
- XCTAssertTrue([dict valueForKey:@"bar" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"bar"]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:@"baz" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:@"mumble" rawValue:NULL]);
+ XCTAssertFalse([dict getRawValue:NULL forKey:@"mumble"]);
__block NSUInteger idx = 0;
NSString **seenKeys = malloc(3 * sizeof(NSString*));
int32_t *seenValues = malloc(3 * sizeof(int32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndEnumsUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -3120,23 +3143,24 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBStringEnumDictionary *dict2 =
- [GPBStringEnumDictionary dictionaryWithDictionary:dict];
+ [[GPBStringEnumDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
XCTAssertEqual(dict.validationFunc, dict2.validationFunc); // Pointer comparison
+ [dict2 release];
[dict release];
}
- (void)testUnknownAdds {
GPBStringEnumDictionary *dict =
- [GPBStringEnumDictionary dictionaryWithValidationFunction:TestingEnum_IsValidValue];
+ [[GPBStringEnumDictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertThrowsSpecificNamed([dict setValue:801 forKey:@"bar"], // Unknown
+ XCTAssertThrowsSpecificNamed([dict setEnum:801 forKey:@"bar"], // Unknown
NSException, NSInvalidArgumentException);
XCTAssertEqual(dict.count, 0U);
[dict setRawValue:801 forKey:@"bar"]; // Unknown
@@ -3145,33 +3169,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const NSString *kKeys[] = { @"foo", @"baz", @"mumble" };
const int32_t kValues[] = { 700, 702, 803 }; // Unknown
GPBStringEnumDictionary *dict2 =
- [[GPBStringEnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBStringEnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"foo"]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"bar"]);
XCTAssertEqual(value, kGPBUnrecognizedEnumeratorValue);
- XCTAssertTrue([dict valueForKey:@"bar" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"bar"]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"mumble"]);
XCTAssertEqual(value, kGPBUnrecognizedEnumeratorValue);
- XCTAssertTrue([dict valueForKey:@"mumble" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"mumble"]);
XCTAssertEqual(value, 803);
[dict2 release];
+ [dict release];
}
- (void)testUnknownRemove {
@@ -3185,51 +3210,51 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:@"bar"];
+ [dict removeEnumForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"foo"]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:@"mumble" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"mumble"]);
XCTAssertEqual(value, 803);
// Remove again does nothing.
- [dict removeValueForKey:@"bar"];
+ [dict removeEnumForKey:@"bar"];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"foo"]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:@"mumble" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"mumble"]);
XCTAssertEqual(value, 803);
- [dict removeValueForKey:@"mumble"];
+ [dict removeEnumForKey:@"mumble"];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"foo"]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"mumble"]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:@"foo" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"bar" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"baz" value:NULL]);
- XCTAssertFalse([dict valueForKey:@"mumble" value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertFalse([dict getEnum:NULL forKey:@"mumble"]);
[dict release];
}
@@ -3244,63 +3269,63 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"foo"]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:@"bar" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"bar"]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:@"mumble" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"mumble"]);
XCTAssertEqual(value, 803);
- XCTAssertThrowsSpecificNamed([dict setValue:803 forKey:@"foo"], // Unknown
+ XCTAssertThrowsSpecificNamed([dict setEnum:803 forKey:@"foo"], // Unknown
NSException, NSInvalidArgumentException);
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"foo"]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:@"bar" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"bar"]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:@"mumble" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"mumble"]);
XCTAssertEqual(value, 803);
[dict setRawValue:803 forKey:@"foo"]; // Unknown
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"foo"]);
XCTAssertEqual(value, 803);
- XCTAssertTrue([dict valueForKey:@"bar" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"bar"]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:@"mumble" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"mumble"]);
XCTAssertEqual(value, 803);
[dict setRawValue:700 forKey:@"mumble"];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"foo"]);
XCTAssertEqual(value, 803);
- XCTAssertTrue([dict valueForKey:@"bar" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"bar"]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:@"baz" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"baz"]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"mumble"]);
XCTAssertEqual(value, 700);
const NSString *kKeys2[] = { @"bar", @"baz" };
@@ -3313,17 +3338,17 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:@"foo" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"foo" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"foo"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"foo"]);
XCTAssertEqual(value, 803);
- XCTAssertTrue([dict valueForKey:@"bar" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"bar" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"bar"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"bar"]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:@"baz" rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:@"baz" rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:@"baz"]);
+ XCTAssertTrue([dict getRawValue:&value forKey:@"baz"]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:@"mumble" value:NULL]);
- XCTAssertTrue([dict valueForKey:@"mumble" value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:@"mumble"]);
+ XCTAssertTrue([dict getEnum:&value forKey:@"mumble"]);
XCTAssertEqual(value, 700);
[dict2 release];
diff --git a/objectivec/Tests/GPBDictionaryTests+UInt32.m b/objectivec/Tests/GPBDictionaryTests+UInt32.m
index c7c57652..5314c58a 100644
--- a/objectivec/Tests/GPBDictionaryTests+UInt32.m
+++ b/objectivec/Tests/GPBDictionaryTests+UInt32.m
@@ -45,10 +45,9 @@
// To let the testing macros work, add some extra methods to simplify things.
@interface GPBUInt32EnumDictionary (TestingTweak)
-+ (instancetype)dictionaryWithValue:(int32_t)value forKey:(uint32_t)key;
-- (instancetype)initWithValues:(const int32_t [])values
- forKeys:(const uint32_t [])keys
- count:(NSUInteger)count;
+- (instancetype)initWithEnums:(const int32_t [])values
+ forKeys:(const uint32_t [])keys
+ count:(NSUInteger)count;
@end
static BOOL TestingEnum_IsValidValue(int32_t value) {
@@ -64,17 +63,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
@implementation GPBUInt32EnumDictionary (TestingTweak)
-+ (instancetype)dictionaryWithValue:(int32_t)value forKey:(uint32_t)key {
- // Cast is needed to compiler knows what class we are invoking initWithValues: on to get the
- // type correct.
- return [[(GPBUInt32EnumDictionary*)[self alloc] initWithValidationFunction:TestingEnum_IsValidValue
- rawValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-- (instancetype)initWithValues:(const int32_t [])values
- forKeys:(const uint32_t [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithEnums:(const int32_t [])values
+ forKeys:(const uint32_t [])keys
+ count:(NSUInteger)count {
return [self initWithValidationFunction:TestingEnum_IsValidValue
rawValues:values
forKeys:keys
@@ -94,8 +85,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBUInt32UInt32Dictionary *dict = [[GPBUInt32UInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, uint32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt32:NULL forKey:1U]);
+ [dict enumerateKeysAndUInt32sUsingBlock:^(uint32_t aKey, uint32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -103,46 +94,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt32UInt32Dictionary *dict = [GPBUInt32UInt32Dictionary dictionaryWithValue:100U forKey:1U];
+ GPBUInt32UInt32Dictionary *dict = [[GPBUInt32UInt32Dictionary alloc] init];
+ [dict setUInt32:100U forKey:1U];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:1U]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, uint32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt32:NULL forKey:2U]);
+ [dict enumerateKeysAndUInt32sUsingBlock:^(uint32_t aKey, uint32_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 1U);
XCTAssertEqual(aValue, 100U);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint32_t kKeys[] = { 1U, 2U, 3U };
const uint32_t kValues[] = { 100U, 101U, 102U };
GPBUInt32UInt32Dictionary *dict =
- [[GPBUInt32UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:1U]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:2U]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:3U]);
XCTAssertEqual(value, 102U);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:4U]);
__block NSUInteger idx = 0;
uint32_t *seenKeys = malloc(3 * sizeof(uint32_t));
uint32_t *seenValues = malloc(3 * sizeof(uint32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, uint32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt32sUsingBlock:^(uint32_t aKey, uint32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -164,7 +157,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, uint32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt32sUsingBlock:^(uint32_t aKey, uint32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -180,29 +173,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kValues2[] = { 100U, 103U, 102U };
const uint32_t kValues3[] = { 100U, 101U, 102U, 103U };
GPBUInt32UInt32Dictionary *dict1 =
- [[GPBUInt32UInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt32UInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBUInt32UInt32Dictionary *dict1prime =
- [[GPBUInt32UInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt32UInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBUInt32UInt32Dictionary *dict2 =
- [[GPBUInt32UInt32Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt32UInt32Dictionary alloc] initWithUInt32s:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBUInt32UInt32Dictionary *dict3 =
- [[GPBUInt32UInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt32UInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBUInt32UInt32Dictionary *dict4 =
- [[GPBUInt32UInt32Dictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBUInt32UInt32Dictionary alloc] initWithUInt32s:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -231,9 +224,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBUInt32UInt32Dictionary *dict =
- [[GPBUInt32UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt32UInt32Dictionary *dict2 = [dict copy];
@@ -252,110 +245,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBUInt32UInt32Dictionary *dict =
- [[GPBUInt32UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt32UInt32Dictionary *dict2 =
- [GPBUInt32UInt32Dictionary dictionaryWithDictionary:dict];
+ [[GPBUInt32UInt32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt32UInt32Dictionary *dict = [GPBUInt32UInt32Dictionary dictionary];
+ GPBUInt32UInt32Dictionary *dict = [[GPBUInt32UInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:100U forKey:1U];
+ [dict setUInt32:100U forKey:1U];
XCTAssertEqual(dict.count, 1U);
const uint32_t kKeys[] = { 2U, 3U, 4U };
const uint32_t kValues[] = { 101U, 102U, 103U };
GPBUInt32UInt32Dictionary *dict2 =
- [[GPBUInt32UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:1U]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:2U]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:3U]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:4U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:4U]);
XCTAssertEqual(value, 103U);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBUInt32UInt32Dictionary *dict =
- [[GPBUInt32UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:2U];
+ [dict removeUInt32ForKey:2U];
XCTAssertEqual(dict.count, 3U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:1U]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:3U]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:4U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:4U]);
XCTAssertEqual(value, 103U);
// Remove again does nothing.
- [dict removeValueForKey:2U];
+ [dict removeUInt32ForKey:2U];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:1U]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:3U]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:4U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:4U]);
XCTAssertEqual(value, 103U);
- [dict removeValueForKey:4U];
+ [dict removeUInt32ForKey:4U];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:1U]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:3U]);
XCTAssertEqual(value, 102U);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:4U]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertFalse([dict valueForKey:3U value:NULL]);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:1U]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:2U]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:3U]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:4U]);
[dict release];
}
@@ -363,75 +358,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBUInt32UInt32Dictionary *dict =
- [[GPBUInt32UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:1U]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:2U]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:3U]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:4U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:4U]);
XCTAssertEqual(value, 103U);
- [dict setValue:103U forKey:1U];
+ [dict setUInt32:103U forKey:1U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:1U]);
XCTAssertEqual(value, 103U);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:2U]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:3U]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:4U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:4U]);
XCTAssertEqual(value, 103U);
- [dict setValue:101U forKey:4U];
+ [dict setUInt32:101U forKey:4U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:1U]);
XCTAssertEqual(value, 103U);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:2U]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:3U]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:4U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:4U]);
XCTAssertEqual(value, 101U);
const uint32_t kKeys2[] = { 2U, 3U };
const uint32_t kValues2[] = { 102U, 100U };
GPBUInt32UInt32Dictionary *dict2 =
- [[GPBUInt32UInt32Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt32UInt32Dictionary alloc] initWithUInt32s:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:1U]);
XCTAssertEqual(value, 103U);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:2U]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:3U]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:4U]);
+ XCTAssertTrue([dict getUInt32:&value forKey:4U]);
XCTAssertEqual(value, 101U);
[dict2 release];
@@ -451,8 +446,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBUInt32Int32Dictionary *dict = [[GPBUInt32Int32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt32:NULL forKey:1U]);
+ [dict enumerateKeysAndInt32sUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -460,46 +455,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt32Int32Dictionary *dict = [GPBUInt32Int32Dictionary dictionaryWithValue:200 forKey:1U];
+ GPBUInt32Int32Dictionary *dict = [[GPBUInt32Int32Dictionary alloc] init];
+ [dict setInt32:200 forKey:1U];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt32:&value forKey:1U]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt32:NULL forKey:2U]);
+ [dict enumerateKeysAndInt32sUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 1U);
XCTAssertEqual(aValue, 200);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint32_t kKeys[] = { 1U, 2U, 3U };
const int32_t kValues[] = { 200, 201, 202 };
GPBUInt32Int32Dictionary *dict =
- [[GPBUInt32Int32Dictionary alloc] initWithValues:kValues
+ [[GPBUInt32Int32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt32:&value forKey:1U]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt32:&value forKey:2U]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt32:&value forKey:3U]);
XCTAssertEqual(value, 202);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:4U]);
__block NSUInteger idx = 0;
uint32_t *seenKeys = malloc(3 * sizeof(uint32_t));
int32_t *seenValues = malloc(3 * sizeof(int32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt32sUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -521,7 +518,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt32sUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -537,27 +534,27 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kValues2[] = { 200, 203, 202 };
const int32_t kValues3[] = { 200, 201, 202, 203 };
GPBUInt32Int32Dictionary *dict1 =
- [[GPBUInt32Int32Dictionary alloc] initWithValues:kValues1
+ [[GPBUInt32Int32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBUInt32Int32Dictionary *dict1prime =
- [[GPBUInt32Int32Dictionary alloc] initWithValues:kValues1
+ [[GPBUInt32Int32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBUInt32Int32Dictionary *dict2 =
- [[GPBUInt32Int32Dictionary alloc] initWithValues:kValues2
+ [[GPBUInt32Int32Dictionary alloc] initWithInt32s:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBUInt32Int32Dictionary *dict3 =
- [[GPBUInt32Int32Dictionary alloc] initWithValues:kValues1
+ [[GPBUInt32Int32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBUInt32Int32Dictionary *dict4 =
- [[GPBUInt32Int32Dictionary alloc] initWithValues:kValues3
+ [[GPBUInt32Int32Dictionary alloc] initWithInt32s:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -588,7 +585,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBUInt32Int32Dictionary *dict =
- [[GPBUInt32Int32Dictionary alloc] initWithValues:kValues
+ [[GPBUInt32Int32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -609,33 +606,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBUInt32Int32Dictionary *dict =
- [[GPBUInt32Int32Dictionary alloc] initWithValues:kValues
+ [[GPBUInt32Int32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt32Int32Dictionary *dict2 =
- [GPBUInt32Int32Dictionary dictionaryWithDictionary:dict];
+ [[GPBUInt32Int32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt32Int32Dictionary *dict = [GPBUInt32Int32Dictionary dictionary];
+ GPBUInt32Int32Dictionary *dict = [[GPBUInt32Int32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:200 forKey:1U];
+ [dict setInt32:200 forKey:1U];
XCTAssertEqual(dict.count, 1U);
const uint32_t kKeys[] = { 2U, 3U, 4U };
const int32_t kValues[] = { 201, 202, 203 };
GPBUInt32Int32Dictionary *dict2 =
- [[GPBUInt32Int32Dictionary alloc] initWithValues:kValues
+ [[GPBUInt32Int32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -643,76 +641,77 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt32:&value forKey:1U]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt32:&value forKey:2U]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt32:&value forKey:3U]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:4U]);
+ XCTAssertTrue([dict getInt32:&value forKey:4U]);
XCTAssertEqual(value, 203);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBUInt32Int32Dictionary *dict =
- [[GPBUInt32Int32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32Int32Dictionary alloc] initWithInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:2U];
+ [dict removeInt32ForKey:2U];
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt32:&value forKey:1U]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt32:&value forKey:3U]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:4U]);
+ XCTAssertTrue([dict getInt32:&value forKey:4U]);
XCTAssertEqual(value, 203);
// Remove again does nothing.
- [dict removeValueForKey:2U];
+ [dict removeInt32ForKey:2U];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt32:&value forKey:1U]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt32:&value forKey:3U]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:4U]);
+ XCTAssertTrue([dict getInt32:&value forKey:4U]);
XCTAssertEqual(value, 203);
- [dict removeValueForKey:4U];
+ [dict removeInt32ForKey:4U];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt32:&value forKey:1U]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt32:&value forKey:3U]);
XCTAssertEqual(value, 202);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:4U]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertFalse([dict valueForKey:3U value:NULL]);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:1U]);
+ XCTAssertFalse([dict getInt32:NULL forKey:2U]);
+ XCTAssertFalse([dict getInt32:NULL forKey:3U]);
+ XCTAssertFalse([dict getInt32:NULL forKey:4U]);
[dict release];
}
@@ -720,75 +719,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBUInt32Int32Dictionary *dict =
- [[GPBUInt32Int32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32Int32Dictionary alloc] initWithInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt32:&value forKey:1U]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt32:&value forKey:2U]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt32:&value forKey:3U]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:4U]);
+ XCTAssertTrue([dict getInt32:&value forKey:4U]);
XCTAssertEqual(value, 203);
- [dict setValue:203 forKey:1U];
+ [dict setInt32:203 forKey:1U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt32:&value forKey:1U]);
XCTAssertEqual(value, 203);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt32:&value forKey:2U]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt32:&value forKey:3U]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:4U]);
+ XCTAssertTrue([dict getInt32:&value forKey:4U]);
XCTAssertEqual(value, 203);
- [dict setValue:201 forKey:4U];
+ [dict setInt32:201 forKey:4U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt32:&value forKey:1U]);
XCTAssertEqual(value, 203);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt32:&value forKey:2U]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt32:&value forKey:3U]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:4U]);
+ XCTAssertTrue([dict getInt32:&value forKey:4U]);
XCTAssertEqual(value, 201);
const uint32_t kKeys2[] = { 2U, 3U };
const int32_t kValues2[] = { 202, 200 };
GPBUInt32Int32Dictionary *dict2 =
- [[GPBUInt32Int32Dictionary alloc] initWithValues:kValues2
+ [[GPBUInt32Int32Dictionary alloc] initWithInt32s:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt32:&value forKey:1U]);
XCTAssertEqual(value, 203);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt32:&value forKey:2U]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt32:&value forKey:3U]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:4U]);
+ XCTAssertTrue([dict getInt32:&value forKey:4U]);
XCTAssertEqual(value, 201);
[dict2 release];
@@ -808,8 +807,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBUInt32UInt64Dictionary *dict = [[GPBUInt32UInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, uint64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt64:NULL forKey:1U]);
+ [dict enumerateKeysAndUInt64sUsingBlock:^(uint32_t aKey, uint64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -817,46 +816,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt32UInt64Dictionary *dict = [GPBUInt32UInt64Dictionary dictionaryWithValue:300U forKey:1U];
+ GPBUInt32UInt64Dictionary *dict = [[GPBUInt32UInt64Dictionary alloc] init];
+ [dict setUInt64:300U forKey:1U];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:1U]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, uint64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt64:NULL forKey:2U]);
+ [dict enumerateKeysAndUInt64sUsingBlock:^(uint32_t aKey, uint64_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 1U);
XCTAssertEqual(aValue, 300U);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint32_t kKeys[] = { 1U, 2U, 3U };
const uint64_t kValues[] = { 300U, 301U, 302U };
GPBUInt32UInt64Dictionary *dict =
- [[GPBUInt32UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:1U]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:2U]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:3U]);
XCTAssertEqual(value, 302U);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:4U]);
__block NSUInteger idx = 0;
uint32_t *seenKeys = malloc(3 * sizeof(uint32_t));
uint64_t *seenValues = malloc(3 * sizeof(uint64_t));
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, uint64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt64sUsingBlock:^(uint32_t aKey, uint64_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -878,7 +879,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, uint64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt64sUsingBlock:^(uint32_t aKey, uint64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -894,29 +895,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kValues2[] = { 300U, 303U, 302U };
const uint64_t kValues3[] = { 300U, 301U, 302U, 303U };
GPBUInt32UInt64Dictionary *dict1 =
- [[GPBUInt32UInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt32UInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBUInt32UInt64Dictionary *dict1prime =
- [[GPBUInt32UInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt32UInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBUInt32UInt64Dictionary *dict2 =
- [[GPBUInt32UInt64Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt32UInt64Dictionary alloc] initWithUInt64s:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBUInt32UInt64Dictionary *dict3 =
- [[GPBUInt32UInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt32UInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBUInt32UInt64Dictionary *dict4 =
- [[GPBUInt32UInt64Dictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBUInt32UInt64Dictionary alloc] initWithUInt64s:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -945,9 +946,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBUInt32UInt64Dictionary *dict =
- [[GPBUInt32UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt32UInt64Dictionary *dict2 = [dict copy];
@@ -966,110 +967,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBUInt32UInt64Dictionary *dict =
- [[GPBUInt32UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt32UInt64Dictionary *dict2 =
- [GPBUInt32UInt64Dictionary dictionaryWithDictionary:dict];
+ [[GPBUInt32UInt64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt32UInt64Dictionary *dict = [GPBUInt32UInt64Dictionary dictionary];
+ GPBUInt32UInt64Dictionary *dict = [[GPBUInt32UInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:300U forKey:1U];
+ [dict setUInt64:300U forKey:1U];
XCTAssertEqual(dict.count, 1U);
const uint32_t kKeys[] = { 2U, 3U, 4U };
const uint64_t kValues[] = { 301U, 302U, 303U };
GPBUInt32UInt64Dictionary *dict2 =
- [[GPBUInt32UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:1U]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:2U]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:3U]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:4U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:4U]);
XCTAssertEqual(value, 303U);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBUInt32UInt64Dictionary *dict =
- [[GPBUInt32UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:2U];
+ [dict removeUInt64ForKey:2U];
XCTAssertEqual(dict.count, 3U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:1U]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:3U]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:4U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:4U]);
XCTAssertEqual(value, 303U);
// Remove again does nothing.
- [dict removeValueForKey:2U];
+ [dict removeUInt64ForKey:2U];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:1U]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:3U]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:4U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:4U]);
XCTAssertEqual(value, 303U);
- [dict removeValueForKey:4U];
+ [dict removeUInt64ForKey:4U];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:1U]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:3U]);
XCTAssertEqual(value, 302U);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:4U]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertFalse([dict valueForKey:3U value:NULL]);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:1U]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:2U]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:3U]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:4U]);
[dict release];
}
@@ -1077,75 +1080,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBUInt32UInt64Dictionary *dict =
- [[GPBUInt32UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:1U]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:2U]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:3U]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:4U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:4U]);
XCTAssertEqual(value, 303U);
- [dict setValue:303U forKey:1U];
+ [dict setUInt64:303U forKey:1U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:1U]);
XCTAssertEqual(value, 303U);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:2U]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:3U]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:4U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:4U]);
XCTAssertEqual(value, 303U);
- [dict setValue:301U forKey:4U];
+ [dict setUInt64:301U forKey:4U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:1U]);
XCTAssertEqual(value, 303U);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:2U]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:3U]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:4U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:4U]);
XCTAssertEqual(value, 301U);
const uint32_t kKeys2[] = { 2U, 3U };
const uint64_t kValues2[] = { 302U, 300U };
GPBUInt32UInt64Dictionary *dict2 =
- [[GPBUInt32UInt64Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt32UInt64Dictionary alloc] initWithUInt64s:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:1U]);
XCTAssertEqual(value, 303U);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:2U]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:3U]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:4U]);
+ XCTAssertTrue([dict getUInt64:&value forKey:4U]);
XCTAssertEqual(value, 301U);
[dict2 release];
@@ -1165,8 +1168,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBUInt32Int64Dictionary *dict = [[GPBUInt32Int64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, int64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt64:NULL forKey:1U]);
+ [dict enumerateKeysAndInt64sUsingBlock:^(uint32_t aKey, int64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1174,46 +1177,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt32Int64Dictionary *dict = [GPBUInt32Int64Dictionary dictionaryWithValue:400 forKey:1U];
+ GPBUInt32Int64Dictionary *dict = [[GPBUInt32Int64Dictionary alloc] init];
+ [dict setInt64:400 forKey:1U];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int64_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt64:&value forKey:1U]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, int64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt64:NULL forKey:2U]);
+ [dict enumerateKeysAndInt64sUsingBlock:^(uint32_t aKey, int64_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 1U);
XCTAssertEqual(aValue, 400);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint32_t kKeys[] = { 1U, 2U, 3U };
const int64_t kValues[] = { 400, 401, 402 };
GPBUInt32Int64Dictionary *dict =
- [[GPBUInt32Int64Dictionary alloc] initWithValues:kValues
+ [[GPBUInt32Int64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
int64_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt64:&value forKey:1U]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt64:&value forKey:2U]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt64:&value forKey:3U]);
XCTAssertEqual(value, 402);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:4U]);
__block NSUInteger idx = 0;
uint32_t *seenKeys = malloc(3 * sizeof(uint32_t));
int64_t *seenValues = malloc(3 * sizeof(int64_t));
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, int64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt64sUsingBlock:^(uint32_t aKey, int64_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1235,7 +1240,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, int64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt64sUsingBlock:^(uint32_t aKey, int64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1251,27 +1256,27 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kValues2[] = { 400, 403, 402 };
const int64_t kValues3[] = { 400, 401, 402, 403 };
GPBUInt32Int64Dictionary *dict1 =
- [[GPBUInt32Int64Dictionary alloc] initWithValues:kValues1
+ [[GPBUInt32Int64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBUInt32Int64Dictionary *dict1prime =
- [[GPBUInt32Int64Dictionary alloc] initWithValues:kValues1
+ [[GPBUInt32Int64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBUInt32Int64Dictionary *dict2 =
- [[GPBUInt32Int64Dictionary alloc] initWithValues:kValues2
+ [[GPBUInt32Int64Dictionary alloc] initWithInt64s:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBUInt32Int64Dictionary *dict3 =
- [[GPBUInt32Int64Dictionary alloc] initWithValues:kValues1
+ [[GPBUInt32Int64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBUInt32Int64Dictionary *dict4 =
- [[GPBUInt32Int64Dictionary alloc] initWithValues:kValues3
+ [[GPBUInt32Int64Dictionary alloc] initWithInt64s:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -1302,7 +1307,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBUInt32Int64Dictionary *dict =
- [[GPBUInt32Int64Dictionary alloc] initWithValues:kValues
+ [[GPBUInt32Int64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -1323,33 +1328,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBUInt32Int64Dictionary *dict =
- [[GPBUInt32Int64Dictionary alloc] initWithValues:kValues
+ [[GPBUInt32Int64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt32Int64Dictionary *dict2 =
- [GPBUInt32Int64Dictionary dictionaryWithDictionary:dict];
+ [[GPBUInt32Int64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt32Int64Dictionary *dict = [GPBUInt32Int64Dictionary dictionary];
+ GPBUInt32Int64Dictionary *dict = [[GPBUInt32Int64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:400 forKey:1U];
+ [dict setInt64:400 forKey:1U];
XCTAssertEqual(dict.count, 1U);
const uint32_t kKeys[] = { 2U, 3U, 4U };
const int64_t kValues[] = { 401, 402, 403 };
GPBUInt32Int64Dictionary *dict2 =
- [[GPBUInt32Int64Dictionary alloc] initWithValues:kValues
+ [[GPBUInt32Int64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -1357,76 +1363,77 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 4U);
int64_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt64:&value forKey:1U]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt64:&value forKey:2U]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt64:&value forKey:3U]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:4U]);
+ XCTAssertTrue([dict getInt64:&value forKey:4U]);
XCTAssertEqual(value, 403);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBUInt32Int64Dictionary *dict =
- [[GPBUInt32Int64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32Int64Dictionary alloc] initWithInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:2U];
+ [dict removeInt64ForKey:2U];
XCTAssertEqual(dict.count, 3U);
int64_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt64:&value forKey:1U]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt64:&value forKey:3U]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:4U]);
+ XCTAssertTrue([dict getInt64:&value forKey:4U]);
XCTAssertEqual(value, 403);
// Remove again does nothing.
- [dict removeValueForKey:2U];
+ [dict removeInt64ForKey:2U];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt64:&value forKey:1U]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt64:&value forKey:3U]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:4U]);
+ XCTAssertTrue([dict getInt64:&value forKey:4U]);
XCTAssertEqual(value, 403);
- [dict removeValueForKey:4U];
+ [dict removeInt64ForKey:4U];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt64:&value forKey:1U]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt64:&value forKey:3U]);
XCTAssertEqual(value, 402);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:4U]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertFalse([dict valueForKey:3U value:NULL]);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:1U]);
+ XCTAssertFalse([dict getInt64:NULL forKey:2U]);
+ XCTAssertFalse([dict getInt64:NULL forKey:3U]);
+ XCTAssertFalse([dict getInt64:NULL forKey:4U]);
[dict release];
}
@@ -1434,75 +1441,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBUInt32Int64Dictionary *dict =
- [[GPBUInt32Int64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32Int64Dictionary alloc] initWithInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int64_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt64:&value forKey:1U]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt64:&value forKey:2U]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt64:&value forKey:3U]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:4U]);
+ XCTAssertTrue([dict getInt64:&value forKey:4U]);
XCTAssertEqual(value, 403);
- [dict setValue:403 forKey:1U];
+ [dict setInt64:403 forKey:1U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt64:&value forKey:1U]);
XCTAssertEqual(value, 403);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt64:&value forKey:2U]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt64:&value forKey:3U]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:4U]);
+ XCTAssertTrue([dict getInt64:&value forKey:4U]);
XCTAssertEqual(value, 403);
- [dict setValue:401 forKey:4U];
+ [dict setInt64:401 forKey:4U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt64:&value forKey:1U]);
XCTAssertEqual(value, 403);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt64:&value forKey:2U]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt64:&value forKey:3U]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:4U]);
+ XCTAssertTrue([dict getInt64:&value forKey:4U]);
XCTAssertEqual(value, 401);
const uint32_t kKeys2[] = { 2U, 3U };
const int64_t kValues2[] = { 402, 400 };
GPBUInt32Int64Dictionary *dict2 =
- [[GPBUInt32Int64Dictionary alloc] initWithValues:kValues2
+ [[GPBUInt32Int64Dictionary alloc] initWithInt64s:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:1U]);
+ XCTAssertTrue([dict getInt64:&value forKey:1U]);
XCTAssertEqual(value, 403);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:2U]);
+ XCTAssertTrue([dict getInt64:&value forKey:2U]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:3U]);
+ XCTAssertTrue([dict getInt64:&value forKey:3U]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:4U]);
+ XCTAssertTrue([dict getInt64:&value forKey:4U]);
XCTAssertEqual(value, 401);
[dict2 release];
@@ -1522,8 +1529,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBUInt32BoolDictionary *dict = [[GPBUInt32BoolDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, BOOL aValue, BOOL *stop) {
+ XCTAssertFalse([dict getBool:NULL forKey:1U]);
+ [dict enumerateKeysAndBoolsUsingBlock:^(uint32_t aKey, BOOL aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1531,46 +1538,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt32BoolDictionary *dict = [GPBUInt32BoolDictionary dictionaryWithValue:YES forKey:1U];
+ GPBUInt32BoolDictionary *dict = [[GPBUInt32BoolDictionary alloc] init];
+ [dict setBool:YES forKey:1U];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
BOOL value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:1U]);
+ XCTAssertTrue([dict getBool:&value forKey:1U]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, BOOL aValue, BOOL *stop) {
+ XCTAssertFalse([dict getBool:NULL forKey:2U]);
+ [dict enumerateKeysAndBoolsUsingBlock:^(uint32_t aKey, BOOL aValue, BOOL *stop) {
XCTAssertEqual(aKey, 1U);
XCTAssertEqual(aValue, YES);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint32_t kKeys[] = { 1U, 2U, 3U };
const BOOL kValues[] = { YES, YES, NO };
GPBUInt32BoolDictionary *dict =
- [[GPBUInt32BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
BOOL value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:1U]);
+ XCTAssertTrue([dict getBool:&value forKey:1U]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:2U]);
+ XCTAssertTrue([dict getBool:&value forKey:2U]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:3U]);
+ XCTAssertTrue([dict getBool:&value forKey:3U]);
XCTAssertEqual(value, NO);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:4U]);
__block NSUInteger idx = 0;
uint32_t *seenKeys = malloc(3 * sizeof(uint32_t));
BOOL *seenValues = malloc(3 * sizeof(BOOL));
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, BOOL aValue, BOOL *stop) {
+ [dict enumerateKeysAndBoolsUsingBlock:^(uint32_t aKey, BOOL aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1592,7 +1601,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, BOOL aValue, BOOL *stop) {
+ [dict enumerateKeysAndBoolsUsingBlock:^(uint32_t aKey, BOOL aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1608,29 +1617,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const BOOL kValues2[] = { YES, NO, NO };
const BOOL kValues3[] = { YES, YES, NO, NO };
GPBUInt32BoolDictionary *dict1 =
- [[GPBUInt32BoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt32BoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBUInt32BoolDictionary *dict1prime =
- [[GPBUInt32BoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt32BoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBUInt32BoolDictionary *dict2 =
- [[GPBUInt32BoolDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt32BoolDictionary alloc] initWithBools:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBUInt32BoolDictionary *dict3 =
- [[GPBUInt32BoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt32BoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBUInt32BoolDictionary *dict4 =
- [[GPBUInt32BoolDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBUInt32BoolDictionary alloc] initWithBools:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -1659,9 +1668,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBUInt32BoolDictionary *dict =
- [[GPBUInt32BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt32BoolDictionary *dict2 = [dict copy];
@@ -1680,110 +1689,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBUInt32BoolDictionary *dict =
- [[GPBUInt32BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt32BoolDictionary *dict2 =
- [GPBUInt32BoolDictionary dictionaryWithDictionary:dict];
+ [[GPBUInt32BoolDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt32BoolDictionary *dict = [GPBUInt32BoolDictionary dictionary];
+ GPBUInt32BoolDictionary *dict = [[GPBUInt32BoolDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:YES forKey:1U];
+ [dict setBool:YES forKey:1U];
XCTAssertEqual(dict.count, 1U);
const uint32_t kKeys[] = { 2U, 3U, 4U };
const BOOL kValues[] = { YES, NO, NO };
GPBUInt32BoolDictionary *dict2 =
- [[GPBUInt32BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
BOOL value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:1U]);
+ XCTAssertTrue([dict getBool:&value forKey:1U]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:2U]);
+ XCTAssertTrue([dict getBool:&value forKey:2U]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:3U]);
+ XCTAssertTrue([dict getBool:&value forKey:3U]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:4U]);
+ XCTAssertTrue([dict getBool:&value forKey:4U]);
XCTAssertEqual(value, NO);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBUInt32BoolDictionary *dict =
- [[GPBUInt32BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:2U];
+ [dict removeBoolForKey:2U];
XCTAssertEqual(dict.count, 3U);
BOOL value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:1U]);
+ XCTAssertTrue([dict getBool:&value forKey:1U]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getBool:NULL forKey:2U]);
+ XCTAssertTrue([dict getBool:NULL forKey:3U]);
+ XCTAssertTrue([dict getBool:&value forKey:3U]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:4U]);
+ XCTAssertTrue([dict getBool:&value forKey:4U]);
XCTAssertEqual(value, NO);
// Remove again does nothing.
- [dict removeValueForKey:2U];
+ [dict removeBoolForKey:2U];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:1U]);
+ XCTAssertTrue([dict getBool:&value forKey:1U]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getBool:NULL forKey:2U]);
+ XCTAssertTrue([dict getBool:NULL forKey:3U]);
+ XCTAssertTrue([dict getBool:&value forKey:3U]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:4U]);
+ XCTAssertTrue([dict getBool:&value forKey:4U]);
XCTAssertEqual(value, NO);
- [dict removeValueForKey:4U];
+ [dict removeBoolForKey:4U];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:1U]);
+ XCTAssertTrue([dict getBool:&value forKey:1U]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getBool:NULL forKey:2U]);
+ XCTAssertTrue([dict getBool:NULL forKey:3U]);
+ XCTAssertTrue([dict getBool:&value forKey:3U]);
XCTAssertEqual(value, NO);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:4U]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertFalse([dict valueForKey:3U value:NULL]);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:1U]);
+ XCTAssertFalse([dict getBool:NULL forKey:2U]);
+ XCTAssertFalse([dict getBool:NULL forKey:3U]);
+ XCTAssertFalse([dict getBool:NULL forKey:4U]);
[dict release];
}
@@ -1791,75 +1802,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBUInt32BoolDictionary *dict =
- [[GPBUInt32BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
BOOL value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:1U]);
+ XCTAssertTrue([dict getBool:&value forKey:1U]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:2U]);
+ XCTAssertTrue([dict getBool:&value forKey:2U]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:3U]);
+ XCTAssertTrue([dict getBool:&value forKey:3U]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:4U]);
+ XCTAssertTrue([dict getBool:&value forKey:4U]);
XCTAssertEqual(value, NO);
- [dict setValue:NO forKey:1U];
+ [dict setBool:NO forKey:1U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:1U]);
+ XCTAssertTrue([dict getBool:&value forKey:1U]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:2U]);
+ XCTAssertTrue([dict getBool:&value forKey:2U]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:3U]);
+ XCTAssertTrue([dict getBool:&value forKey:3U]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:4U]);
+ XCTAssertTrue([dict getBool:&value forKey:4U]);
XCTAssertEqual(value, NO);
- [dict setValue:YES forKey:4U];
+ [dict setBool:YES forKey:4U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:1U]);
+ XCTAssertTrue([dict getBool:&value forKey:1U]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:2U]);
+ XCTAssertTrue([dict getBool:&value forKey:2U]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:3U]);
+ XCTAssertTrue([dict getBool:&value forKey:3U]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:4U]);
+ XCTAssertTrue([dict getBool:&value forKey:4U]);
XCTAssertEqual(value, YES);
const uint32_t kKeys2[] = { 2U, 3U };
const BOOL kValues2[] = { NO, YES };
GPBUInt32BoolDictionary *dict2 =
- [[GPBUInt32BoolDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt32BoolDictionary alloc] initWithBools:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:1U]);
+ XCTAssertTrue([dict getBool:&value forKey:1U]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:2U]);
+ XCTAssertTrue([dict getBool:&value forKey:2U]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:3U]);
+ XCTAssertTrue([dict getBool:&value forKey:3U]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:4U]);
+ XCTAssertTrue([dict getBool:&value forKey:4U]);
XCTAssertEqual(value, YES);
[dict2 release];
@@ -1879,8 +1890,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBUInt32FloatDictionary *dict = [[GPBUInt32FloatDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, float aValue, BOOL *stop) {
+ XCTAssertFalse([dict getFloat:NULL forKey:1U]);
+ [dict enumerateKeysAndFloatsUsingBlock:^(uint32_t aKey, float aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1888,46 +1899,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt32FloatDictionary *dict = [GPBUInt32FloatDictionary dictionaryWithValue:500.f forKey:1U];
+ GPBUInt32FloatDictionary *dict = [[GPBUInt32FloatDictionary alloc] init];
+ [dict setFloat:500.f forKey:1U];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
float value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:1U]);
+ XCTAssertTrue([dict getFloat:&value forKey:1U]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, float aValue, BOOL *stop) {
+ XCTAssertFalse([dict getFloat:NULL forKey:2U]);
+ [dict enumerateKeysAndFloatsUsingBlock:^(uint32_t aKey, float aValue, BOOL *stop) {
XCTAssertEqual(aKey, 1U);
XCTAssertEqual(aValue, 500.f);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint32_t kKeys[] = { 1U, 2U, 3U };
const float kValues[] = { 500.f, 501.f, 502.f };
GPBUInt32FloatDictionary *dict =
- [[GPBUInt32FloatDictionary alloc] initWithValues:kValues
+ [[GPBUInt32FloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
float value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:1U]);
+ XCTAssertTrue([dict getFloat:&value forKey:1U]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:2U]);
+ XCTAssertTrue([dict getFloat:&value forKey:2U]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:3U]);
+ XCTAssertTrue([dict getFloat:&value forKey:3U]);
XCTAssertEqual(value, 502.f);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:4U]);
__block NSUInteger idx = 0;
uint32_t *seenKeys = malloc(3 * sizeof(uint32_t));
float *seenValues = malloc(3 * sizeof(float));
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, float aValue, BOOL *stop) {
+ [dict enumerateKeysAndFloatsUsingBlock:^(uint32_t aKey, float aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1949,7 +1962,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, float aValue, BOOL *stop) {
+ [dict enumerateKeysAndFloatsUsingBlock:^(uint32_t aKey, float aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1965,27 +1978,27 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const float kValues2[] = { 500.f, 503.f, 502.f };
const float kValues3[] = { 500.f, 501.f, 502.f, 503.f };
GPBUInt32FloatDictionary *dict1 =
- [[GPBUInt32FloatDictionary alloc] initWithValues:kValues1
+ [[GPBUInt32FloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBUInt32FloatDictionary *dict1prime =
- [[GPBUInt32FloatDictionary alloc] initWithValues:kValues1
+ [[GPBUInt32FloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBUInt32FloatDictionary *dict2 =
- [[GPBUInt32FloatDictionary alloc] initWithValues:kValues2
+ [[GPBUInt32FloatDictionary alloc] initWithFloats:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBUInt32FloatDictionary *dict3 =
- [[GPBUInt32FloatDictionary alloc] initWithValues:kValues1
+ [[GPBUInt32FloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBUInt32FloatDictionary *dict4 =
- [[GPBUInt32FloatDictionary alloc] initWithValues:kValues3
+ [[GPBUInt32FloatDictionary alloc] initWithFloats:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -2016,7 +2029,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBUInt32FloatDictionary *dict =
- [[GPBUInt32FloatDictionary alloc] initWithValues:kValues
+ [[GPBUInt32FloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -2037,33 +2050,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBUInt32FloatDictionary *dict =
- [[GPBUInt32FloatDictionary alloc] initWithValues:kValues
+ [[GPBUInt32FloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt32FloatDictionary *dict2 =
- [GPBUInt32FloatDictionary dictionaryWithDictionary:dict];
+ [[GPBUInt32FloatDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt32FloatDictionary *dict = [GPBUInt32FloatDictionary dictionary];
+ GPBUInt32FloatDictionary *dict = [[GPBUInt32FloatDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:500.f forKey:1U];
+ [dict setFloat:500.f forKey:1U];
XCTAssertEqual(dict.count, 1U);
const uint32_t kKeys[] = { 2U, 3U, 4U };
const float kValues[] = { 501.f, 502.f, 503.f };
GPBUInt32FloatDictionary *dict2 =
- [[GPBUInt32FloatDictionary alloc] initWithValues:kValues
+ [[GPBUInt32FloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -2071,76 +2085,77 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 4U);
float value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:1U]);
+ XCTAssertTrue([dict getFloat:&value forKey:1U]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:2U]);
+ XCTAssertTrue([dict getFloat:&value forKey:2U]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:3U]);
+ XCTAssertTrue([dict getFloat:&value forKey:3U]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:4U]);
+ XCTAssertTrue([dict getFloat:&value forKey:4U]);
XCTAssertEqual(value, 503.f);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBUInt32FloatDictionary *dict =
- [[GPBUInt32FloatDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32FloatDictionary alloc] initWithFloats:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:2U];
+ [dict removeFloatForKey:2U];
XCTAssertEqual(dict.count, 3U);
float value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:1U]);
+ XCTAssertTrue([dict getFloat:&value forKey:1U]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getFloat:NULL forKey:2U]);
+ XCTAssertTrue([dict getFloat:NULL forKey:3U]);
+ XCTAssertTrue([dict getFloat:&value forKey:3U]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:4U]);
+ XCTAssertTrue([dict getFloat:&value forKey:4U]);
XCTAssertEqual(value, 503.f);
// Remove again does nothing.
- [dict removeValueForKey:2U];
+ [dict removeFloatForKey:2U];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:1U]);
+ XCTAssertTrue([dict getFloat:&value forKey:1U]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getFloat:NULL forKey:2U]);
+ XCTAssertTrue([dict getFloat:NULL forKey:3U]);
+ XCTAssertTrue([dict getFloat:&value forKey:3U]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:4U]);
+ XCTAssertTrue([dict getFloat:&value forKey:4U]);
XCTAssertEqual(value, 503.f);
- [dict removeValueForKey:4U];
+ [dict removeFloatForKey:4U];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:1U]);
+ XCTAssertTrue([dict getFloat:&value forKey:1U]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getFloat:NULL forKey:2U]);
+ XCTAssertTrue([dict getFloat:NULL forKey:3U]);
+ XCTAssertTrue([dict getFloat:&value forKey:3U]);
XCTAssertEqual(value, 502.f);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:4U]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertFalse([dict valueForKey:3U value:NULL]);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:1U]);
+ XCTAssertFalse([dict getFloat:NULL forKey:2U]);
+ XCTAssertFalse([dict getFloat:NULL forKey:3U]);
+ XCTAssertFalse([dict getFloat:NULL forKey:4U]);
[dict release];
}
@@ -2148,75 +2163,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBUInt32FloatDictionary *dict =
- [[GPBUInt32FloatDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32FloatDictionary alloc] initWithFloats:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
float value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:1U]);
+ XCTAssertTrue([dict getFloat:&value forKey:1U]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:2U]);
+ XCTAssertTrue([dict getFloat:&value forKey:2U]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:3U]);
+ XCTAssertTrue([dict getFloat:&value forKey:3U]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:4U]);
+ XCTAssertTrue([dict getFloat:&value forKey:4U]);
XCTAssertEqual(value, 503.f);
- [dict setValue:503.f forKey:1U];
+ [dict setFloat:503.f forKey:1U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:1U]);
+ XCTAssertTrue([dict getFloat:&value forKey:1U]);
XCTAssertEqual(value, 503.f);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:2U]);
+ XCTAssertTrue([dict getFloat:&value forKey:2U]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:3U]);
+ XCTAssertTrue([dict getFloat:&value forKey:3U]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:4U]);
+ XCTAssertTrue([dict getFloat:&value forKey:4U]);
XCTAssertEqual(value, 503.f);
- [dict setValue:501.f forKey:4U];
+ [dict setFloat:501.f forKey:4U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:1U]);
+ XCTAssertTrue([dict getFloat:&value forKey:1U]);
XCTAssertEqual(value, 503.f);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:2U]);
+ XCTAssertTrue([dict getFloat:&value forKey:2U]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:3U]);
+ XCTAssertTrue([dict getFloat:&value forKey:3U]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:4U]);
+ XCTAssertTrue([dict getFloat:&value forKey:4U]);
XCTAssertEqual(value, 501.f);
const uint32_t kKeys2[] = { 2U, 3U };
const float kValues2[] = { 502.f, 500.f };
GPBUInt32FloatDictionary *dict2 =
- [[GPBUInt32FloatDictionary alloc] initWithValues:kValues2
+ [[GPBUInt32FloatDictionary alloc] initWithFloats:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:1U]);
+ XCTAssertTrue([dict getFloat:&value forKey:1U]);
XCTAssertEqual(value, 503.f);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:2U]);
+ XCTAssertTrue([dict getFloat:&value forKey:2U]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:3U]);
+ XCTAssertTrue([dict getFloat:&value forKey:3U]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:4U]);
+ XCTAssertTrue([dict getFloat:&value forKey:4U]);
XCTAssertEqual(value, 501.f);
[dict2 release];
@@ -2236,8 +2251,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBUInt32DoubleDictionary *dict = [[GPBUInt32DoubleDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, double aValue, BOOL *stop) {
+ XCTAssertFalse([dict getDouble:NULL forKey:1U]);
+ [dict enumerateKeysAndDoublesUsingBlock:^(uint32_t aKey, double aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -2245,46 +2260,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt32DoubleDictionary *dict = [GPBUInt32DoubleDictionary dictionaryWithValue:600. forKey:1U];
+ GPBUInt32DoubleDictionary *dict = [[GPBUInt32DoubleDictionary alloc] init];
+ [dict setDouble:600. forKey:1U];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
double value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:1U]);
+ XCTAssertTrue([dict getDouble:&value forKey:1U]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, double aValue, BOOL *stop) {
+ XCTAssertFalse([dict getDouble:NULL forKey:2U]);
+ [dict enumerateKeysAndDoublesUsingBlock:^(uint32_t aKey, double aValue, BOOL *stop) {
XCTAssertEqual(aKey, 1U);
XCTAssertEqual(aValue, 600.);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint32_t kKeys[] = { 1U, 2U, 3U };
const double kValues[] = { 600., 601., 602. };
GPBUInt32DoubleDictionary *dict =
- [[GPBUInt32DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
double value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:1U]);
+ XCTAssertTrue([dict getDouble:&value forKey:1U]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:2U]);
+ XCTAssertTrue([dict getDouble:&value forKey:2U]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:3U]);
+ XCTAssertTrue([dict getDouble:&value forKey:3U]);
XCTAssertEqual(value, 602.);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:4U]);
__block NSUInteger idx = 0;
uint32_t *seenKeys = malloc(3 * sizeof(uint32_t));
double *seenValues = malloc(3 * sizeof(double));
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, double aValue, BOOL *stop) {
+ [dict enumerateKeysAndDoublesUsingBlock:^(uint32_t aKey, double aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -2306,7 +2323,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, double aValue, BOOL *stop) {
+ [dict enumerateKeysAndDoublesUsingBlock:^(uint32_t aKey, double aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -2322,29 +2339,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const double kValues2[] = { 600., 603., 602. };
const double kValues3[] = { 600., 601., 602., 603. };
GPBUInt32DoubleDictionary *dict1 =
- [[GPBUInt32DoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt32DoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBUInt32DoubleDictionary *dict1prime =
- [[GPBUInt32DoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt32DoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBUInt32DoubleDictionary *dict2 =
- [[GPBUInt32DoubleDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt32DoubleDictionary alloc] initWithDoubles:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBUInt32DoubleDictionary *dict3 =
- [[GPBUInt32DoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt32DoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBUInt32DoubleDictionary *dict4 =
- [[GPBUInt32DoubleDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBUInt32DoubleDictionary alloc] initWithDoubles:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -2373,9 +2390,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const double kValues[] = { 600., 601., 602., 603. };
GPBUInt32DoubleDictionary *dict =
- [[GPBUInt32DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt32DoubleDictionary *dict2 = [dict copy];
@@ -2394,110 +2411,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const double kValues[] = { 600., 601., 602., 603. };
GPBUInt32DoubleDictionary *dict =
- [[GPBUInt32DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt32DoubleDictionary *dict2 =
- [GPBUInt32DoubleDictionary dictionaryWithDictionary:dict];
+ [[GPBUInt32DoubleDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt32DoubleDictionary *dict = [GPBUInt32DoubleDictionary dictionary];
+ GPBUInt32DoubleDictionary *dict = [[GPBUInt32DoubleDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:600. forKey:1U];
+ [dict setDouble:600. forKey:1U];
XCTAssertEqual(dict.count, 1U);
const uint32_t kKeys[] = { 2U, 3U, 4U };
const double kValues[] = { 601., 602., 603. };
GPBUInt32DoubleDictionary *dict2 =
- [[GPBUInt32DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
double value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:1U]);
+ XCTAssertTrue([dict getDouble:&value forKey:1U]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:2U]);
+ XCTAssertTrue([dict getDouble:&value forKey:2U]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:3U]);
+ XCTAssertTrue([dict getDouble:&value forKey:3U]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:4U]);
+ XCTAssertTrue([dict getDouble:&value forKey:4U]);
XCTAssertEqual(value, 603.);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const double kValues[] = { 600., 601., 602., 603. };
GPBUInt32DoubleDictionary *dict =
- [[GPBUInt32DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:2U];
+ [dict removeDoubleForKey:2U];
XCTAssertEqual(dict.count, 3U);
double value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:1U]);
+ XCTAssertTrue([dict getDouble:&value forKey:1U]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getDouble:NULL forKey:2U]);
+ XCTAssertTrue([dict getDouble:NULL forKey:3U]);
+ XCTAssertTrue([dict getDouble:&value forKey:3U]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:4U]);
+ XCTAssertTrue([dict getDouble:&value forKey:4U]);
XCTAssertEqual(value, 603.);
// Remove again does nothing.
- [dict removeValueForKey:2U];
+ [dict removeDoubleForKey:2U];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:1U]);
+ XCTAssertTrue([dict getDouble:&value forKey:1U]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getDouble:NULL forKey:2U]);
+ XCTAssertTrue([dict getDouble:NULL forKey:3U]);
+ XCTAssertTrue([dict getDouble:&value forKey:3U]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:4U]);
+ XCTAssertTrue([dict getDouble:&value forKey:4U]);
XCTAssertEqual(value, 603.);
- [dict removeValueForKey:4U];
+ [dict removeDoubleForKey:4U];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:1U]);
+ XCTAssertTrue([dict getDouble:&value forKey:1U]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getDouble:NULL forKey:2U]);
+ XCTAssertTrue([dict getDouble:NULL forKey:3U]);
+ XCTAssertTrue([dict getDouble:&value forKey:3U]);
XCTAssertEqual(value, 602.);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:4U]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertFalse([dict valueForKey:3U value:NULL]);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:1U]);
+ XCTAssertFalse([dict getDouble:NULL forKey:2U]);
+ XCTAssertFalse([dict getDouble:NULL forKey:3U]);
+ XCTAssertFalse([dict getDouble:NULL forKey:4U]);
[dict release];
}
@@ -2505,75 +2524,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const double kValues[] = { 600., 601., 602., 603. };
GPBUInt32DoubleDictionary *dict =
- [[GPBUInt32DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
double value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:1U]);
+ XCTAssertTrue([dict getDouble:&value forKey:1U]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:2U]);
+ XCTAssertTrue([dict getDouble:&value forKey:2U]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:3U]);
+ XCTAssertTrue([dict getDouble:&value forKey:3U]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:4U]);
+ XCTAssertTrue([dict getDouble:&value forKey:4U]);
XCTAssertEqual(value, 603.);
- [dict setValue:603. forKey:1U];
+ [dict setDouble:603. forKey:1U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:1U]);
+ XCTAssertTrue([dict getDouble:&value forKey:1U]);
XCTAssertEqual(value, 603.);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:2U]);
+ XCTAssertTrue([dict getDouble:&value forKey:2U]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:3U]);
+ XCTAssertTrue([dict getDouble:&value forKey:3U]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:4U]);
+ XCTAssertTrue([dict getDouble:&value forKey:4U]);
XCTAssertEqual(value, 603.);
- [dict setValue:601. forKey:4U];
+ [dict setDouble:601. forKey:4U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:1U]);
+ XCTAssertTrue([dict getDouble:&value forKey:1U]);
XCTAssertEqual(value, 603.);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:2U]);
+ XCTAssertTrue([dict getDouble:&value forKey:2U]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:3U]);
+ XCTAssertTrue([dict getDouble:&value forKey:3U]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:4U]);
+ XCTAssertTrue([dict getDouble:&value forKey:4U]);
XCTAssertEqual(value, 601.);
const uint32_t kKeys2[] = { 2U, 3U };
const double kValues2[] = { 602., 600. };
GPBUInt32DoubleDictionary *dict2 =
- [[GPBUInt32DoubleDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt32DoubleDictionary alloc] initWithDoubles:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:1U]);
+ XCTAssertTrue([dict getDouble:&value forKey:1U]);
XCTAssertEqual(value, 603.);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:2U]);
+ XCTAssertTrue([dict getDouble:&value forKey:2U]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:3U]);
+ XCTAssertTrue([dict getDouble:&value forKey:3U]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:4U]);
+ XCTAssertTrue([dict getDouble:&value forKey:4U]);
XCTAssertEqual(value, 601.);
[dict2 release];
@@ -2593,8 +2612,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBUInt32EnumDictionary *dict = [[GPBUInt32EnumDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getEnum:NULL forKey:1U]);
+ [dict enumerateKeysAndEnumsUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -2602,46 +2621,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt32EnumDictionary *dict = [GPBUInt32EnumDictionary dictionaryWithValue:700 forKey:1U];
+ GPBUInt32EnumDictionary *dict = [[GPBUInt32EnumDictionary alloc] init];
+ [dict setEnum:700 forKey:1U];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:1U]);
+ XCTAssertTrue([dict getEnum:&value forKey:1U]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getEnum:NULL forKey:2U]);
+ [dict enumerateKeysAndEnumsUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 1U);
XCTAssertEqual(aValue, 700);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint32_t kKeys[] = { 1U, 2U, 3U };
const int32_t kValues[] = { 700, 701, 702 };
GPBUInt32EnumDictionary *dict =
- [[GPBUInt32EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:1U]);
+ XCTAssertTrue([dict getEnum:&value forKey:1U]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:2U]);
+ XCTAssertTrue([dict getEnum:&value forKey:2U]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:4U]);
__block NSUInteger idx = 0;
uint32_t *seenKeys = malloc(3 * sizeof(uint32_t));
int32_t *seenValues = malloc(3 * sizeof(int32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndEnumsUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -2663,7 +2684,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndEnumsUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -2679,29 +2700,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kValues2[] = { 700, 703, 702 };
const int32_t kValues3[] = { 700, 701, 702, 703 };
GPBUInt32EnumDictionary *dict1 =
- [[GPBUInt32EnumDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt32EnumDictionary alloc] initWithEnums:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBUInt32EnumDictionary *dict1prime =
- [[GPBUInt32EnumDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt32EnumDictionary alloc] initWithEnums:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBUInt32EnumDictionary *dict2 =
- [[GPBUInt32EnumDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt32EnumDictionary alloc] initWithEnums:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBUInt32EnumDictionary *dict3 =
- [[GPBUInt32EnumDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt32EnumDictionary alloc] initWithEnums:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBUInt32EnumDictionary *dict4 =
- [[GPBUInt32EnumDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBUInt32EnumDictionary alloc] initWithEnums:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -2730,9 +2751,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBUInt32EnumDictionary *dict =
- [[GPBUInt32EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt32EnumDictionary *dict2 = [dict copy];
@@ -2751,110 +2772,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBUInt32EnumDictionary *dict =
- [[GPBUInt32EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt32EnumDictionary *dict2 =
- [GPBUInt32EnumDictionary dictionaryWithDictionary:dict];
+ [[GPBUInt32EnumDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt32EnumDictionary *dict = [GPBUInt32EnumDictionary dictionary];
+ GPBUInt32EnumDictionary *dict = [[GPBUInt32EnumDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:700 forKey:1U];
+ [dict setEnum:700 forKey:1U];
XCTAssertEqual(dict.count, 1U);
const uint32_t kKeys[] = { 2U, 3U, 4U };
const int32_t kValues[] = { 701, 702, 703 };
GPBUInt32EnumDictionary *dict2 =
- [[GPBUInt32EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:1U]);
+ XCTAssertTrue([dict getEnum:&value forKey:1U]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:2U]);
+ XCTAssertTrue([dict getEnum:&value forKey:2U]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:4U]);
+ XCTAssertTrue([dict getEnum:&value forKey:4U]);
XCTAssertEqual(value, 703);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBUInt32EnumDictionary *dict =
- [[GPBUInt32EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:2U];
+ [dict removeEnumForKey:2U];
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:1U]);
+ XCTAssertTrue([dict getEnum:&value forKey:1U]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:2U]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:4U]);
+ XCTAssertTrue([dict getEnum:&value forKey:4U]);
XCTAssertEqual(value, 703);
// Remove again does nothing.
- [dict removeValueForKey:2U];
+ [dict removeEnumForKey:2U];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:1U]);
+ XCTAssertTrue([dict getEnum:&value forKey:1U]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:2U]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:4U]);
+ XCTAssertTrue([dict getEnum:&value forKey:4U]);
XCTAssertEqual(value, 703);
- [dict removeValueForKey:4U];
+ [dict removeEnumForKey:4U];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:1U]);
+ XCTAssertTrue([dict getEnum:&value forKey:1U]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:2U]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:4U]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertFalse([dict valueForKey:3U value:NULL]);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:1U]);
+ XCTAssertFalse([dict getEnum:NULL forKey:2U]);
+ XCTAssertFalse([dict getEnum:NULL forKey:3U]);
+ XCTAssertFalse([dict getEnum:NULL forKey:4U]);
[dict release];
}
@@ -2862,75 +2885,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBUInt32EnumDictionary *dict =
- [[GPBUInt32EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:1U]);
+ XCTAssertTrue([dict getEnum:&value forKey:1U]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:2U]);
+ XCTAssertTrue([dict getEnum:&value forKey:2U]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:4U]);
+ XCTAssertTrue([dict getEnum:&value forKey:4U]);
XCTAssertEqual(value, 703);
- [dict setValue:703 forKey:1U];
+ [dict setEnum:703 forKey:1U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:1U]);
+ XCTAssertTrue([dict getEnum:&value forKey:1U]);
XCTAssertEqual(value, 703);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:2U]);
+ XCTAssertTrue([dict getEnum:&value forKey:2U]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:4U]);
+ XCTAssertTrue([dict getEnum:&value forKey:4U]);
XCTAssertEqual(value, 703);
- [dict setValue:701 forKey:4U];
+ [dict setEnum:701 forKey:4U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:1U]);
+ XCTAssertTrue([dict getEnum:&value forKey:1U]);
XCTAssertEqual(value, 703);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:2U]);
+ XCTAssertTrue([dict getEnum:&value forKey:2U]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:4U]);
+ XCTAssertTrue([dict getEnum:&value forKey:4U]);
XCTAssertEqual(value, 701);
const uint32_t kKeys2[] = { 2U, 3U };
const int32_t kValues2[] = { 702, 700 };
GPBUInt32EnumDictionary *dict2 =
- [[GPBUInt32EnumDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt32EnumDictionary alloc] initWithEnums:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:1U]);
+ XCTAssertTrue([dict getEnum:&value forKey:1U]);
XCTAssertEqual(value, 703);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:2U]);
+ XCTAssertTrue([dict getEnum:&value forKey:2U]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:4U]);
+ XCTAssertTrue([dict getEnum:&value forKey:4U]);
XCTAssertEqual(value, 701);
[dict2 release];
@@ -2958,24 +2981,24 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 3U);
XCTAssertTrue(dict.validationFunc == TestingEnum_IsValidValue); // Pointer comparison
int32_t value;
- XCTAssertTrue([dict valueForKey:1U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:1U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:1U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:1U]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:2U]);
+ XCTAssertTrue([dict getEnum:&value forKey:2U]);
XCTAssertEqual(value, kGPBUnrecognizedEnumeratorValue);
- XCTAssertTrue([dict valueForKey:2U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:2U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:2U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:2U]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:3U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:3U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:3U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:4U rawValue:NULL]);
+ XCTAssertFalse([dict getRawValue:NULL forKey:4U]);
__block NSUInteger idx = 0;
uint32_t *seenKeys = malloc(3 * sizeof(uint32_t));
int32_t *seenValues = malloc(3 * sizeof(int32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndEnumsUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -3120,23 +3143,24 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBUInt32EnumDictionary *dict2 =
- [GPBUInt32EnumDictionary dictionaryWithDictionary:dict];
+ [[GPBUInt32EnumDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
XCTAssertEqual(dict.validationFunc, dict2.validationFunc); // Pointer comparison
+ [dict2 release];
[dict release];
}
- (void)testUnknownAdds {
GPBUInt32EnumDictionary *dict =
- [GPBUInt32EnumDictionary dictionaryWithValidationFunction:TestingEnum_IsValidValue];
+ [[GPBUInt32EnumDictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertThrowsSpecificNamed([dict setValue:801 forKey:2U], // Unknown
+ XCTAssertThrowsSpecificNamed([dict setEnum:801 forKey:2U], // Unknown
NSException, NSInvalidArgumentException);
XCTAssertEqual(dict.count, 0U);
[dict setRawValue:801 forKey:2U]; // Unknown
@@ -3145,33 +3169,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kKeys[] = { 1U, 3U, 4U };
const int32_t kValues[] = { 700, 702, 803 }; // Unknown
GPBUInt32EnumDictionary *dict2 =
- [[GPBUInt32EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt32EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:1U]);
+ XCTAssertTrue([dict getEnum:&value forKey:1U]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:2U]);
+ XCTAssertTrue([dict getEnum:&value forKey:2U]);
XCTAssertEqual(value, kGPBUnrecognizedEnumeratorValue);
- XCTAssertTrue([dict valueForKey:2U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:2U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:2U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:2U]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:4U]);
+ XCTAssertTrue([dict getEnum:&value forKey:4U]);
XCTAssertEqual(value, kGPBUnrecognizedEnumeratorValue);
- XCTAssertTrue([dict valueForKey:4U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:4U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:4U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:4U]);
XCTAssertEqual(value, 803);
[dict2 release];
+ [dict release];
}
- (void)testUnknownRemove {
@@ -3185,51 +3210,51 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:2U];
+ [dict removeEnumForKey:2U];
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:1U]);
+ XCTAssertTrue([dict getEnum:&value forKey:1U]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:2U]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:4U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:4U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:4U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:4U]);
XCTAssertEqual(value, 803);
// Remove again does nothing.
- [dict removeValueForKey:2U];
+ [dict removeEnumForKey:2U];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:1U]);
+ XCTAssertTrue([dict getEnum:&value forKey:1U]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:2U]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:4U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:4U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:4U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:4U]);
XCTAssertEqual(value, 803);
- [dict removeValueForKey:4U];
+ [dict removeEnumForKey:4U];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:1U]);
+ XCTAssertTrue([dict getEnum:&value forKey:1U]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:2U]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:4U]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:1U value:NULL]);
- XCTAssertFalse([dict valueForKey:2U value:NULL]);
- XCTAssertFalse([dict valueForKey:3U value:NULL]);
- XCTAssertFalse([dict valueForKey:4U value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:1U]);
+ XCTAssertFalse([dict getEnum:NULL forKey:2U]);
+ XCTAssertFalse([dict getEnum:NULL forKey:3U]);
+ XCTAssertFalse([dict getEnum:NULL forKey:4U]);
[dict release];
}
@@ -3244,63 +3269,63 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:1U]);
+ XCTAssertTrue([dict getEnum:&value forKey:1U]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:2U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:2U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:2U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:2U]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:4U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:4U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:4U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:4U]);
XCTAssertEqual(value, 803);
- XCTAssertThrowsSpecificNamed([dict setValue:803 forKey:1U], // Unknown
+ XCTAssertThrowsSpecificNamed([dict setEnum:803 forKey:1U], // Unknown
NSException, NSInvalidArgumentException);
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U value:NULL]);
- XCTAssertTrue([dict valueForKey:1U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:1U]);
+ XCTAssertTrue([dict getEnum:&value forKey:1U]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:2U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:2U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:2U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:2U]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:4U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:4U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:4U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:4U]);
XCTAssertEqual(value, 803);
[dict setRawValue:803 forKey:1U]; // Unknown
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:1U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:1U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:1U]);
XCTAssertEqual(value, 803);
- XCTAssertTrue([dict valueForKey:2U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:2U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:2U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:2U]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:4U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:4U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:4U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:4U]);
XCTAssertEqual(value, 803);
[dict setRawValue:700 forKey:4U];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:1U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:1U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:1U]);
XCTAssertEqual(value, 803);
- XCTAssertTrue([dict valueForKey:2U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:2U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:2U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:2U]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:3U value:NULL]);
- XCTAssertTrue([dict valueForKey:3U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:3U]);
+ XCTAssertTrue([dict getEnum:&value forKey:3U]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:4U]);
+ XCTAssertTrue([dict getEnum:&value forKey:4U]);
XCTAssertEqual(value, 700);
const uint32_t kKeys2[] = { 2U, 3U };
@@ -3313,17 +3338,17 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:1U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:1U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:1U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:1U]);
XCTAssertEqual(value, 803);
- XCTAssertTrue([dict valueForKey:2U value:NULL]);
- XCTAssertTrue([dict valueForKey:2U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:2U]);
+ XCTAssertTrue([dict getEnum:&value forKey:2U]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:3U rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:3U rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:3U]);
+ XCTAssertTrue([dict getRawValue:&value forKey:3U]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:4U value:NULL]);
- XCTAssertTrue([dict valueForKey:4U value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:4U]);
+ XCTAssertTrue([dict getEnum:&value forKey:4U]);
XCTAssertEqual(value, 700);
[dict2 release];
@@ -3363,11 +3388,11 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
@implementation GPBUInt32ObjectDictionaryTests
- (void)testEmpty {
- GPBUInt32ObjectDictionary *dict = [[GPBUInt32ObjectDictionary alloc] init];
+ GPBUInt32ObjectDictionary<NSString*> *dict = [[GPBUInt32ObjectDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
XCTAssertNil([dict objectForKey:1U]);
- [dict enumerateKeysAndObjectsUsingBlock:^(uint32_t aKey, id aObject, BOOL *stop) {
+ [dict enumerateKeysAndObjectsUsingBlock:^(uint32_t aKey, NSString* aObject, BOOL *stop) {
#pragma unused(aKey, aObject, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -3375,22 +3400,24 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt32ObjectDictionary *dict = [GPBUInt32ObjectDictionary dictionaryWithObject:@"abc" forKey:1U];
+ GPBUInt32ObjectDictionary<NSString*> *dict = [[GPBUInt32ObjectDictionary alloc] init];
+ [dict setObject:@"abc" forKey:1U];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
XCTAssertEqualObjects([dict objectForKey:1U], @"abc");
XCTAssertNil([dict objectForKey:2U]);
- [dict enumerateKeysAndObjectsUsingBlock:^(uint32_t aKey, id aObject, BOOL *stop) {
+ [dict enumerateKeysAndObjectsUsingBlock:^(uint32_t aKey, NSString* aObject, BOOL *stop) {
XCTAssertEqual(aKey, 1U);
XCTAssertEqualObjects(aObject, @"abc");
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint32_t kKeys[] = { 1U, 2U, 3U };
- const id kObjects[] = { @"abc", @"def", @"ghi" };
- GPBUInt32ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi" };
+ GPBUInt32ObjectDictionary<NSString*> *dict =
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
@@ -3403,8 +3430,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
__block NSUInteger idx = 0;
uint32_t *seenKeys = malloc(3 * sizeof(uint32_t));
- id *seenObjects = malloc(3 * sizeof(id));
- [dict enumerateKeysAndObjectsUsingBlock:^(uint32_t aKey, id aObject, BOOL *stop) {
+ NSString* *seenObjects = malloc(3 * sizeof(NSString*));
+ [dict enumerateKeysAndObjectsUsingBlock:^(uint32_t aKey, NSString* aObject, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenObjects[idx] = aObject;
@@ -3426,7 +3453,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndObjectsUsingBlock:^(uint32_t aKey, id aObject, BOOL *stop) {
+ [dict enumerateKeysAndObjectsUsingBlock:^(uint32_t aKey, NSString* aObject, BOOL *stop) {
#pragma unused(aKey, aObject)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -3438,30 +3465,30 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
- (void)testEquality {
const uint32_t kKeys1[] = { 1U, 2U, 3U, 4U };
const uint32_t kKeys2[] = { 2U, 1U, 4U };
- const id kObjects1[] = { @"abc", @"def", @"ghi" };
- const id kObjects2[] = { @"abc", @"jkl", @"ghi" };
- const id kObjects3[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBUInt32ObjectDictionary *dict1 =
+ const NSString* kObjects1[] = { @"abc", @"def", @"ghi" };
+ const NSString* kObjects2[] = { @"abc", @"jkl", @"ghi" };
+ const NSString* kObjects3[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBUInt32ObjectDictionary<NSString*> *dict1 =
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects1
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects1)];
XCTAssertNotNil(dict1);
- GPBUInt32ObjectDictionary *dict1prime =
+ GPBUInt32ObjectDictionary<NSString*> *dict1prime =
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects1
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects1)];
XCTAssertNotNil(dict1prime);
- GPBUInt32ObjectDictionary *dict2 =
+ GPBUInt32ObjectDictionary<NSString*> *dict2 =
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects2
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects2)];
XCTAssertNotNil(dict2);
- GPBUInt32ObjectDictionary *dict3 =
+ GPBUInt32ObjectDictionary<NSString*> *dict3 =
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects1
forKeys:kKeys2
count:GPBARRAYSIZE(kObjects1)];
XCTAssertNotNil(dict3);
- GPBUInt32ObjectDictionary *dict4 =
+ GPBUInt32ObjectDictionary<NSString*> *dict4 =
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects3
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects3)];
@@ -3491,14 +3518,14 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
- (void)testCopy {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
- const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBUInt32ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBUInt32ObjectDictionary<NSString*> *dict =
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
- GPBUInt32ObjectDictionary *dict2 = [dict copy];
+ GPBUInt32ObjectDictionary<NSString*> *dict2 = [dict copy];
XCTAssertNotNil(dict2);
// Should be new object but equal.
@@ -3512,25 +3539,26 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
- (void)testDictionaryFromDictionary {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
- const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBUInt32ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBUInt32ObjectDictionary<NSString*> *dict =
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
- GPBUInt32ObjectDictionary *dict2 =
- [GPBUInt32ObjectDictionary dictionaryWithDictionary:dict];
+ GPBUInt32ObjectDictionary<NSString*> *dict2 =
+ [[GPBUInt32ObjectDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt32ObjectDictionary *dict = [GPBUInt32ObjectDictionary dictionary];
+ GPBUInt32ObjectDictionary<NSString*> *dict = [[GPBUInt32ObjectDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@@ -3538,8 +3566,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 1U);
const uint32_t kKeys[] = { 2U, 3U, 4U };
- const id kObjects[] = { @"def", @"ghi", @"jkl" };
- GPBUInt32ObjectDictionary *dict2 =
+ const NSString* kObjects[] = { @"def", @"ghi", @"jkl" };
+ GPBUInt32ObjectDictionary<NSString*> *dict2 =
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
@@ -3552,15 +3580,16 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqualObjects([dict objectForKey:3U], @"ghi");
XCTAssertEqualObjects([dict objectForKey:4U], @"jkl");
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
- const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBUInt32ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBUInt32ObjectDictionary<NSString*> *dict =
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects
- forKeys:kKeys
- count:GPBARRAYSIZE(kObjects)];
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
@@ -3597,11 +3626,11 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
- (void)testInplaceMutation {
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
- const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBUInt32ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBUInt32ObjectDictionary<NSString*> *dict =
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects
- forKeys:kKeys
- count:GPBARRAYSIZE(kObjects)];
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
XCTAssertEqualObjects([dict objectForKey:1U], @"abc");
@@ -3624,8 +3653,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqualObjects([dict objectForKey:4U], @"def");
const uint32_t kKeys2[] = { 2U, 3U };
- const id kObjects2[] = { @"ghi", @"abc" };
- GPBUInt32ObjectDictionary *dict2 =
+ const NSString* kObjects2[] = { @"ghi", @"abc" };
+ GPBUInt32ObjectDictionary<NSString*> *dict2 =
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects2
forKeys:kKeys2
count:GPBARRAYSIZE(kObjects2)];
diff --git a/objectivec/Tests/GPBDictionaryTests+UInt64.m b/objectivec/Tests/GPBDictionaryTests+UInt64.m
index b64d3a96..ccd063f5 100644
--- a/objectivec/Tests/GPBDictionaryTests+UInt64.m
+++ b/objectivec/Tests/GPBDictionaryTests+UInt64.m
@@ -45,10 +45,9 @@
// To let the testing macros work, add some extra methods to simplify things.
@interface GPBUInt64EnumDictionary (TestingTweak)
-+ (instancetype)dictionaryWithValue:(int32_t)value forKey:(uint64_t)key;
-- (instancetype)initWithValues:(const int32_t [])values
- forKeys:(const uint64_t [])keys
- count:(NSUInteger)count;
+- (instancetype)initWithEnums:(const int32_t [])values
+ forKeys:(const uint64_t [])keys
+ count:(NSUInteger)count;
@end
static BOOL TestingEnum_IsValidValue(int32_t value) {
@@ -64,17 +63,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
@implementation GPBUInt64EnumDictionary (TestingTweak)
-+ (instancetype)dictionaryWithValue:(int32_t)value forKey:(uint64_t)key {
- // Cast is needed to compiler knows what class we are invoking initWithValues: on to get the
- // type correct.
- return [[(GPBUInt64EnumDictionary*)[self alloc] initWithValidationFunction:TestingEnum_IsValidValue
- rawValues:&value
- forKeys:&key
- count:1] autorelease];
-}
-- (instancetype)initWithValues:(const int32_t [])values
- forKeys:(const uint64_t [])keys
- count:(NSUInteger)count {
+- (instancetype)initWithEnums:(const int32_t [])values
+ forKeys:(const uint64_t [])keys
+ count:(NSUInteger)count {
return [self initWithValidationFunction:TestingEnum_IsValidValue
rawValues:values
forKeys:keys
@@ -94,8 +85,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBUInt64UInt32Dictionary *dict = [[GPBUInt64UInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, uint32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt32:NULL forKey:31ULL]);
+ [dict enumerateKeysAndUInt32sUsingBlock:^(uint64_t aKey, uint32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -103,46 +94,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt64UInt32Dictionary *dict = [GPBUInt64UInt32Dictionary dictionaryWithValue:100U forKey:31ULL];
+ GPBUInt64UInt32Dictionary *dict = [[GPBUInt64UInt32Dictionary alloc] init];
+ [dict setUInt32:100U forKey:31ULL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, uint32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt32:NULL forKey:32ULL]);
+ [dict enumerateKeysAndUInt32sUsingBlock:^(uint64_t aKey, uint32_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 31ULL);
XCTAssertEqual(aValue, 100U);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL };
const uint32_t kValues[] = { 100U, 101U, 102U };
GPBUInt64UInt32Dictionary *dict =
- [[GPBUInt64UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:32ULL]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 102U);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:34ULL]);
__block NSUInteger idx = 0;
uint64_t *seenKeys = malloc(3 * sizeof(uint64_t));
uint32_t *seenValues = malloc(3 * sizeof(uint32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, uint32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt32sUsingBlock:^(uint64_t aKey, uint32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -164,7 +157,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, uint32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt32sUsingBlock:^(uint64_t aKey, uint32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -180,29 +173,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint32_t kValues2[] = { 100U, 103U, 102U };
const uint32_t kValues3[] = { 100U, 101U, 102U, 103U };
GPBUInt64UInt32Dictionary *dict1 =
- [[GPBUInt64UInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt64UInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBUInt64UInt32Dictionary *dict1prime =
- [[GPBUInt64UInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt64UInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBUInt64UInt32Dictionary *dict2 =
- [[GPBUInt64UInt32Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt64UInt32Dictionary alloc] initWithUInt32s:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBUInt64UInt32Dictionary *dict3 =
- [[GPBUInt64UInt32Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt64UInt32Dictionary alloc] initWithUInt32s:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBUInt64UInt32Dictionary *dict4 =
- [[GPBUInt64UInt32Dictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBUInt64UInt32Dictionary alloc] initWithUInt32s:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -231,9 +224,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBUInt64UInt32Dictionary *dict =
- [[GPBUInt64UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt64UInt32Dictionary *dict2 = [dict copy];
@@ -252,110 +245,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBUInt64UInt32Dictionary *dict =
- [[GPBUInt64UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt64UInt32Dictionary *dict2 =
- [GPBUInt64UInt32Dictionary dictionaryWithDictionary:dict];
+ [[GPBUInt64UInt32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt64UInt32Dictionary *dict = [GPBUInt64UInt32Dictionary dictionary];
+ GPBUInt64UInt32Dictionary *dict = [[GPBUInt64UInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:100U forKey:31ULL];
+ [dict setUInt32:100U forKey:31ULL];
XCTAssertEqual(dict.count, 1U);
const uint64_t kKeys[] = { 32ULL, 33ULL, 34ULL };
const uint32_t kValues[] = { 101U, 102U, 103U };
GPBUInt64UInt32Dictionary *dict2 =
- [[GPBUInt64UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:32ULL]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:34ULL]);
XCTAssertEqual(value, 103U);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBUInt64UInt32Dictionary *dict =
- [[GPBUInt64UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:32ULL];
+ [dict removeUInt32ForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:34ULL]);
XCTAssertEqual(value, 103U);
// Remove again does nothing.
- [dict removeValueForKey:32ULL];
+ [dict removeUInt32ForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:34ULL]);
XCTAssertEqual(value, 103U);
- [dict removeValueForKey:34ULL];
+ [dict removeUInt32ForKey:34ULL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 100U);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 102U);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:34ULL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:33ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:31ULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:32ULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:33ULL]);
+ XCTAssertFalse([dict getUInt32:NULL forKey:34ULL]);
[dict release];
}
@@ -363,75 +358,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const uint32_t kValues[] = { 100U, 101U, 102U, 103U };
GPBUInt64UInt32Dictionary *dict =
- [[GPBUInt64UInt32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64UInt32Dictionary alloc] initWithUInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
uint32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:32ULL]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:34ULL]);
XCTAssertEqual(value, 103U);
- [dict setValue:103U forKey:31ULL];
+ [dict setUInt32:103U forKey:31ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 103U);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:32ULL]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:34ULL]);
XCTAssertEqual(value, 103U);
- [dict setValue:101U forKey:34ULL];
+ [dict setUInt32:101U forKey:34ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 103U);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:32ULL]);
XCTAssertEqual(value, 101U);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:34ULL]);
XCTAssertEqual(value, 101U);
const uint64_t kKeys2[] = { 32ULL, 33ULL };
const uint32_t kValues2[] = { 102U, 100U };
GPBUInt64UInt32Dictionary *dict2 =
- [[GPBUInt64UInt32Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt64UInt32Dictionary alloc] initWithUInt32s:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 103U);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:32ULL]);
XCTAssertEqual(value, 102U);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 100U);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getUInt32:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getUInt32:&value forKey:34ULL]);
XCTAssertEqual(value, 101U);
[dict2 release];
@@ -451,8 +446,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBUInt64Int32Dictionary *dict = [[GPBUInt64Int32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt32:NULL forKey:31ULL]);
+ [dict enumerateKeysAndInt32sUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -460,46 +455,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt64Int32Dictionary *dict = [GPBUInt64Int32Dictionary dictionaryWithValue:200 forKey:31ULL];
+ GPBUInt64Int32Dictionary *dict = [[GPBUInt64Int32Dictionary alloc] init];
+ [dict setInt32:200 forKey:31ULL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt32:NULL forKey:32ULL]);
+ [dict enumerateKeysAndInt32sUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 31ULL);
XCTAssertEqual(aValue, 200);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL };
const int32_t kValues[] = { 200, 201, 202 };
GPBUInt64Int32Dictionary *dict =
- [[GPBUInt64Int32Dictionary alloc] initWithValues:kValues
+ [[GPBUInt64Int32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:32ULL]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 202);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:34ULL]);
__block NSUInteger idx = 0;
uint64_t *seenKeys = malloc(3 * sizeof(uint64_t));
int32_t *seenValues = malloc(3 * sizeof(int32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt32sUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -521,7 +518,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt32sUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -537,27 +534,27 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kValues2[] = { 200, 203, 202 };
const int32_t kValues3[] = { 200, 201, 202, 203 };
GPBUInt64Int32Dictionary *dict1 =
- [[GPBUInt64Int32Dictionary alloc] initWithValues:kValues1
+ [[GPBUInt64Int32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBUInt64Int32Dictionary *dict1prime =
- [[GPBUInt64Int32Dictionary alloc] initWithValues:kValues1
+ [[GPBUInt64Int32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBUInt64Int32Dictionary *dict2 =
- [[GPBUInt64Int32Dictionary alloc] initWithValues:kValues2
+ [[GPBUInt64Int32Dictionary alloc] initWithInt32s:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBUInt64Int32Dictionary *dict3 =
- [[GPBUInt64Int32Dictionary alloc] initWithValues:kValues1
+ [[GPBUInt64Int32Dictionary alloc] initWithInt32s:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBUInt64Int32Dictionary *dict4 =
- [[GPBUInt64Int32Dictionary alloc] initWithValues:kValues3
+ [[GPBUInt64Int32Dictionary alloc] initWithInt32s:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -588,7 +585,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBUInt64Int32Dictionary *dict =
- [[GPBUInt64Int32Dictionary alloc] initWithValues:kValues
+ [[GPBUInt64Int32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -609,33 +606,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBUInt64Int32Dictionary *dict =
- [[GPBUInt64Int32Dictionary alloc] initWithValues:kValues
+ [[GPBUInt64Int32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt64Int32Dictionary *dict2 =
- [GPBUInt64Int32Dictionary dictionaryWithDictionary:dict];
+ [[GPBUInt64Int32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt64Int32Dictionary *dict = [GPBUInt64Int32Dictionary dictionary];
+ GPBUInt64Int32Dictionary *dict = [[GPBUInt64Int32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:200 forKey:31ULL];
+ [dict setInt32:200 forKey:31ULL];
XCTAssertEqual(dict.count, 1U);
const uint64_t kKeys[] = { 32ULL, 33ULL, 34ULL };
const int32_t kValues[] = { 201, 202, 203 };
GPBUInt64Int32Dictionary *dict2 =
- [[GPBUInt64Int32Dictionary alloc] initWithValues:kValues
+ [[GPBUInt64Int32Dictionary alloc] initWithInt32s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -643,76 +641,77 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:32ULL]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:34ULL]);
XCTAssertEqual(value, 203);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBUInt64Int32Dictionary *dict =
- [[GPBUInt64Int32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64Int32Dictionary alloc] initWithInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:32ULL];
+ [dict removeInt32ForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:34ULL]);
XCTAssertEqual(value, 203);
// Remove again does nothing.
- [dict removeValueForKey:32ULL];
+ [dict removeInt32ForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:34ULL]);
XCTAssertEqual(value, 203);
- [dict removeValueForKey:34ULL];
+ [dict removeInt32ForKey:34ULL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 200);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 202);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:34ULL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:33ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:31ULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:32ULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:33ULL]);
+ XCTAssertFalse([dict getInt32:NULL forKey:34ULL]);
[dict release];
}
@@ -720,75 +719,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const int32_t kValues[] = { 200, 201, 202, 203 };
GPBUInt64Int32Dictionary *dict =
- [[GPBUInt64Int32Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64Int32Dictionary alloc] initWithInt32s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:32ULL]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:34ULL]);
XCTAssertEqual(value, 203);
- [dict setValue:203 forKey:31ULL];
+ [dict setInt32:203 forKey:31ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 203);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:32ULL]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:34ULL]);
XCTAssertEqual(value, 203);
- [dict setValue:201 forKey:34ULL];
+ [dict setInt32:201 forKey:34ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 203);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:32ULL]);
XCTAssertEqual(value, 201);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:34ULL]);
XCTAssertEqual(value, 201);
const uint64_t kKeys2[] = { 32ULL, 33ULL };
const int32_t kValues2[] = { 202, 200 };
GPBUInt64Int32Dictionary *dict2 =
- [[GPBUInt64Int32Dictionary alloc] initWithValues:kValues2
+ [[GPBUInt64Int32Dictionary alloc] initWithInt32s:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:31ULL]);
XCTAssertEqual(value, 203);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:32ULL]);
XCTAssertEqual(value, 202);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:33ULL]);
XCTAssertEqual(value, 200);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getInt32:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getInt32:&value forKey:34ULL]);
XCTAssertEqual(value, 201);
[dict2 release];
@@ -808,8 +807,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBUInt64UInt64Dictionary *dict = [[GPBUInt64UInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, uint64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt64:NULL forKey:31ULL]);
+ [dict enumerateKeysAndUInt64sUsingBlock:^(uint64_t aKey, uint64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -817,46 +816,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt64UInt64Dictionary *dict = [GPBUInt64UInt64Dictionary dictionaryWithValue:300U forKey:31ULL];
+ GPBUInt64UInt64Dictionary *dict = [[GPBUInt64UInt64Dictionary alloc] init];
+ [dict setUInt64:300U forKey:31ULL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, uint64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getUInt64:NULL forKey:32ULL]);
+ [dict enumerateKeysAndUInt64sUsingBlock:^(uint64_t aKey, uint64_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 31ULL);
XCTAssertEqual(aValue, 300U);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL };
const uint64_t kValues[] = { 300U, 301U, 302U };
GPBUInt64UInt64Dictionary *dict =
- [[GPBUInt64UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:32ULL]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 302U);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:34ULL]);
__block NSUInteger idx = 0;
uint64_t *seenKeys = malloc(3 * sizeof(uint64_t));
uint64_t *seenValues = malloc(3 * sizeof(uint64_t));
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, uint64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt64sUsingBlock:^(uint64_t aKey, uint64_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -878,7 +879,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, uint64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndUInt64sUsingBlock:^(uint64_t aKey, uint64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -894,29 +895,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kValues2[] = { 300U, 303U, 302U };
const uint64_t kValues3[] = { 300U, 301U, 302U, 303U };
GPBUInt64UInt64Dictionary *dict1 =
- [[GPBUInt64UInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt64UInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBUInt64UInt64Dictionary *dict1prime =
- [[GPBUInt64UInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt64UInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBUInt64UInt64Dictionary *dict2 =
- [[GPBUInt64UInt64Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt64UInt64Dictionary alloc] initWithUInt64s:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBUInt64UInt64Dictionary *dict3 =
- [[GPBUInt64UInt64Dictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt64UInt64Dictionary alloc] initWithUInt64s:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBUInt64UInt64Dictionary *dict4 =
- [[GPBUInt64UInt64Dictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBUInt64UInt64Dictionary alloc] initWithUInt64s:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -945,9 +946,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBUInt64UInt64Dictionary *dict =
- [[GPBUInt64UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt64UInt64Dictionary *dict2 = [dict copy];
@@ -966,110 +967,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBUInt64UInt64Dictionary *dict =
- [[GPBUInt64UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt64UInt64Dictionary *dict2 =
- [GPBUInt64UInt64Dictionary dictionaryWithDictionary:dict];
+ [[GPBUInt64UInt64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt64UInt64Dictionary *dict = [GPBUInt64UInt64Dictionary dictionary];
+ GPBUInt64UInt64Dictionary *dict = [[GPBUInt64UInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:300U forKey:31ULL];
+ [dict setUInt64:300U forKey:31ULL];
XCTAssertEqual(dict.count, 1U);
const uint64_t kKeys[] = { 32ULL, 33ULL, 34ULL };
const uint64_t kValues[] = { 301U, 302U, 303U };
GPBUInt64UInt64Dictionary *dict2 =
- [[GPBUInt64UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:32ULL]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:34ULL]);
XCTAssertEqual(value, 303U);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBUInt64UInt64Dictionary *dict =
- [[GPBUInt64UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:32ULL];
+ [dict removeUInt64ForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:34ULL]);
XCTAssertEqual(value, 303U);
// Remove again does nothing.
- [dict removeValueForKey:32ULL];
+ [dict removeUInt64ForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:34ULL]);
XCTAssertEqual(value, 303U);
- [dict removeValueForKey:34ULL];
+ [dict removeUInt64ForKey:34ULL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 300U);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 302U);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:34ULL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:33ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:31ULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:32ULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:33ULL]);
+ XCTAssertFalse([dict getUInt64:NULL forKey:34ULL]);
[dict release];
}
@@ -1077,75 +1080,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const uint64_t kValues[] = { 300U, 301U, 302U, 303U };
GPBUInt64UInt64Dictionary *dict =
- [[GPBUInt64UInt64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64UInt64Dictionary alloc] initWithUInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
uint64_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:32ULL]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:34ULL]);
XCTAssertEqual(value, 303U);
- [dict setValue:303U forKey:31ULL];
+ [dict setUInt64:303U forKey:31ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 303U);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:32ULL]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:34ULL]);
XCTAssertEqual(value, 303U);
- [dict setValue:301U forKey:34ULL];
+ [dict setUInt64:301U forKey:34ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 303U);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:32ULL]);
XCTAssertEqual(value, 301U);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:34ULL]);
XCTAssertEqual(value, 301U);
const uint64_t kKeys2[] = { 32ULL, 33ULL };
const uint64_t kValues2[] = { 302U, 300U };
GPBUInt64UInt64Dictionary *dict2 =
- [[GPBUInt64UInt64Dictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt64UInt64Dictionary alloc] initWithUInt64s:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 303U);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:32ULL]);
XCTAssertEqual(value, 302U);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 300U);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getUInt64:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getUInt64:&value forKey:34ULL]);
XCTAssertEqual(value, 301U);
[dict2 release];
@@ -1165,8 +1168,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBUInt64Int64Dictionary *dict = [[GPBUInt64Int64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, int64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt64:NULL forKey:31ULL]);
+ [dict enumerateKeysAndInt64sUsingBlock:^(uint64_t aKey, int64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1174,46 +1177,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt64Int64Dictionary *dict = [GPBUInt64Int64Dictionary dictionaryWithValue:400 forKey:31ULL];
+ GPBUInt64Int64Dictionary *dict = [[GPBUInt64Int64Dictionary alloc] init];
+ [dict setInt64:400 forKey:31ULL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int64_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, int64_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getInt64:NULL forKey:32ULL]);
+ [dict enumerateKeysAndInt64sUsingBlock:^(uint64_t aKey, int64_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 31ULL);
XCTAssertEqual(aValue, 400);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL };
const int64_t kValues[] = { 400, 401, 402 };
GPBUInt64Int64Dictionary *dict =
- [[GPBUInt64Int64Dictionary alloc] initWithValues:kValues
+ [[GPBUInt64Int64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
int64_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:32ULL]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 402);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:34ULL]);
__block NSUInteger idx = 0;
uint64_t *seenKeys = malloc(3 * sizeof(uint64_t));
int64_t *seenValues = malloc(3 * sizeof(int64_t));
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, int64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt64sUsingBlock:^(uint64_t aKey, int64_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1235,7 +1240,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, int64_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndInt64sUsingBlock:^(uint64_t aKey, int64_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1251,27 +1256,27 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int64_t kValues2[] = { 400, 403, 402 };
const int64_t kValues3[] = { 400, 401, 402, 403 };
GPBUInt64Int64Dictionary *dict1 =
- [[GPBUInt64Int64Dictionary alloc] initWithValues:kValues1
+ [[GPBUInt64Int64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBUInt64Int64Dictionary *dict1prime =
- [[GPBUInt64Int64Dictionary alloc] initWithValues:kValues1
+ [[GPBUInt64Int64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBUInt64Int64Dictionary *dict2 =
- [[GPBUInt64Int64Dictionary alloc] initWithValues:kValues2
+ [[GPBUInt64Int64Dictionary alloc] initWithInt64s:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBUInt64Int64Dictionary *dict3 =
- [[GPBUInt64Int64Dictionary alloc] initWithValues:kValues1
+ [[GPBUInt64Int64Dictionary alloc] initWithInt64s:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBUInt64Int64Dictionary *dict4 =
- [[GPBUInt64Int64Dictionary alloc] initWithValues:kValues3
+ [[GPBUInt64Int64Dictionary alloc] initWithInt64s:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -1302,7 +1307,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBUInt64Int64Dictionary *dict =
- [[GPBUInt64Int64Dictionary alloc] initWithValues:kValues
+ [[GPBUInt64Int64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -1323,33 +1328,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBUInt64Int64Dictionary *dict =
- [[GPBUInt64Int64Dictionary alloc] initWithValues:kValues
+ [[GPBUInt64Int64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt64Int64Dictionary *dict2 =
- [GPBUInt64Int64Dictionary dictionaryWithDictionary:dict];
+ [[GPBUInt64Int64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt64Int64Dictionary *dict = [GPBUInt64Int64Dictionary dictionary];
+ GPBUInt64Int64Dictionary *dict = [[GPBUInt64Int64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:400 forKey:31ULL];
+ [dict setInt64:400 forKey:31ULL];
XCTAssertEqual(dict.count, 1U);
const uint64_t kKeys[] = { 32ULL, 33ULL, 34ULL };
const int64_t kValues[] = { 401, 402, 403 };
GPBUInt64Int64Dictionary *dict2 =
- [[GPBUInt64Int64Dictionary alloc] initWithValues:kValues
+ [[GPBUInt64Int64Dictionary alloc] initWithInt64s:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -1357,76 +1363,77 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 4U);
int64_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:32ULL]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:34ULL]);
XCTAssertEqual(value, 403);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBUInt64Int64Dictionary *dict =
- [[GPBUInt64Int64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64Int64Dictionary alloc] initWithInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:32ULL];
+ [dict removeInt64ForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
int64_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:34ULL]);
XCTAssertEqual(value, 403);
// Remove again does nothing.
- [dict removeValueForKey:32ULL];
+ [dict removeInt64ForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:34ULL]);
XCTAssertEqual(value, 403);
- [dict removeValueForKey:34ULL];
+ [dict removeInt64ForKey:34ULL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 400);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 402);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:34ULL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:33ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:31ULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:32ULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:33ULL]);
+ XCTAssertFalse([dict getInt64:NULL forKey:34ULL]);
[dict release];
}
@@ -1434,75 +1441,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const int64_t kValues[] = { 400, 401, 402, 403 };
GPBUInt64Int64Dictionary *dict =
- [[GPBUInt64Int64Dictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64Int64Dictionary alloc] initWithInt64s:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int64_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:32ULL]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:34ULL]);
XCTAssertEqual(value, 403);
- [dict setValue:403 forKey:31ULL];
+ [dict setInt64:403 forKey:31ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 403);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:32ULL]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:34ULL]);
XCTAssertEqual(value, 403);
- [dict setValue:401 forKey:34ULL];
+ [dict setInt64:401 forKey:34ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 403);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:32ULL]);
XCTAssertEqual(value, 401);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:34ULL]);
XCTAssertEqual(value, 401);
const uint64_t kKeys2[] = { 32ULL, 33ULL };
const int64_t kValues2[] = { 402, 400 };
GPBUInt64Int64Dictionary *dict2 =
- [[GPBUInt64Int64Dictionary alloc] initWithValues:kValues2
+ [[GPBUInt64Int64Dictionary alloc] initWithInt64s:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:31ULL]);
XCTAssertEqual(value, 403);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:32ULL]);
XCTAssertEqual(value, 402);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:33ULL]);
XCTAssertEqual(value, 400);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getInt64:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getInt64:&value forKey:34ULL]);
XCTAssertEqual(value, 401);
[dict2 release];
@@ -1522,8 +1529,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBUInt64BoolDictionary *dict = [[GPBUInt64BoolDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, BOOL aValue, BOOL *stop) {
+ XCTAssertFalse([dict getBool:NULL forKey:31ULL]);
+ [dict enumerateKeysAndBoolsUsingBlock:^(uint64_t aKey, BOOL aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1531,46 +1538,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt64BoolDictionary *dict = [GPBUInt64BoolDictionary dictionaryWithValue:YES forKey:31ULL];
+ GPBUInt64BoolDictionary *dict = [[GPBUInt64BoolDictionary alloc] init];
+ [dict setBool:YES forKey:31ULL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
BOOL value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:31ULL]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, BOOL aValue, BOOL *stop) {
+ XCTAssertFalse([dict getBool:NULL forKey:32ULL]);
+ [dict enumerateKeysAndBoolsUsingBlock:^(uint64_t aKey, BOOL aValue, BOOL *stop) {
XCTAssertEqual(aKey, 31ULL);
XCTAssertEqual(aValue, YES);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL };
const BOOL kValues[] = { YES, YES, NO };
GPBUInt64BoolDictionary *dict =
- [[GPBUInt64BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
BOOL value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:31ULL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:32ULL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:33ULL]);
XCTAssertEqual(value, NO);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:34ULL]);
__block NSUInteger idx = 0;
uint64_t *seenKeys = malloc(3 * sizeof(uint64_t));
BOOL *seenValues = malloc(3 * sizeof(BOOL));
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, BOOL aValue, BOOL *stop) {
+ [dict enumerateKeysAndBoolsUsingBlock:^(uint64_t aKey, BOOL aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1592,7 +1601,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, BOOL aValue, BOOL *stop) {
+ [dict enumerateKeysAndBoolsUsingBlock:^(uint64_t aKey, BOOL aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1608,29 +1617,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const BOOL kValues2[] = { YES, NO, NO };
const BOOL kValues3[] = { YES, YES, NO, NO };
GPBUInt64BoolDictionary *dict1 =
- [[GPBUInt64BoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt64BoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBUInt64BoolDictionary *dict1prime =
- [[GPBUInt64BoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt64BoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBUInt64BoolDictionary *dict2 =
- [[GPBUInt64BoolDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt64BoolDictionary alloc] initWithBools:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBUInt64BoolDictionary *dict3 =
- [[GPBUInt64BoolDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt64BoolDictionary alloc] initWithBools:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBUInt64BoolDictionary *dict4 =
- [[GPBUInt64BoolDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBUInt64BoolDictionary alloc] initWithBools:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -1659,9 +1668,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBUInt64BoolDictionary *dict =
- [[GPBUInt64BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt64BoolDictionary *dict2 = [dict copy];
@@ -1680,110 +1689,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBUInt64BoolDictionary *dict =
- [[GPBUInt64BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt64BoolDictionary *dict2 =
- [GPBUInt64BoolDictionary dictionaryWithDictionary:dict];
+ [[GPBUInt64BoolDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt64BoolDictionary *dict = [GPBUInt64BoolDictionary dictionary];
+ GPBUInt64BoolDictionary *dict = [[GPBUInt64BoolDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:YES forKey:31ULL];
+ [dict setBool:YES forKey:31ULL];
XCTAssertEqual(dict.count, 1U);
const uint64_t kKeys[] = { 32ULL, 33ULL, 34ULL };
const BOOL kValues[] = { YES, NO, NO };
GPBUInt64BoolDictionary *dict2 =
- [[GPBUInt64BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
BOOL value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:31ULL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:32ULL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:33ULL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:34ULL]);
XCTAssertEqual(value, NO);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBUInt64BoolDictionary *dict =
- [[GPBUInt64BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:32ULL];
+ [dict removeBoolForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
BOOL value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:31ULL]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getBool:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getBool:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:33ULL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:34ULL]);
XCTAssertEqual(value, NO);
// Remove again does nothing.
- [dict removeValueForKey:32ULL];
+ [dict removeBoolForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:31ULL]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getBool:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getBool:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:33ULL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:34ULL]);
XCTAssertEqual(value, NO);
- [dict removeValueForKey:34ULL];
+ [dict removeBoolForKey:34ULL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:31ULL]);
XCTAssertEqual(value, YES);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getBool:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getBool:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:33ULL]);
XCTAssertEqual(value, NO);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:34ULL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:33ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:31ULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:32ULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:33ULL]);
+ XCTAssertFalse([dict getBool:NULL forKey:34ULL]);
[dict release];
}
@@ -1791,75 +1802,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const BOOL kValues[] = { YES, YES, NO, NO };
GPBUInt64BoolDictionary *dict =
- [[GPBUInt64BoolDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64BoolDictionary alloc] initWithBools:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
BOOL value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:31ULL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:32ULL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:33ULL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:34ULL]);
XCTAssertEqual(value, NO);
- [dict setValue:NO forKey:31ULL];
+ [dict setBool:NO forKey:31ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:31ULL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:32ULL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:33ULL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:34ULL]);
XCTAssertEqual(value, NO);
- [dict setValue:YES forKey:34ULL];
+ [dict setBool:YES forKey:34ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:31ULL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:32ULL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:33ULL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:34ULL]);
XCTAssertEqual(value, YES);
const uint64_t kKeys2[] = { 32ULL, 33ULL };
const BOOL kValues2[] = { NO, YES };
GPBUInt64BoolDictionary *dict2 =
- [[GPBUInt64BoolDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt64BoolDictionary alloc] initWithBools:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:31ULL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:32ULL]);
XCTAssertEqual(value, NO);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:33ULL]);
XCTAssertEqual(value, YES);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getBool:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getBool:&value forKey:34ULL]);
XCTAssertEqual(value, YES);
[dict2 release];
@@ -1879,8 +1890,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBUInt64FloatDictionary *dict = [[GPBUInt64FloatDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, float aValue, BOOL *stop) {
+ XCTAssertFalse([dict getFloat:NULL forKey:31ULL]);
+ [dict enumerateKeysAndFloatsUsingBlock:^(uint64_t aKey, float aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -1888,46 +1899,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt64FloatDictionary *dict = [GPBUInt64FloatDictionary dictionaryWithValue:500.f forKey:31ULL];
+ GPBUInt64FloatDictionary *dict = [[GPBUInt64FloatDictionary alloc] init];
+ [dict setFloat:500.f forKey:31ULL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
float value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:31ULL]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, float aValue, BOOL *stop) {
+ XCTAssertFalse([dict getFloat:NULL forKey:32ULL]);
+ [dict enumerateKeysAndFloatsUsingBlock:^(uint64_t aKey, float aValue, BOOL *stop) {
XCTAssertEqual(aKey, 31ULL);
XCTAssertEqual(aValue, 500.f);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL };
const float kValues[] = { 500.f, 501.f, 502.f };
GPBUInt64FloatDictionary *dict =
- [[GPBUInt64FloatDictionary alloc] initWithValues:kValues
+ [[GPBUInt64FloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
float value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:31ULL]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:32ULL]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:33ULL]);
XCTAssertEqual(value, 502.f);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:34ULL]);
__block NSUInteger idx = 0;
uint64_t *seenKeys = malloc(3 * sizeof(uint64_t));
float *seenValues = malloc(3 * sizeof(float));
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, float aValue, BOOL *stop) {
+ [dict enumerateKeysAndFloatsUsingBlock:^(uint64_t aKey, float aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -1949,7 +1962,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, float aValue, BOOL *stop) {
+ [dict enumerateKeysAndFloatsUsingBlock:^(uint64_t aKey, float aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -1965,27 +1978,27 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const float kValues2[] = { 500.f, 503.f, 502.f };
const float kValues3[] = { 500.f, 501.f, 502.f, 503.f };
GPBUInt64FloatDictionary *dict1 =
- [[GPBUInt64FloatDictionary alloc] initWithValues:kValues1
+ [[GPBUInt64FloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBUInt64FloatDictionary *dict1prime =
- [[GPBUInt64FloatDictionary alloc] initWithValues:kValues1
+ [[GPBUInt64FloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys1
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBUInt64FloatDictionary *dict2 =
- [[GPBUInt64FloatDictionary alloc] initWithValues:kValues2
+ [[GPBUInt64FloatDictionary alloc] initWithFloats:kValues2
forKeys:kKeys1
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBUInt64FloatDictionary *dict3 =
- [[GPBUInt64FloatDictionary alloc] initWithValues:kValues1
+ [[GPBUInt64FloatDictionary alloc] initWithFloats:kValues1
forKeys:kKeys2
count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBUInt64FloatDictionary *dict4 =
- [[GPBUInt64FloatDictionary alloc] initWithValues:kValues3
+ [[GPBUInt64FloatDictionary alloc] initWithFloats:kValues3
forKeys:kKeys1
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
@@ -2016,7 +2029,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBUInt64FloatDictionary *dict =
- [[GPBUInt64FloatDictionary alloc] initWithValues:kValues
+ [[GPBUInt64FloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
@@ -2037,33 +2050,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBUInt64FloatDictionary *dict =
- [[GPBUInt64FloatDictionary alloc] initWithValues:kValues
+ [[GPBUInt64FloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt64FloatDictionary *dict2 =
- [GPBUInt64FloatDictionary dictionaryWithDictionary:dict];
+ [[GPBUInt64FloatDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt64FloatDictionary *dict = [GPBUInt64FloatDictionary dictionary];
+ GPBUInt64FloatDictionary *dict = [[GPBUInt64FloatDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:500.f forKey:31ULL];
+ [dict setFloat:500.f forKey:31ULL];
XCTAssertEqual(dict.count, 1U);
const uint64_t kKeys[] = { 32ULL, 33ULL, 34ULL };
const float kValues[] = { 501.f, 502.f, 503.f };
GPBUInt64FloatDictionary *dict2 =
- [[GPBUInt64FloatDictionary alloc] initWithValues:kValues
+ [[GPBUInt64FloatDictionary alloc] initWithFloats:kValues
forKeys:kKeys
count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
@@ -2071,76 +2085,77 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 4U);
float value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:31ULL]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:32ULL]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:33ULL]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:34ULL]);
XCTAssertEqual(value, 503.f);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBUInt64FloatDictionary *dict =
- [[GPBUInt64FloatDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64FloatDictionary alloc] initWithFloats:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:32ULL];
+ [dict removeFloatForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
float value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:31ULL]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getFloat:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getFloat:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:33ULL]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:34ULL]);
XCTAssertEqual(value, 503.f);
// Remove again does nothing.
- [dict removeValueForKey:32ULL];
+ [dict removeFloatForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:31ULL]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getFloat:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getFloat:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:33ULL]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:34ULL]);
XCTAssertEqual(value, 503.f);
- [dict removeValueForKey:34ULL];
+ [dict removeFloatForKey:34ULL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:31ULL]);
XCTAssertEqual(value, 500.f);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getFloat:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getFloat:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:33ULL]);
XCTAssertEqual(value, 502.f);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:34ULL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:33ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:31ULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:32ULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:33ULL]);
+ XCTAssertFalse([dict getFloat:NULL forKey:34ULL]);
[dict release];
}
@@ -2148,75 +2163,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const float kValues[] = { 500.f, 501.f, 502.f, 503.f };
GPBUInt64FloatDictionary *dict =
- [[GPBUInt64FloatDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64FloatDictionary alloc] initWithFloats:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
float value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:31ULL]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:32ULL]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:33ULL]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:34ULL]);
XCTAssertEqual(value, 503.f);
- [dict setValue:503.f forKey:31ULL];
+ [dict setFloat:503.f forKey:31ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:31ULL]);
XCTAssertEqual(value, 503.f);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:32ULL]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:33ULL]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:34ULL]);
XCTAssertEqual(value, 503.f);
- [dict setValue:501.f forKey:34ULL];
+ [dict setFloat:501.f forKey:34ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:31ULL]);
XCTAssertEqual(value, 503.f);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:32ULL]);
XCTAssertEqual(value, 501.f);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:33ULL]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:34ULL]);
XCTAssertEqual(value, 501.f);
const uint64_t kKeys2[] = { 32ULL, 33ULL };
const float kValues2[] = { 502.f, 500.f };
GPBUInt64FloatDictionary *dict2 =
- [[GPBUInt64FloatDictionary alloc] initWithValues:kValues2
+ [[GPBUInt64FloatDictionary alloc] initWithFloats:kValues2
forKeys:kKeys2
count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:31ULL]);
XCTAssertEqual(value, 503.f);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:32ULL]);
XCTAssertEqual(value, 502.f);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:33ULL]);
XCTAssertEqual(value, 500.f);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getFloat:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getFloat:&value forKey:34ULL]);
XCTAssertEqual(value, 501.f);
[dict2 release];
@@ -2236,8 +2251,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBUInt64DoubleDictionary *dict = [[GPBUInt64DoubleDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, double aValue, BOOL *stop) {
+ XCTAssertFalse([dict getDouble:NULL forKey:31ULL]);
+ [dict enumerateKeysAndDoublesUsingBlock:^(uint64_t aKey, double aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -2245,46 +2260,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt64DoubleDictionary *dict = [GPBUInt64DoubleDictionary dictionaryWithValue:600. forKey:31ULL];
+ GPBUInt64DoubleDictionary *dict = [[GPBUInt64DoubleDictionary alloc] init];
+ [dict setDouble:600. forKey:31ULL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
double value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:31ULL]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, double aValue, BOOL *stop) {
+ XCTAssertFalse([dict getDouble:NULL forKey:32ULL]);
+ [dict enumerateKeysAndDoublesUsingBlock:^(uint64_t aKey, double aValue, BOOL *stop) {
XCTAssertEqual(aKey, 31ULL);
XCTAssertEqual(aValue, 600.);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL };
const double kValues[] = { 600., 601., 602. };
GPBUInt64DoubleDictionary *dict =
- [[GPBUInt64DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
double value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:31ULL]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:32ULL]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:33ULL]);
XCTAssertEqual(value, 602.);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:34ULL]);
__block NSUInteger idx = 0;
uint64_t *seenKeys = malloc(3 * sizeof(uint64_t));
double *seenValues = malloc(3 * sizeof(double));
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, double aValue, BOOL *stop) {
+ [dict enumerateKeysAndDoublesUsingBlock:^(uint64_t aKey, double aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -2306,7 +2323,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, double aValue, BOOL *stop) {
+ [dict enumerateKeysAndDoublesUsingBlock:^(uint64_t aKey, double aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -2322,29 +2339,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const double kValues2[] = { 600., 603., 602. };
const double kValues3[] = { 600., 601., 602., 603. };
GPBUInt64DoubleDictionary *dict1 =
- [[GPBUInt64DoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt64DoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBUInt64DoubleDictionary *dict1prime =
- [[GPBUInt64DoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt64DoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBUInt64DoubleDictionary *dict2 =
- [[GPBUInt64DoubleDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt64DoubleDictionary alloc] initWithDoubles:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBUInt64DoubleDictionary *dict3 =
- [[GPBUInt64DoubleDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt64DoubleDictionary alloc] initWithDoubles:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBUInt64DoubleDictionary *dict4 =
- [[GPBUInt64DoubleDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBUInt64DoubleDictionary alloc] initWithDoubles:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -2373,9 +2390,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const double kValues[] = { 600., 601., 602., 603. };
GPBUInt64DoubleDictionary *dict =
- [[GPBUInt64DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt64DoubleDictionary *dict2 = [dict copy];
@@ -2394,110 +2411,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const double kValues[] = { 600., 601., 602., 603. };
GPBUInt64DoubleDictionary *dict =
- [[GPBUInt64DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt64DoubleDictionary *dict2 =
- [GPBUInt64DoubleDictionary dictionaryWithDictionary:dict];
+ [[GPBUInt64DoubleDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt64DoubleDictionary *dict = [GPBUInt64DoubleDictionary dictionary];
+ GPBUInt64DoubleDictionary *dict = [[GPBUInt64DoubleDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:600. forKey:31ULL];
+ [dict setDouble:600. forKey:31ULL];
XCTAssertEqual(dict.count, 1U);
const uint64_t kKeys[] = { 32ULL, 33ULL, 34ULL };
const double kValues[] = { 601., 602., 603. };
GPBUInt64DoubleDictionary *dict2 =
- [[GPBUInt64DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
double value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:31ULL]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:32ULL]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:33ULL]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:34ULL]);
XCTAssertEqual(value, 603.);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const double kValues[] = { 600., 601., 602., 603. };
GPBUInt64DoubleDictionary *dict =
- [[GPBUInt64DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:32ULL];
+ [dict removeDoubleForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
double value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:31ULL]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getDouble:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getDouble:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:33ULL]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:34ULL]);
XCTAssertEqual(value, 603.);
// Remove again does nothing.
- [dict removeValueForKey:32ULL];
+ [dict removeDoubleForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:31ULL]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getDouble:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getDouble:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:33ULL]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:34ULL]);
XCTAssertEqual(value, 603.);
- [dict removeValueForKey:34ULL];
+ [dict removeDoubleForKey:34ULL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:31ULL]);
XCTAssertEqual(value, 600.);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getDouble:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getDouble:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:33ULL]);
XCTAssertEqual(value, 602.);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:34ULL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:33ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:31ULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:32ULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:33ULL]);
+ XCTAssertFalse([dict getDouble:NULL forKey:34ULL]);
[dict release];
}
@@ -2505,75 +2524,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const double kValues[] = { 600., 601., 602., 603. };
GPBUInt64DoubleDictionary *dict =
- [[GPBUInt64DoubleDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64DoubleDictionary alloc] initWithDoubles:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
double value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:31ULL]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:32ULL]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:33ULL]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:34ULL]);
XCTAssertEqual(value, 603.);
- [dict setValue:603. forKey:31ULL];
+ [dict setDouble:603. forKey:31ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:31ULL]);
XCTAssertEqual(value, 603.);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:32ULL]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:33ULL]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:34ULL]);
XCTAssertEqual(value, 603.);
- [dict setValue:601. forKey:34ULL];
+ [dict setDouble:601. forKey:34ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:31ULL]);
XCTAssertEqual(value, 603.);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:32ULL]);
XCTAssertEqual(value, 601.);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:33ULL]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:34ULL]);
XCTAssertEqual(value, 601.);
const uint64_t kKeys2[] = { 32ULL, 33ULL };
const double kValues2[] = { 602., 600. };
GPBUInt64DoubleDictionary *dict2 =
- [[GPBUInt64DoubleDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt64DoubleDictionary alloc] initWithDoubles:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:31ULL]);
XCTAssertEqual(value, 603.);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:32ULL]);
XCTAssertEqual(value, 602.);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:33ULL]);
XCTAssertEqual(value, 600.);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getDouble:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getDouble:&value forKey:34ULL]);
XCTAssertEqual(value, 601.);
[dict2 release];
@@ -2593,8 +2612,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
GPBUInt64EnumDictionary *dict = [[GPBUInt64EnumDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getEnum:NULL forKey:31ULL]);
+ [dict enumerateKeysAndEnumsUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -2602,46 +2621,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt64EnumDictionary *dict = [GPBUInt64EnumDictionary dictionaryWithValue:700 forKey:31ULL];
+ GPBUInt64EnumDictionary *dict = [[GPBUInt64EnumDictionary alloc] init];
+ [dict setEnum:700 forKey:31ULL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:31ULL]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
+ XCTAssertFalse([dict getEnum:NULL forKey:32ULL]);
+ [dict enumerateKeysAndEnumsUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertEqual(aKey, 31ULL);
XCTAssertEqual(aValue, 700);
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL };
const int32_t kValues[] = { 700, 701, 702 };
GPBUInt64EnumDictionary *dict =
- [[GPBUInt64EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:31ULL]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:32ULL]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:34ULL]);
__block NSUInteger idx = 0;
uint64_t *seenKeys = malloc(3 * sizeof(uint64_t));
int32_t *seenValues = malloc(3 * sizeof(int32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndEnumsUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -2663,7 +2684,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndEnumsUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
#pragma unused(aKey, aValue)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -2679,29 +2700,29 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const int32_t kValues2[] = { 700, 703, 702 };
const int32_t kValues3[] = { 700, 701, 702, 703 };
GPBUInt64EnumDictionary *dict1 =
- [[GPBUInt64EnumDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt64EnumDictionary alloc] initWithEnums:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1);
GPBUInt64EnumDictionary *dict1prime =
- [[GPBUInt64EnumDictionary alloc] initWithValues:kValues1
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt64EnumDictionary alloc] initWithEnums:kValues1
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict1prime);
GPBUInt64EnumDictionary *dict2 =
- [[GPBUInt64EnumDictionary alloc] initWithValues:kValues2
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt64EnumDictionary alloc] initWithEnums:kValues2
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
GPBUInt64EnumDictionary *dict3 =
- [[GPBUInt64EnumDictionary alloc] initWithValues:kValues1
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues1)];
+ [[GPBUInt64EnumDictionary alloc] initWithEnums:kValues1
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues1)];
XCTAssertNotNil(dict3);
GPBUInt64EnumDictionary *dict4 =
- [[GPBUInt64EnumDictionary alloc] initWithValues:kValues3
- forKeys:kKeys1
- count:GPBARRAYSIZE(kValues3)];
+ [[GPBUInt64EnumDictionary alloc] initWithEnums:kValues3
+ forKeys:kKeys1
+ count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(dict4);
// 1/1Prime should be different objects, but equal.
@@ -2730,9 +2751,9 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBUInt64EnumDictionary *dict =
- [[GPBUInt64EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt64EnumDictionary *dict2 = [dict copy];
@@ -2751,110 +2772,112 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBUInt64EnumDictionary *dict =
- [[GPBUInt64EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
GPBUInt64EnumDictionary *dict2 =
- [GPBUInt64EnumDictionary dictionaryWithDictionary:dict];
+ [[GPBUInt64EnumDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt64EnumDictionary *dict = [GPBUInt64EnumDictionary dictionary];
+ GPBUInt64EnumDictionary *dict = [[GPBUInt64EnumDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- [dict setValue:700 forKey:31ULL];
+ [dict setEnum:700 forKey:31ULL];
XCTAssertEqual(dict.count, 1U);
const uint64_t kKeys[] = { 32ULL, 33ULL, 34ULL };
const int32_t kValues[] = { 701, 702, 703 };
GPBUInt64EnumDictionary *dict2 =
- [[GPBUInt64EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:31ULL]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:32ULL]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:34ULL]);
XCTAssertEqual(value, 703);
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBUInt64EnumDictionary *dict =
- [[GPBUInt64EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:32ULL];
+ [dict removeEnumForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:31ULL]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:34ULL]);
XCTAssertEqual(value, 703);
// Remove again does nothing.
- [dict removeValueForKey:32ULL];
+ [dict removeEnumForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:31ULL]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:34ULL]);
XCTAssertEqual(value, 703);
- [dict removeValueForKey:34ULL];
+ [dict removeEnumForKey:34ULL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:31ULL]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:34ULL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:33ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:34ULL]);
[dict release];
}
@@ -2862,75 +2885,75 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const int32_t kValues[] = { 700, 701, 702, 703 };
GPBUInt64EnumDictionary *dict =
- [[GPBUInt64EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:31ULL]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:32ULL]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:34ULL]);
XCTAssertEqual(value, 703);
- [dict setValue:703 forKey:31ULL];
+ [dict setEnum:703 forKey:31ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:31ULL]);
XCTAssertEqual(value, 703);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:32ULL]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:34ULL]);
XCTAssertEqual(value, 703);
- [dict setValue:701 forKey:34ULL];
+ [dict setEnum:701 forKey:34ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:31ULL]);
XCTAssertEqual(value, 703);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:32ULL]);
XCTAssertEqual(value, 701);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:34ULL]);
XCTAssertEqual(value, 701);
const uint64_t kKeys2[] = { 32ULL, 33ULL };
const int32_t kValues2[] = { 702, 700 };
GPBUInt64EnumDictionary *dict2 =
- [[GPBUInt64EnumDictionary alloc] initWithValues:kValues2
- forKeys:kKeys2
- count:GPBARRAYSIZE(kValues2)];
+ [[GPBUInt64EnumDictionary alloc] initWithEnums:kValues2
+ forKeys:kKeys2
+ count:GPBARRAYSIZE(kValues2)];
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:31ULL]);
XCTAssertEqual(value, 703);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:32ULL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:34ULL]);
XCTAssertEqual(value, 701);
[dict2 release];
@@ -2958,24 +2981,24 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 3U);
XCTAssertTrue(dict.validationFunc == TestingEnum_IsValidValue); // Pointer comparison
int32_t value;
- XCTAssertTrue([dict valueForKey:31ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:31ULL]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:32ULL]);
XCTAssertEqual(value, kGPBUnrecognizedEnumeratorValue);
- XCTAssertTrue([dict valueForKey:32ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:32ULL]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:33ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:34ULL rawValue:NULL]);
+ XCTAssertFalse([dict getRawValue:NULL forKey:34ULL]);
__block NSUInteger idx = 0;
uint64_t *seenKeys = malloc(3 * sizeof(uint64_t));
int32_t *seenValues = malloc(3 * sizeof(int32_t));
- [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
+ [dict enumerateKeysAndEnumsUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenValues[idx] = aValue;
@@ -3120,23 +3143,24 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBUInt64EnumDictionary *dict2 =
- [GPBUInt64EnumDictionary dictionaryWithDictionary:dict];
+ [[GPBUInt64EnumDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
XCTAssertEqual(dict.validationFunc, dict2.validationFunc); // Pointer comparison
+ [dict2 release];
[dict release];
}
- (void)testUnknownAdds {
GPBUInt64EnumDictionary *dict =
- [GPBUInt64EnumDictionary dictionaryWithValidationFunction:TestingEnum_IsValidValue];
+ [[GPBUInt64EnumDictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
- XCTAssertThrowsSpecificNamed([dict setValue:801 forKey:32ULL], // Unknown
+ XCTAssertThrowsSpecificNamed([dict setEnum:801 forKey:32ULL], // Unknown
NSException, NSInvalidArgumentException);
XCTAssertEqual(dict.count, 0U);
[dict setRawValue:801 forKey:32ULL]; // Unknown
@@ -3145,33 +3169,34 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
const uint64_t kKeys[] = { 31ULL, 33ULL, 34ULL };
const int32_t kValues[] = { 700, 702, 803 }; // Unknown
GPBUInt64EnumDictionary *dict2 =
- [[GPBUInt64EnumDictionary alloc] initWithValues:kValues
- forKeys:kKeys
- count:GPBARRAYSIZE(kValues)];
+ [[GPBUInt64EnumDictionary alloc] initWithEnums:kValues
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:31ULL]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:32ULL]);
XCTAssertEqual(value, kGPBUnrecognizedEnumeratorValue);
- XCTAssertTrue([dict valueForKey:32ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:32ULL]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:34ULL]);
XCTAssertEqual(value, kGPBUnrecognizedEnumeratorValue);
- XCTAssertTrue([dict valueForKey:34ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:34ULL]);
XCTAssertEqual(value, 803);
[dict2 release];
+ [dict release];
}
- (void)testUnknownRemove {
@@ -3185,51 +3210,51 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
- [dict removeValueForKey:32ULL];
+ [dict removeEnumForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
int32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:31ULL]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:34ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:34ULL]);
XCTAssertEqual(value, 803);
// Remove again does nothing.
- [dict removeValueForKey:32ULL];
+ [dict removeEnumForKey:32ULL];
XCTAssertEqual(dict.count, 3U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:31ULL]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:34ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:34ULL]);
XCTAssertEqual(value, 803);
- [dict removeValueForKey:34ULL];
+ [dict removeEnumForKey:34ULL];
XCTAssertEqual(dict.count, 2U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:31ULL]);
XCTAssertEqual(value, 700);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertFalse([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:34ULL]);
[dict removeAll];
XCTAssertEqual(dict.count, 0U);
- XCTAssertFalse([dict valueForKey:31ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:32ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:33ULL value:NULL]);
- XCTAssertFalse([dict valueForKey:34ULL value:NULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertFalse([dict getEnum:NULL forKey:34ULL]);
[dict release];
}
@@ -3244,63 +3269,63 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
int32_t value;
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:31ULL]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:32ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:32ULL]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:34ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:34ULL]);
XCTAssertEqual(value, 803);
- XCTAssertThrowsSpecificNamed([dict setValue:803 forKey:31ULL], // Unknown
+ XCTAssertThrowsSpecificNamed([dict setEnum:803 forKey:31ULL], // Unknown
NSException, NSInvalidArgumentException);
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:31ULL]);
XCTAssertEqual(value, 700);
- XCTAssertTrue([dict valueForKey:32ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:32ULL]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:34ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:34ULL]);
XCTAssertEqual(value, 803);
[dict setRawValue:803 forKey:31ULL]; // Unknown
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:31ULL]);
XCTAssertEqual(value, 803);
- XCTAssertTrue([dict valueForKey:32ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:32ULL]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:34ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:34ULL]);
XCTAssertEqual(value, 803);
[dict setRawValue:700 forKey:34ULL];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:31ULL]);
XCTAssertEqual(value, 803);
- XCTAssertTrue([dict valueForKey:32ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:32ULL]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:33ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:33ULL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:34ULL]);
XCTAssertEqual(value, 700);
const uint64_t kKeys2[] = { 32ULL, 33ULL };
@@ -3313,17 +3338,17 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict2);
[dict addRawEntriesFromDictionary:dict2];
XCTAssertEqual(dict.count, 4U);
- XCTAssertTrue([dict valueForKey:31ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:31ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:31ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:31ULL]);
XCTAssertEqual(value, 803);
- XCTAssertTrue([dict valueForKey:32ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:32ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:32ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:32ULL]);
XCTAssertEqual(value, 702);
- XCTAssertTrue([dict valueForKey:33ULL rawValue:NULL]);
- XCTAssertTrue([dict valueForKey:33ULL rawValue:&value]);
+ XCTAssertTrue([dict getRawValue:NULL forKey:33ULL]);
+ XCTAssertTrue([dict getRawValue:&value forKey:33ULL]);
XCTAssertEqual(value, 801);
- XCTAssertTrue([dict valueForKey:34ULL value:NULL]);
- XCTAssertTrue([dict valueForKey:34ULL value:&value]);
+ XCTAssertTrue([dict getEnum:NULL forKey:34ULL]);
+ XCTAssertTrue([dict getEnum:&value forKey:34ULL]);
XCTAssertEqual(value, 700);
[dict2 release];
@@ -3363,11 +3388,11 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
@implementation GPBUInt64ObjectDictionaryTests
- (void)testEmpty {
- GPBUInt64ObjectDictionary *dict = [[GPBUInt64ObjectDictionary alloc] init];
+ GPBUInt64ObjectDictionary<NSString*> *dict = [[GPBUInt64ObjectDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
XCTAssertNil([dict objectForKey:31ULL]);
- [dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, id aObject, BOOL *stop) {
+ [dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, NSString* aObject, BOOL *stop) {
#pragma unused(aKey, aObject, stop)
XCTFail(@"Shouldn't get here!");
}];
@@ -3375,22 +3400,24 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
- GPBUInt64ObjectDictionary *dict = [GPBUInt64ObjectDictionary dictionaryWithObject:@"abc" forKey:31ULL];
+ GPBUInt64ObjectDictionary<NSString*> *dict = [[GPBUInt64ObjectDictionary alloc] init];
+ [dict setObject:@"abc" forKey:31ULL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
XCTAssertEqualObjects([dict objectForKey:31ULL], @"abc");
XCTAssertNil([dict objectForKey:32ULL]);
- [dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, id aObject, BOOL *stop) {
+ [dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, NSString* aObject, BOOL *stop) {
XCTAssertEqual(aKey, 31ULL);
XCTAssertEqualObjects(aObject, @"abc");
XCTAssertNotEqual(stop, NULL);
}];
+ [dict release];
}
- (void)testBasics {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL };
- const id kObjects[] = { @"abc", @"def", @"ghi" };
- GPBUInt64ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi" };
+ GPBUInt64ObjectDictionary<NSString*> *dict =
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
@@ -3403,8 +3430,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
__block NSUInteger idx = 0;
uint64_t *seenKeys = malloc(3 * sizeof(uint64_t));
- id *seenObjects = malloc(3 * sizeof(id));
- [dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, id aObject, BOOL *stop) {
+ NSString* *seenObjects = malloc(3 * sizeof(NSString*));
+ [dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, NSString* aObject, BOOL *stop) {
XCTAssertLessThan(idx, 3U);
seenKeys[idx] = aKey;
seenObjects[idx] = aObject;
@@ -3426,7 +3453,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
// Stopping the enumeration.
idx = 0;
- [dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, id aObject, BOOL *stop) {
+ [dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, NSString* aObject, BOOL *stop) {
#pragma unused(aKey, aObject)
if (idx == 1) *stop = YES;
XCTAssertNotEqual(idx, 2U);
@@ -3438,30 +3465,30 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
- (void)testEquality {
const uint64_t kKeys1[] = { 31ULL, 32ULL, 33ULL, 34ULL };
const uint64_t kKeys2[] = { 32ULL, 31ULL, 34ULL };
- const id kObjects1[] = { @"abc", @"def", @"ghi" };
- const id kObjects2[] = { @"abc", @"jkl", @"ghi" };
- const id kObjects3[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBUInt64ObjectDictionary *dict1 =
+ const NSString* kObjects1[] = { @"abc", @"def", @"ghi" };
+ const NSString* kObjects2[] = { @"abc", @"jkl", @"ghi" };
+ const NSString* kObjects3[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBUInt64ObjectDictionary<NSString*> *dict1 =
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects1
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects1)];
XCTAssertNotNil(dict1);
- GPBUInt64ObjectDictionary *dict1prime =
+ GPBUInt64ObjectDictionary<NSString*> *dict1prime =
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects1
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects1)];
XCTAssertNotNil(dict1prime);
- GPBUInt64ObjectDictionary *dict2 =
+ GPBUInt64ObjectDictionary<NSString*> *dict2 =
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects2
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects2)];
XCTAssertNotNil(dict2);
- GPBUInt64ObjectDictionary *dict3 =
+ GPBUInt64ObjectDictionary<NSString*> *dict3 =
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects1
forKeys:kKeys2
count:GPBARRAYSIZE(kObjects1)];
XCTAssertNotNil(dict3);
- GPBUInt64ObjectDictionary *dict4 =
+ GPBUInt64ObjectDictionary<NSString*> *dict4 =
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects3
forKeys:kKeys1
count:GPBARRAYSIZE(kObjects3)];
@@ -3491,14 +3518,14 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
- (void)testCopy {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
- const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBUInt64ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBUInt64ObjectDictionary<NSString*> *dict =
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
- GPBUInt64ObjectDictionary *dict2 = [dict copy];
+ GPBUInt64ObjectDictionary<NSString*> *dict2 = [dict copy];
XCTAssertNotNil(dict2);
// Should be new object but equal.
@@ -3512,25 +3539,26 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
- (void)testDictionaryFromDictionary {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
- const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBUInt64ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBUInt64ObjectDictionary<NSString*> *dict =
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
- GPBUInt64ObjectDictionary *dict2 =
- [GPBUInt64ObjectDictionary dictionaryWithDictionary:dict];
+ GPBUInt64ObjectDictionary<NSString*> *dict2 =
+ [[GPBUInt64ObjectDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
+ [dict2 release];
[dict release];
}
- (void)testAdds {
- GPBUInt64ObjectDictionary *dict = [GPBUInt64ObjectDictionary dictionary];
+ GPBUInt64ObjectDictionary<NSString*> *dict = [[GPBUInt64ObjectDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@@ -3538,8 +3566,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(dict.count, 1U);
const uint64_t kKeys[] = { 32ULL, 33ULL, 34ULL };
- const id kObjects[] = { @"def", @"ghi", @"jkl" };
- GPBUInt64ObjectDictionary *dict2 =
+ const NSString* kObjects[] = { @"def", @"ghi", @"jkl" };
+ GPBUInt64ObjectDictionary<NSString*> *dict2 =
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects
forKeys:kKeys
count:GPBARRAYSIZE(kObjects)];
@@ -3552,15 +3580,16 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqualObjects([dict objectForKey:33ULL], @"ghi");
XCTAssertEqualObjects([dict objectForKey:34ULL], @"jkl");
[dict2 release];
+ [dict release];
}
- (void)testRemove {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
- const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBUInt64ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBUInt64ObjectDictionary<NSString*> *dict =
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects
- forKeys:kKeys
- count:GPBARRAYSIZE(kObjects)];
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
@@ -3597,11 +3626,11 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
- (void)testInplaceMutation {
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
- const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
- GPBUInt64ObjectDictionary *dict =
+ const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
+ GPBUInt64ObjectDictionary<NSString*> *dict =
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects
- forKeys:kKeys
- count:GPBARRAYSIZE(kObjects)];
+ forKeys:kKeys
+ count:GPBARRAYSIZE(kObjects)];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 4U);
XCTAssertEqualObjects([dict objectForKey:31ULL], @"abc");
@@ -3624,8 +3653,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqualObjects([dict objectForKey:34ULL], @"def");
const uint64_t kKeys2[] = { 32ULL, 33ULL };
- const id kObjects2[] = { @"ghi", @"abc" };
- GPBUInt64ObjectDictionary *dict2 =
+ const NSString* kObjects2[] = { @"ghi", @"abc" };
+ GPBUInt64ObjectDictionary<NSString*> *dict2 =
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects2
forKeys:kKeys2
count:GPBARRAYSIZE(kObjects2)];
diff --git a/objectivec/Tests/GPBDictionaryTests.m b/objectivec/Tests/GPBDictionaryTests.m
new file mode 100644
index 00000000..52b4b328
--- /dev/null
+++ b/objectivec/Tests/GPBDictionaryTests.m
@@ -0,0 +1,186 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2017 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#import <Foundation/Foundation.h>
+#import <XCTest/XCTest.h>
+
+#import "GPBDictionary.h"
+#import "GPBDictionary_PackagePrivate.h"
+
+#import "GPBTestUtilities.h"
+
+#pragma mark - GPBAutocreatedDictionary Tests
+
+// These are hand written tests to double check some behaviors of the
+// GPBAutocreatedDictionary. The GPBDictionary+[type]Tests files are generate
+// tests.
+
+// NOTE: GPBAutocreatedDictionary is private to the library, users of the
+// library should never have to directly deal with this class.
+
+@interface GPBAutocreatedDictionaryTests : XCTestCase
+@end
+
+@implementation GPBAutocreatedDictionaryTests
+
+- (void)testEquality {
+ GPBAutocreatedDictionary *dict = [[GPBAutocreatedDictionary alloc] init];
+
+ XCTAssertTrue([dict isEqual:@{}]);
+ XCTAssertTrue([dict isEqualToDictionary:@{}]);
+
+ XCTAssertFalse([dict isEqual:@{ @"foo" : @"bar" }]);
+ XCTAssertFalse([dict isEqualToDictionary:@{ @"foo" : @"bar" }]);
+
+ [dict setObject:@"bar" forKey:@"foo"];
+
+ XCTAssertFalse([dict isEqual:@{}]);
+ XCTAssertFalse([dict isEqualToDictionary:@{}]);
+ XCTAssertTrue([dict isEqual:@{ @"foo" : @"bar" }]);
+ XCTAssertTrue([dict isEqualToDictionary:@{ @"foo" : @"bar" }]);
+ XCTAssertFalse([dict isEqual:@{ @"bar" : @"baz" }]);
+ XCTAssertFalse([dict isEqualToDictionary:@{ @"bar" : @"baz" }]);
+
+ GPBAutocreatedDictionary *dict2 = [[GPBAutocreatedDictionary alloc] init];
+
+ XCTAssertFalse([dict isEqual:dict2]);
+ XCTAssertFalse([dict isEqualToDictionary:dict2]);
+
+ [dict2 setObject:@"mumble" forKey:@"foo"];
+ XCTAssertFalse([dict isEqual:dict2]);
+ XCTAssertFalse([dict isEqualToDictionary:dict2]);
+
+ [dict2 setObject:@"bar" forKey:@"foo"];
+ XCTAssertTrue([dict isEqual:dict2]);
+ XCTAssertTrue([dict isEqualToDictionary:dict2]);
+
+ [dict2 release];
+ [dict release];
+}
+
+- (void)testCopy {
+ {
+ GPBAutocreatedDictionary *dict = [[GPBAutocreatedDictionary alloc] init];
+
+ NSDictionary *cpy = [dict copy];
+ XCTAssertTrue(cpy != dict); // Ptr compare
+ XCTAssertTrue([cpy isKindOfClass:[NSDictionary class]]);
+ XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedDictionary class]]);
+ XCTAssertEqual(cpy.count, (NSUInteger)0);
+
+ NSDictionary *cpy2 = [dict copy];
+ XCTAssertTrue(cpy2 != dict); // Ptr compare
+ XCTAssertTrue(cpy2 != cpy); // Ptr compare
+ XCTAssertTrue([cpy2 isKindOfClass:[NSDictionary class]]);
+ XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedDictionary class]]);
+ XCTAssertEqual(cpy2.count, (NSUInteger)0);
+
+ [cpy2 release];
+ [cpy release];
+ [dict release];
+ }
+
+ {
+ GPBAutocreatedDictionary *dict = [[GPBAutocreatedDictionary alloc] init];
+
+ NSMutableDictionary *cpy = [dict mutableCopy];
+ XCTAssertTrue(cpy != dict); // Ptr compare
+ XCTAssertTrue([cpy isKindOfClass:[NSMutableDictionary class]]);
+ XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedDictionary class]]);
+ XCTAssertEqual(cpy.count, (NSUInteger)0);
+
+ NSMutableDictionary *cpy2 = [dict mutableCopy];
+ XCTAssertTrue(cpy2 != dict); // Ptr compare
+ XCTAssertTrue(cpy2 != cpy); // Ptr compare
+ XCTAssertTrue([cpy2 isKindOfClass:[NSMutableDictionary class]]);
+ XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedDictionary class]]);
+ XCTAssertEqual(cpy2.count, (NSUInteger)0);
+
+ [cpy2 release];
+ [cpy release];
+ [dict release];
+ }
+
+ {
+ GPBAutocreatedDictionary *dict = [[GPBAutocreatedDictionary alloc] init];
+ dict[@"foo"] = @"bar";
+ dict[@"baz"] = @"mumble";
+
+ NSDictionary *cpy = [dict copy];
+ XCTAssertTrue(cpy != dict); // Ptr compare
+ XCTAssertTrue([cpy isKindOfClass:[NSDictionary class]]);
+ XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedDictionary class]]);
+ XCTAssertEqual(cpy.count, (NSUInteger)2);
+ XCTAssertEqualObjects(cpy[@"foo"], @"bar");
+ XCTAssertEqualObjects(cpy[@"baz"], @"mumble");
+
+ NSDictionary *cpy2 = [dict copy];
+ XCTAssertTrue(cpy2 != dict); // Ptr compare
+ XCTAssertTrue(cpy2 != cpy); // Ptr compare
+ XCTAssertTrue([cpy2 isKindOfClass:[NSDictionary class]]);
+ XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedDictionary class]]);
+ XCTAssertEqual(cpy2.count, (NSUInteger)2);
+ XCTAssertEqualObjects(cpy2[@"foo"], @"bar");
+ XCTAssertEqualObjects(cpy2[@"baz"], @"mumble");
+
+ [cpy2 release];
+ [cpy release];
+ [dict release];
+ }
+
+ {
+ GPBAutocreatedDictionary *dict = [[GPBAutocreatedDictionary alloc] init];
+ dict[@"foo"] = @"bar";
+ dict[@"baz"] = @"mumble";
+
+ NSMutableDictionary *cpy = [dict mutableCopy];
+ XCTAssertTrue(cpy != dict); // Ptr compare
+ XCTAssertTrue([cpy isKindOfClass:[NSMutableDictionary class]]);
+ XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedDictionary class]]);
+ XCTAssertEqual(cpy.count, (NSUInteger)2);
+ XCTAssertEqualObjects(cpy[@"foo"], @"bar");
+ XCTAssertEqualObjects(cpy[@"baz"], @"mumble");
+
+ NSMutableDictionary *cpy2 = [dict mutableCopy];
+ XCTAssertTrue(cpy2 != dict); // Ptr compare
+ XCTAssertTrue(cpy2 != cpy); // Ptr compare
+ XCTAssertTrue([cpy2 isKindOfClass:[NSMutableDictionary class]]);
+ XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedDictionary class]]);
+ XCTAssertEqual(cpy2.count, (NSUInteger)2);
+ XCTAssertEqualObjects(cpy2[@"foo"], @"bar");
+ XCTAssertEqualObjects(cpy2[@"baz"], @"mumble");
+
+ [cpy2 release];
+ [cpy release];
+ [dict release];
+ }
+}
+
+@end
diff --git a/objectivec/Tests/GPBDictionaryTests.pddm b/objectivec/Tests/GPBDictionaryTests.pddm
index ada93c64..17f12c28 100644
--- a/objectivec/Tests/GPBDictionaryTests.pddm
+++ b/objectivec/Tests/GPBDictionaryTests.pddm
@@ -30,7 +30,7 @@
//%PDDM-DEFINE TEST_FOR_POD_KEY(KEY_NAME, KEY_TYPE, KEY1, KEY2, KEY3, KEY4)
//%TESTS_FOR_POD_VALUES(KEY_NAME, KEY_TYPE, , , KEY1, KEY2, KEY3, KEY4)
-//%TESTS_FOR_POD_KEY_OBJECT_VALUE(KEY_NAME, KEY_TYPE, KEY1, KEY2, KEY3, KEY4, Object, id, @"abc", @"def", @"ghi", @"jkl")
+//%TESTS_FOR_POD_KEY_OBJECT_VALUE(KEY_NAME, KEY_TYPE, KEY1, KEY2, KEY3, KEY4, Object, NSString*, @"abc", @"def", @"ghi", @"jkl")
//%PDDM-DEFINE TESTS_FOR_POD_VALUES(KEY_NAME, KEY_TYPE, KisP, KSUFFIX, KEY1, KEY2, KEY3, KEY4)
//%TEST_HELPERS(KEY_NAME, KEY_TYPE, KisP)
@@ -50,6 +50,13 @@
//%PDDM-DEFINE TESTS_FOR_POD_KEY_OBJECT_VALUE(KEY_NAME, KEY_TYPE, KEY1, KEY2, KEY3, KEY4, VALUE_NAME, VALUE_TYPE, VAL1, VAL2, VAL3, VAL4)
//%TESTS_COMMON(KEY_NAME, KEY_TYPE, , , KEY1, KEY2, KEY3, KEY4, VALUE_NAME, VALUE_TYPE, Objects, object, OBJECT, , VAL1, VAL2, VAL3, VAL4)
+//%PDDM-DEFINE DICTIONARY_CLASS_DECLPOD(KEY_NAME, VALUE_NAME, VALUE_TYPE)
+//%GPB##KEY_NAME##VALUE_NAME##Dictionary
+//%PDDM-DEFINE DICTIONARY_CLASS_DECLEnum(KEY_NAME, VALUE_NAME, VALUE_TYPE)
+//%GPB##KEY_NAME##VALUE_NAME##Dictionary
+//%PDDM-DEFINE DICTIONARY_CLASS_DECLOBJECT(KEY_NAME, VALUE_NAME, VALUE_TYPE)
+//%GPB##KEY_NAME##VALUE_NAME##Dictionary<VALUE_TYPE>
+
//%PDDM-DEFINE TESTS_COMMON(KEY_NAME, KEY_TYPE, KisP, KSUFFIX, KEY1, KEY2, KEY3, KEY4, VALUE_NAME, VALUE_TYPE, VSUFFIX, VNAME, VHELPER, VACCESSOR, VAL1, VAL2, VAL3, VAL4)
//%#pragma mark - KEY_NAME -> VALUE_NAME
//%
@@ -59,11 +66,11 @@
//%@implementation GPB##KEY_NAME##VALUE_NAME##DictionaryTests
//%
//%- (void)testEmpty {
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict = [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] init];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict = [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] init];
//% XCTAssertNotNil(dict);
//% XCTAssertEqual(dict.count, 0U);
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY1)
-//% [dict enumerateKeysAnd##VNAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u, BOOL *stop) {
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY1)
+//% [dict enumerateKeysAnd##VALUE_NAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u, BOOL *stop) {
//% #pragma unused(aKey, a##VNAME$u, stop)
//% XCTFail(@"Shouldn't get here!");
//% }];
@@ -71,36 +78,38 @@
//%}
//%
//%- (void)testOne {
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict = [GPB##KEY_NAME##VALUE_NAME##Dictionary dictionaryWith##VNAME$u##:VAL1 forKey:KEY1];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict = [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] init];
+//% [dict set##VALUE_NAME$u##:VAL1 forKey:KEY1];
//% XCTAssertNotNil(dict);
//% XCTAssertEqual(dict.count, 1U);
-//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
-//% [dict enumerateKeysAnd##VNAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u, BOOL *stop) {
+//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL1)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY2)
+//% [dict enumerateKeysAnd##VALUE_NAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u, BOOL *stop) {
//% XCTAssertEqual##KSUFFIX(aKey, KEY1);
//% XCTAssertEqual##VSUFFIX(a##VNAME$u, VAL1);
//% XCTAssertNotEqual(stop, NULL);
//% }];
+//% [dict release];
//%}
//%
//%- (void)testBasics {
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2, KEY3 };
//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2, VAL3 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME$u##s:k##VNAME$u##s
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
//% XCTAssertNotNil(dict);
//% XCTAssertEqual(dict.count, 3U);
-//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY3, VAL3)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY4)
+//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL1)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY2, VAL2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY3, VAL3)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY4)
//%
//% __block NSUInteger idx = 0;
//% KEY_TYPE KisP##*seenKeys = malloc(3 * sizeof(KEY_TYPE##KisP));
//% VALUE_TYPE *seen##VNAME$u##s = malloc(3 * sizeof(VALUE_TYPE));
-//% [dict enumerateKeysAnd##VNAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u, BOOL *stop) {
+//% [dict enumerateKeysAnd##VALUE_NAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u, BOOL *stop) {
//% XCTAssertLessThan(idx, 3U);
//% seenKeys[idx] = aKey;
//% seen##VNAME$u##s[idx] = a##VNAME$u##;
@@ -122,7 +131,7 @@
//%
//% // Stopping the enumeration.
//% idx = 0;
-//% [dict enumerateKeysAnd##VNAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u, BOOL *stop) {
+//% [dict enumerateKeysAnd##VALUE_NAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u, BOOL *stop) {
//% #pragma unused(aKey, a##VNAME$u)
//% if (idx == 1) *stop = YES;
//% XCTAssertNotEqual(idx, 2U);
@@ -137,30 +146,30 @@
//% const VALUE_TYPE k##VNAME$u##s1[] = { VAL1, VAL2, VAL3 };
//% const VALUE_TYPE k##VNAME$u##s2[] = { VAL1, VAL4, VAL3 };
//% const VALUE_TYPE k##VNAME$u##s3[] = { VAL1, VAL2, VAL3, VAL4 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict1 =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s1
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys1
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s1)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict1 =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s1
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys1
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s1)];
//% XCTAssertNotNil(dict1);
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict1prime =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s1
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys1
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s1)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict1prime =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s1
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys1
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s1)];
//% XCTAssertNotNil(dict1prime);
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s2
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys1
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s2)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s2
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys1
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s2)];
//% XCTAssertNotNil(dict2);
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict3 =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s1
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys2
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s1)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict3 =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s1
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys2
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s1)];
//% XCTAssertNotNil(dict3);
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict4 =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s3
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys1
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s3)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict4 =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s3
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys1
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s3)];
//% XCTAssertNotNil(dict4);
//%
//% // 1/1Prime should be different objects, but equal.
@@ -188,13 +197,13 @@
//%- (void)testCopy {
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2, KEY3, KEY4 };
//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2, VAL3, VAL4 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
//% XCTAssertNotNil(dict);
//%
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 = [dict copy];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 = [dict copy];
//% XCTAssertNotNil(dict2);
//%
//% // Should be new object but equal.
@@ -209,129 +218,131 @@
//%- (void)testDictionaryFromDictionary {
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2, KEY3, KEY4 };
//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2, VAL3, VAL4 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
//% XCTAssertNotNil(dict);
//%
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 =
-//% [GPB##KEY_NAME##VALUE_NAME##Dictionary dictionaryWithDictionary:dict];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithDictionary:dict];
//% XCTAssertNotNil(dict2);
//%
//% // Should be new pointer, but equal objects.
//% XCTAssertNotEqual(dict, dict2);
//% XCTAssertEqualObjects(dict, dict2);
+//% [dict2 release];
//% [dict release];
//%}
//%
//%- (void)testAdds {
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict = [GPB##KEY_NAME##VALUE_NAME##Dictionary dictionary];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict = [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] init];
//% XCTAssertNotNil(dict);
//%
//% XCTAssertEqual(dict.count, 0U);
-//% [dict set##VNAME$u##:VAL1 forKey:KEY1];
+//% [dict set##VALUE_NAME##:VAL1 forKey:KEY1];
//% XCTAssertEqual(dict.count, 1U);
//%
//% const KEY_TYPE KisP##kKeys[] = { KEY2, KEY3, KEY4 };
//% const VALUE_TYPE k##VNAME$u##s[] = { VAL2, VAL3, VAL4 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
//% XCTAssertNotNil(dict2);
//% [dict add##VACCESSOR##EntriesFromDictionary:dict2];
//% XCTAssertEqual(dict.count, 4U);
//%
-//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY3, VAL3)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY4, VAL4)
+//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL1)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY2, VAL2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY3, VAL3)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY4, VAL4)
//% [dict2 release];
+//% [dict release];
//%}
//%
//%- (void)testRemove {
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2, KEY3, KEY4 };
//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2, VAL3, VAL4 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
//% XCTAssertNotNil(dict);
//% XCTAssertEqual(dict.count, 4U);
//%
-//% [dict remove##VNAME$u##ForKey:KEY2];
+//% [dict remove##VALUE_NAME##ForKey:KEY2];
//% XCTAssertEqual(dict.count, 3U);
-//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY3, VAL3)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY4, VAL4)
+//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL1)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY3, VAL3)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY4, VAL4)
//%
//% // Remove again does nothing.
-//% [dict remove##VNAME$u##ForKey:KEY2];
+//% [dict remove##VALUE_NAME##ForKey:KEY2];
//% XCTAssertEqual(dict.count, 3U);
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY3, VAL3)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY4, VAL4)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL1)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY3, VAL3)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY4, VAL4)
//%
-//% [dict remove##VNAME$u##ForKey:KEY4];
+//% [dict remove##VALUE_NAME##ForKey:KEY4];
//% XCTAssertEqual(dict.count, 2U);
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY3, VAL3)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY4)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL1)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY3, VAL3)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY4)
//%
//% [dict removeAll];
//% XCTAssertEqual(dict.count, 0U);
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY1)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY3)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY4)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY1)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY2)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY3)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY4)
//% [dict release];
//%}
//%
//%- (void)testInplaceMutation {
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2, KEY3, KEY4 };
//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2, VAL3, VAL4 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
//% XCTAssertNotNil(dict);
//% XCTAssertEqual(dict.count, 4U);
-//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY3, VAL3)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY4, VAL4)
+//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL1)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY2, VAL2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY3, VAL3)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY4, VAL4)
//%
-//% [dict set##VNAME$u##:VAL4 forKey:KEY1];
+//% [dict set##VALUE_NAME##:VAL4 forKey:KEY1];
//% XCTAssertEqual(dict.count, 4U);
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL4)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY3, VAL3)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY4, VAL4)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL4)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY2, VAL2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY3, VAL3)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY4, VAL4)
//%
-//% [dict set##VNAME$u##:VAL2 forKey:KEY4];
+//% [dict set##VALUE_NAME##:VAL2 forKey:KEY4];
//% XCTAssertEqual(dict.count, 4U);
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL4)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY3, VAL3)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY4, VAL2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL4)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY2, VAL2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY3, VAL3)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY4, VAL2)
//%
//% const KEY_TYPE KisP##kKeys2[] = { KEY2, KEY3 };
//% const VALUE_TYPE k##VNAME$u##s2[] = { VAL3, VAL1 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s2
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys2
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s2)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s2
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys2
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s2)];
//% XCTAssertNotNil(dict2);
//% [dict add##VACCESSOR##EntriesFromDictionary:dict2];
//% XCTAssertEqual(dict.count, 4U);
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL4)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL3)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY3, VAL1)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY4, VAL2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL4)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY2, VAL3)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY3, VAL1)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY4, VAL2)
//%
//% [dict2 release];
//% [dict release];
@@ -353,7 +364,7 @@
//%- (void)testRawBasics {
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2, KEY3 };
//% const VALUE_TYPE kValues[] = { VAL1, VAL2, VAL3 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue
//% KEY_NAME$S VALUE_NAME$S rawValues:kValues
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys
@@ -362,15 +373,15 @@
//% XCTAssertEqual(dict.count, 3U);
//% XCTAssertTrue(dict.validationFunc == TestingEnum_IsValidValue); // Pointer comparison
//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_RAW_VALUE##VHELPER(dict, value, KEY1, VAL1)
-//%TEST_VALUE##VHELPER(dict, value, KEY2, kGPBUnrecognizedEnumeratorValue)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY2, kGPBUnrecognizedEnumeratorValue)
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY2, VAL2)
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY3, VAL3)
-//%RAW_VALUE_NOT_FOUND##VHELPER(dict, KEY4)
+//%RAW_VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY4)
//%
//% __block NSUInteger idx = 0;
//% KEY_TYPE KisP##*seenKeys = malloc(3 * sizeof(KEY_TYPE##KisP));
//% VALUE_TYPE *seenValues = malloc(3 * sizeof(VALUE_TYPE));
-//% [dict enumerateKeysAndValuesUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE aValue, BOOL *stop) {
+//% [dict enumerateKeysAndEnumsUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE aValue, BOOL *stop) {
//% XCTAssertLessThan(idx, 3U);
//% seenKeys[idx] = aKey;
//% seenValues[idx] = aValue;
@@ -429,31 +440,31 @@
//% const VALUE_TYPE kValues1[] = { VAL1, VAL2, VAL3 }; // Unknown
//% const VALUE_TYPE kValues2[] = { VAL1, VAL4, VAL3 }; // Unknown
//% const VALUE_TYPE kValues3[] = { VAL1, VAL2, VAL3, VAL4 }; // Unknowns
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict1 =
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict1 =
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue
//% KEY_NAME$S VALUE_NAME$S rawValues:kValues1
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys1
//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues1)];
//% XCTAssertNotNil(dict1);
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict1prime =
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict1prime =
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue
//% KEY_NAME$S VALUE_NAME$S rawValues:kValues1
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys1
//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues1)];
//% XCTAssertNotNil(dict1prime);
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 =
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 =
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue
//% KEY_NAME$S VALUE_NAME$S rawValues:kValues2
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys1
//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues2)];
//% XCTAssertNotNil(dict2);
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict3 =
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict3 =
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue
//% KEY_NAME$S VALUE_NAME$S rawValues:kValues1
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys2
//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues1)];
//% XCTAssertNotNil(dict3);
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict4 =
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict4 =
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue
//% KEY_NAME$S VALUE_NAME$S rawValues:kValues3
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys1
@@ -485,14 +496,14 @@
//%- (void)testCopyWithUnknowns {
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2, KEY3, KEY4 };
//% const VALUE_TYPE kValues[] = { VAL1, VAL2, VAL3, VAL4 }; // Unknown
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue
//% KEY_NAME$S VALUE_NAME$S rawValues:kValues
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys
//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues)];
//% XCTAssertNotNil(dict);
//%
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 = [dict copy];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 = [dict copy];
//% XCTAssertNotNil(dict2);
//%
//% // Should be new pointer, but equal objects.
@@ -507,31 +518,32 @@
//%- (void)testDictionaryFromDictionary {
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2, KEY3, KEY4 };
//% const VALUE_TYPE kValues[] = { VAL1, VAL2, VAL3, VAL4 }; // Unknowns
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue
//% KEY_NAME$S VALUE_NAME$S rawValues:kValues
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys
//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues)];
//% XCTAssertNotNil(dict);
//%
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 =
-//% [GPB##KEY_NAME##VALUE_NAME##Dictionary dictionaryWithDictionary:dict];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithDictionary:dict];
//% XCTAssertNotNil(dict2);
//%
//% // Should be new pointer, but equal objects.
//% XCTAssertNotEqual(dict, dict2);
//% XCTAssertEqualObjects(dict, dict2);
//% XCTAssertEqual(dict.validationFunc, dict2.validationFunc); // Pointer comparison
+//% [dict2 release];
//% [dict release];
//%}
//%
//%- (void)testUnknownAdds {
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
-//% [GPB##KEY_NAME##VALUE_NAME##Dictionary dictionaryWithValidationFunction:TestingEnum_IsValidValue];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue];
//% XCTAssertNotNil(dict);
//%
//% XCTAssertEqual(dict.count, 0U);
-//% XCTAssertThrowsSpecificNamed([dict setValue:VAL2 forKey:KEY2], // Unknown
+//% XCTAssertThrowsSpecificNamed([dict setEnum:VAL2 forKey:KEY2], // Unknown
//% NSException, NSInvalidArgumentException);
//% XCTAssertEqual(dict.count, 0U);
//% [dict setRawValue:VAL2 forKey:KEY2]; // Unknown
@@ -539,27 +551,28 @@
//%
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY3, KEY4 };
//% const VALUE_TYPE kValues[] = { VAL1, VAL3, VAL4 }; // Unknown
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues
-//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys
-//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithEnums:kValues
+//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys
+//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues)];
//% XCTAssertNotNil(dict2);
//% [dict addRawEntriesFromDictionary:dict2];
//% XCTAssertEqual(dict.count, 4U);
//%
-//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_VALUE##VHELPER(dict, value, KEY1, VAL1)
-//%TEST_VALUE##VHELPER(dict, value, KEY2, kGPBUnrecognizedEnumeratorValue)
+//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY1, VAL1)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY2, kGPBUnrecognizedEnumeratorValue)
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY2, VAL2)
-//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL3)
-//%TEST_VALUE##VHELPER(dict, value, KEY4, kGPBUnrecognizedEnumeratorValue)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY3, VAL3)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY4, kGPBUnrecognizedEnumeratorValue)
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY4, VAL4)
//% [dict2 release];
+//% [dict release];
//%}
//%
//%- (void)testUnknownRemove {
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2, KEY3, KEY4 };
//% const VALUE_TYPE kValues[] = { VAL1, VAL2, VAL3, VAL4 }; // Unknowns
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue
//% KEY_NAME$S VALUE_NAME$S rawValues:kValues
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys
@@ -567,77 +580,77 @@
//% XCTAssertNotNil(dict);
//% XCTAssertEqual(dict.count, 4U);
//%
-//% [dict removeValueForKey:KEY2];
+//% [dict removeEnumForKey:KEY2];
//% XCTAssertEqual(dict.count, 3U);
-//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_VALUE##VHELPER(dict, value, KEY1, VAL1)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
-//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL3)
+//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY1, VAL1)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY3, VAL3)
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY4, VAL4)
//%
//% // Remove again does nothing.
-//% [dict removeValueForKey:KEY2];
+//% [dict removeEnumForKey:KEY2];
//% XCTAssertEqual(dict.count, 3U);
-//%TEST_VALUE##VHELPER(dict, value, KEY1, VAL1)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
-//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL3)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY1, VAL1)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY3, VAL3)
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY4, VAL4)
//%
-//% [dict removeValueForKey:KEY4];
+//% [dict removeEnumForKey:KEY4];
//% XCTAssertEqual(dict.count, 2U);
-//%TEST_VALUE##VHELPER(dict, value, KEY1, VAL1)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
-//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL3)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY4)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY1, VAL1)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY3, VAL3)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY4)
//%
//% [dict removeAll];
//% XCTAssertEqual(dict.count, 0U);
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY1)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY3)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY4)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY1)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY2)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY3)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY4)
//% [dict release];
//%}
//%
//%- (void)testInplaceMutationUnknowns {
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2, KEY3, KEY4 };
//% const VALUE_TYPE kValues[] = { VAL1, VAL2, VAL3, VAL4 }; // Unknowns
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue
//% KEY_NAME$S VALUE_NAME$S rawValues:kValues
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys
//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues)];
//% XCTAssertNotNil(dict);
//% XCTAssertEqual(dict.count, 4U);
-//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_VALUE##VHELPER(dict, value, KEY1, VAL1)
+//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY1, VAL1)
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY2, VAL2)
-//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL3)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY3, VAL3)
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY4, VAL4)
//%
-//% XCTAssertThrowsSpecificNamed([dict setValue:VAL4 forKey:KEY1], // Unknown
+//% XCTAssertThrowsSpecificNamed([dict setEnum:VAL4 forKey:KEY1], // Unknown
//% NSException, NSInvalidArgumentException);
//% XCTAssertEqual(dict.count, 4U);
-//%TEST_VALUE##VHELPER(dict, value, KEY1, VAL1)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY1, VAL1)
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY2, VAL2)
-//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL3)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY3, VAL3)
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY4, VAL4)
//%
//% [dict setRawValue:VAL4 forKey:KEY1]; // Unknown
//% XCTAssertEqual(dict.count, 4U);
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY1, VAL4)
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY2, VAL2)
-//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL3)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY3, VAL3)
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY4, VAL4)
//%
//% [dict setRawValue:VAL1 forKey:KEY4];
//% XCTAssertEqual(dict.count, 4U);
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY1, VAL4)
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY2, VAL2)
-//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL3)
-//%TEST_VALUE##VHELPER(dict, value, KEY4, VAL1)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY3, VAL3)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY4, VAL1)
//%
//% const KEY_TYPE KisP##kKeys2[] = { KEY2, KEY3 };
//% const VALUE_TYPE kValues2[] = { VAL3, VAL2 }; // Unknown
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 =
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 =
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue
//% KEY_NAME$S VALUE_NAME$S rawValues:kValues2
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys2
@@ -646,9 +659,9 @@
//% [dict addRawEntriesFromDictionary:dict2];
//% XCTAssertEqual(dict.count, 4U);
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY1, VAL4)
-//%TEST_VALUE##VHELPER(dict, value, KEY2, VAL3)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY2, VAL3)
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY3, VAL2)
-//%TEST_VALUE##VHELPER(dict, value, KEY4, VAL1)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY4, VAL1)
//%
//% [dict2 release];
//% [dict release];
@@ -657,14 +670,14 @@
//%- (void)testCopyUnknowns {
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2, KEY3, KEY4 };
//% const VALUE_TYPE kValues[] = { VAL1, VAL2, VAL3, VAL4 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue
//% KEY_NAME$S VALUE_NAME$S rawValues:kValues
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys
//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues)];
//% XCTAssertNotNil(dict);
//%
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 = [dict copy];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 = [dict copy];
//% XCTAssertNotNil(dict2);
//%
//% // Should be new pointer, but equal objects.
@@ -687,19 +700,19 @@
//%PDDM-DEFINE DECLARE_VALUE_STORAGEPOD(VALUE_TYPE, NAME)
//% VALUE_TYPE NAME;
//%
-//%PDDM-DEFINE VALUE_NOT_FOUNDPOD(DICT, KEY)
-//% XCTAssertFalse([DICT valueForKey:KEY value:NULL]);
-//%PDDM-DEFINE TEST_VALUEPOD(DICT, STORAGE, KEY, VALUE)
-//% XCTAssertTrue([DICT valueForKey:KEY value:NULL]);
-//% XCTAssertTrue([DICT valueForKey:KEY value:&STORAGE]);
+//%PDDM-DEFINE VALUE_NOT_FOUNDPOD(VALUE_NAME, DICT, KEY)
+//% XCTAssertFalse([DICT get##VALUE_NAME##:NULL forKey:KEY]);
+//%PDDM-DEFINE TEST_VALUEPOD(VALUE_NAME, DICT, STORAGE, KEY, VALUE)
+//% XCTAssertTrue([DICT get##VALUE_NAME##:NULL forKey:KEY]);
+//% XCTAssertTrue([DICT get##VALUE_NAME##:&STORAGE forKey:KEY]);
//% XCTAssertEqual(STORAGE, VALUE);
//%PDDM-DEFINE COMPARE_KEYS(KEY1, KEY2)
//%KEY1 == KEY2
-//%PDDM-DEFINE RAW_VALUE_NOT_FOUNDPOD(DICT, KEY)
-//% XCTAssertFalse([DICT valueForKey:KEY rawValue:NULL]);
+//%PDDM-DEFINE RAW_VALUE_NOT_FOUNDPOD(VALUE_NAME, DICT, KEY)
+//% XCTAssertFalse([DICT getRawValue:NULL forKey:KEY]);
//%PDDM-DEFINE TEST_RAW_VALUEPOD(DICT, STORAGE, KEY, VALUE)
-//% XCTAssertTrue([DICT valueForKey:KEY rawValue:NULL]);
-//% XCTAssertTrue([DICT valueForKey:KEY rawValue:&STORAGE]);
+//% XCTAssertTrue([DICT getRawValue:NULL forKey:KEY]);
+//% XCTAssertTrue([DICT getRawValue:&STORAGE forKey:KEY]);
//% XCTAssertEqual(STORAGE, VALUE);
//
@@ -708,9 +721,9 @@
//%PDDM-DEFINE DECLARE_VALUE_STORAGEOBJECT(VALUE_TYPE, NAME)
// Empty
-//%PDDM-DEFINE VALUE_NOT_FOUNDOBJECT(DICT, KEY)
+//%PDDM-DEFINE VALUE_NOT_FOUNDOBJECT(VALUE_NAME, DICT, KEY)
//% XCTAssertNil([DICT objectForKey:KEY]);
-//%PDDM-DEFINE TEST_VALUEOBJECT(DICT, STORAGE, KEY, VALUE)
+//%PDDM-DEFINE TEST_VALUEOBJECT(VALUE_NAME, DICT, STORAGE, KEY, VALUE)
//% XCTAssertEqualObjects([DICT objectForKey:KEY], VALUE);
//%PDDM-DEFINE COMPARE_KEYSObjects(KEY1, KEY2)
//%[KEY1 isEqual:KEY2]
@@ -722,10 +735,9 @@
//%PDDM-DEFINE TEST_HELPERS(KEY_NAME, KEY_TYPE, KisP)
//%// To let the testing macros work, add some extra methods to simplify things.
//%@interface GPB##KEY_NAME##EnumDictionary (TestingTweak)
-//%+ (instancetype)dictionaryWithValue:(int32_t)value forKey:(KEY_TYPE##KisP$S##KisP)key;
-//%- (instancetype)initWithValues:(const int32_t [])values
-//% forKeys:(const KEY_TYPE##KisP$S##KisP [])keys
-//% count:(NSUInteger)count;
+//%- (instancetype)initWithEnums:(const int32_t [])values
+//% forKeys:(const KEY_TYPE##KisP$S##KisP [])keys
+//% count:(NSUInteger)count;
//%@end
//%
//%static BOOL TestingEnum_IsValidValue(int32_t value) {
@@ -741,17 +753,9 @@
//%}
//%
//%@implementation GPB##KEY_NAME##EnumDictionary (TestingTweak)
-//%+ (instancetype)dictionaryWithValue:(int32_t)value forKey:(KEY_TYPE##KisP$S##KisP)key {
-//% // Cast is needed to compiler knows what class we are invoking initWithValues: on to get the
-//% // type correct.
-//% return [[(GPB##KEY_NAME##EnumDictionary*)[self alloc] initWithValidationFunction:TestingEnum_IsValidValue
-//% KEY_NAME$S rawValues:&value
-//% KEY_NAME$S forKeys:&key
-//% KEY_NAME$S count:1] autorelease];
-//%}
-//%- (instancetype)initWithValues:(const int32_t [])values
-//% forKeys:(const KEY_TYPE##KisP$S##KisP [])keys
-//% count:(NSUInteger)count {
+//%- (instancetype)initWithEnums:(const int32_t [])values
+//% forKeys:(const KEY_TYPE##KisP$S##KisP [])keys
+//% count:(NSUInteger)count {
//% return [self initWithValidationFunction:TestingEnum_IsValidValue
//% rawValues:values
//% forKeys:keys
@@ -782,11 +786,11 @@
//%@implementation GPB##KEY_NAME##VALUE_NAME##DictionaryTests
//%
//%- (void)testEmpty {
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict = [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] init];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict = [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] init];
//% XCTAssertNotNil(dict);
//% XCTAssertEqual(dict.count, 0U);
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY1)
-//% [dict enumerateKeysAnd##VNAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u##, BOOL *stop) {
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY1)
+//% [dict enumerateKeysAnd##VALUE_NAME##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u##, BOOL *stop) {
//% #pragma unused(aKey, a##VNAME$u##, stop)
//% XCTFail(@"Shouldn't get here!");
//% }];
@@ -794,34 +798,36 @@
//%}
//%
//%- (void)testOne {
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict = [GPB##KEY_NAME##VALUE_NAME##Dictionary dictionaryWith##VNAME$u##:VAL1 forKey:KEY1];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict = [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] init];
+//% [dict set##VALUE_NAME$u##:VAL1 forKey:KEY1];
//% XCTAssertNotNil(dict);
//% XCTAssertEqual(dict.count, 1U);
-//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
-//% [dict enumerateKeysAnd##VNAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u, BOOL *stop) {
+//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL1)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY2)
+//% [dict enumerateKeysAnd##VALUE_NAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u, BOOL *stop) {
//% XCTAssertEqual##KSUFFIX(aKey, KEY1);
//% XCTAssertEqual##VSUFFIX(a##VNAME$u, VAL1);
//% XCTAssertNotEqual(stop, NULL);
//% }];
+//% [dict release];
//%}
//%
//%- (void)testBasics {
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2 };
//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
//% XCTAssertNotNil(dict);
//% XCTAssertEqual(dict.count, 2U);
-//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2)
+//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL1)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY2, VAL2)
//%
//% __block NSUInteger idx = 0;
//% KEY_TYPE KisP##*seenKeys = malloc(2 * sizeof(KEY_TYPE##KisP));
//% VALUE_TYPE *seen##VNAME$u##s = malloc(2 * sizeof(VALUE_TYPE));
-//% [dict enumerateKeysAnd##VNAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u##, BOOL *stop) {
+//% [dict enumerateKeysAnd##VALUE_NAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u##, BOOL *stop) {
//% XCTAssertLessThan(idx, 2U);
//% seenKeys[idx] = aKey;
//% seen##VNAME$u##s[idx] = a##VNAME$u;
@@ -843,7 +849,7 @@
//%
//% // Stopping the enumeration.
//% idx = 0;
-//% [dict enumerateKeysAnd##VNAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u##, BOOL *stop) {
+//% [dict enumerateKeysAnd##VALUE_NAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u##, BOOL *stop) {
//% #pragma unused(aKey, a##VNAME$u)
//% if (idx == 0) *stop = YES;
//% XCTAssertNotEqual(idx, 2U);
@@ -858,30 +864,30 @@
//% const VALUE_TYPE k##VNAME$u##s1[] = { VAL1, VAL2 };
//% const VALUE_TYPE k##VNAME$u##s2[] = { VAL2, VAL1 };
//% const VALUE_TYPE k##VNAME$u##s3[] = { VAL2 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict1 =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s1
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys1
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s1)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict1 =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s1
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys1
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s1)];
//% XCTAssertNotNil(dict1);
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict1prime =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s1
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys1
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s1)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict1prime =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s1
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys1
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s1)];
//% XCTAssertNotNil(dict1prime);
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s2
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys1
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s2)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s2
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys1
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s2)];
//% XCTAssertNotNil(dict2);
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict3 =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s1
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys2
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s1)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict3 =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s1
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys2
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s1)];
//% XCTAssertNotNil(dict3);
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict4 =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s3
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys1
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s3)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict4 =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s3
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys1
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s3)];
//% XCTAssertNotNil(dict4);
//%
//% // 1/1Prime should be different objects, but equal.
@@ -909,13 +915,13 @@
//%- (void)testCopy {
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2 };
//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
//% XCTAssertNotNil(dict);
//%
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 = [dict copy];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 = [dict copy];
//% XCTAssertNotNil(dict2);
//%
//% // Should be new object but equal.
@@ -930,106 +936,108 @@
//%- (void)testDictionaryFromDictionary {
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2 };
//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
//% XCTAssertNotNil(dict);
//%
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 =
-//% [GPB##KEY_NAME##VALUE_NAME##Dictionary dictionaryWithDictionary:dict];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithDictionary:dict];
//% XCTAssertNotNil(dict2);
//%
//% // Should be new pointer, but equal objects.
//% XCTAssertNotEqual(dict, dict2);
//% XCTAssertEqualObjects(dict, dict2);
+//% [dict2 release];
//% [dict release];
//%}
//%
//%- (void)testAdds {
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict = [GPB##KEY_NAME##VALUE_NAME##Dictionary dictionary];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict = [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] init];
//% XCTAssertNotNil(dict);
//%
//% XCTAssertEqual(dict.count, 0U);
-//% [dict set##VNAME$u:VAL1 forKey:KEY1];
+//% [dict set##VALUE_NAME:VAL1 forKey:KEY1];
//% XCTAssertEqual(dict.count, 1U);
//%
//% const KEY_TYPE KisP##kKeys[] = { KEY2 };
//% const VALUE_TYPE k##VNAME$u##s[] = { VAL2 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
//% XCTAssertNotNil(dict2);
//% [dict addEntriesFromDictionary:dict2];
//% XCTAssertEqual(dict.count, 2U);
//%
-//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2)
+//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL1)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY2, VAL2)
//% [dict2 release];
+//% [dict release];
//%}
//%
//%- (void)testRemove {
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2};
//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
//% XCTAssertNotNil(dict);
//% XCTAssertEqual(dict.count, 2U);
//%
-//% [dict remove##VNAME$u##ForKey:KEY2];
+//% [dict remove##VALUE_NAME##ForKey:KEY2];
//% XCTAssertEqual(dict.count, 1U);
-//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
+//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL1)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY2)
//%
//% // Remove again does nothing.
-//% [dict remove##VNAME$u##ForKey:KEY2];
+//% [dict remove##VALUE_NAME##ForKey:KEY2];
//% XCTAssertEqual(dict.count, 1U);
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL1)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY2)
//%
//% [dict removeAll];
//% XCTAssertEqual(dict.count, 0U);
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY1)
-//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY1)
+//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY2)
//% [dict release];
//%}
//%
//%- (void)testInplaceMutation {
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2 };
//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)];
//% XCTAssertNotNil(dict);
//% XCTAssertEqual(dict.count, 2U);
-//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2)
+//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL1)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY2, VAL2)
//%
-//% [dict set##VNAME$u##:VAL2 forKey:KEY1];
+//% [dict set##VALUE_NAME##:VAL2 forKey:KEY1];
//% XCTAssertEqual(dict.count, 2U);
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL2)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY2, VAL2)
//%
-//% [dict set##VNAME$u##:VAL1 forKey:KEY2];
+//% [dict set##VALUE_NAME##:VAL1 forKey:KEY2];
//% XCTAssertEqual(dict.count, 2U);
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL2)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL1)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY2, VAL1)
//%
//% const KEY_TYPE KisP##kKeys2[] = { KEY2, KEY1 };
//% const VALUE_TYPE k##VNAME$u##s2[] = { VAL2, VAL1 };
-//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 =
-//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s2
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys2
-//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s2)];
+//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 =
+//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VALUE_NAME##s:k##VNAME$u##s2
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## forKeys:kKeys2
+//% KEY_NAME$S VALUE_NAME$S ##VALUE_NAME$S## count:GPBARRAYSIZE(k##VNAME$u##s2)];
//% XCTAssertNotNil(dict2);
//% [dict addEntriesFromDictionary:dict2];
//% XCTAssertEqual(dict.count, 2U);
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
-//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL1)
+//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY2, VAL2)
//%
//% [dict2 release];
//% [dict release];
diff --git a/objectivec/Tests/GPBExtensionRegistryTest.m b/objectivec/Tests/GPBExtensionRegistryTest.m
new file mode 100644
index 00000000..b1168826
--- /dev/null
+++ b/objectivec/Tests/GPBExtensionRegistryTest.m
@@ -0,0 +1,138 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2017 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#import "GPBTestUtilities.h"
+
+#import "GPBExtensionRegistry.h"
+#import "google/protobuf/Unittest.pbobjc.h"
+
+@interface GPBExtensionRegistryTest : GPBTestCase
+@end
+
+@implementation GPBExtensionRegistryTest
+
+- (void)testBasics {
+ GPBExtensionRegistry *reg = [[[GPBExtensionRegistry alloc] init] autorelease];
+ XCTAssertNotNil(reg);
+
+ XCTAssertNil([reg extensionForDescriptor:[TestAllExtensions descriptor]
+ fieldNumber:1]);
+ XCTAssertNil([reg extensionForDescriptor:[TestAllTypes descriptor]
+ fieldNumber:1]);
+
+ [reg addExtension:[UnittestRoot optionalInt32Extension]];
+ [reg addExtension:[UnittestRoot packedInt64Extension]];
+
+ XCTAssertTrue([reg extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:1] ==
+ [UnittestRoot optionalInt32Extension]); // ptr equality
+ XCTAssertNil([reg extensionForDescriptor:[TestAllTypes descriptor]
+ fieldNumber:1]);
+ XCTAssertTrue([reg extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:91] ==
+ [UnittestRoot packedInt64Extension]); // ptr equality
+}
+
+- (void)testCopy {
+ GPBExtensionRegistry *reg1 = [[[GPBExtensionRegistry alloc] init] autorelease];
+ [reg1 addExtension:[UnittestRoot optionalInt32Extension]];
+
+ GPBExtensionRegistry *reg2 = [[reg1 copy] autorelease];
+ XCTAssertNotNil(reg2);
+
+ XCTAssertTrue([reg1 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:1] ==
+ [UnittestRoot optionalInt32Extension]); // ptr equality
+ XCTAssertTrue([reg2 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:1] ==
+ [UnittestRoot optionalInt32Extension]); // ptr equality
+
+ // Message class that had registered extension(s) at the -copy time.
+
+ [reg1 addExtension:[UnittestRoot optionalBoolExtension]];
+ [reg2 addExtension:[UnittestRoot optionalStringExtension]];
+
+ XCTAssertTrue([reg1 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:13] ==
+ [UnittestRoot optionalBoolExtension]); // ptr equality
+ XCTAssertNil([reg1 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:14]);
+ XCTAssertNil([reg2 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:13]);
+ XCTAssertTrue([reg2 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:14] ==
+ [UnittestRoot optionalStringExtension]); // ptr equality
+
+ // Message class that did not have any registered extensions at the -copy time.
+
+ [reg1 addExtension:[UnittestRoot packedInt64Extension]];
+ [reg2 addExtension:[UnittestRoot packedSint32Extension]];
+
+ XCTAssertTrue([reg1 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:91] ==
+ [UnittestRoot packedInt64Extension]); // ptr equality
+ XCTAssertNil([reg1 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:94]);
+ XCTAssertNil([reg2 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:91]);
+ XCTAssertTrue([reg2 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:94] ==
+ [UnittestRoot packedSint32Extension]); // ptr equality
+
+}
+
+- (void)testAddExtensions {
+ GPBExtensionRegistry *reg1 = [[[GPBExtensionRegistry alloc] init] autorelease];
+ [reg1 addExtension:[UnittestRoot optionalInt32Extension]];
+
+ GPBExtensionRegistry *reg2 = [[[GPBExtensionRegistry alloc] init] autorelease];
+
+ XCTAssertNil([reg2 extensionForDescriptor:[TestAllExtensions descriptor]
+ fieldNumber:1]);
+
+ [reg2 addExtensions:reg1];
+
+ XCTAssertTrue([reg2 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:1] ==
+ [UnittestRoot optionalInt32Extension]); // ptr equality
+
+ // Confirm adding to the first doesn't add to the second.
+
+ [reg1 addExtension:[UnittestRoot optionalBoolExtension]];
+ [reg1 addExtension:[UnittestRoot packedInt64Extension]];
+
+ XCTAssertTrue([reg1 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:13] ==
+ [UnittestRoot optionalBoolExtension]); // ptr equality
+ XCTAssertTrue([reg1 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:91] ==
+ [UnittestRoot packedInt64Extension]); // ptr equality
+ XCTAssertNil([reg2 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:13]);
+ XCTAssertNil([reg2 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:91]);
+
+ // Confirm adding to the second doesn't add to the first.
+
+ [reg2 addExtension:[UnittestRoot optionalStringExtension]];
+ [reg2 addExtension:[UnittestRoot packedSint32Extension]];
+
+ XCTAssertNil([reg1 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:14]);
+ XCTAssertNil([reg1 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:94]);
+ XCTAssertTrue([reg2 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:14] ==
+ [UnittestRoot optionalStringExtension]); // ptr equality
+ XCTAssertTrue([reg2 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:94] ==
+ [UnittestRoot packedSint32Extension]); // ptr equality
+}
+
+@end
diff --git a/objectivec/Tests/GPBMessageTests+Runtime.m b/objectivec/Tests/GPBMessageTests+Runtime.m
index 5e197711..0058311b 100644
--- a/objectivec/Tests/GPBMessageTests+Runtime.m
+++ b/objectivec/Tests/GPBMessageTests+Runtime.m
@@ -36,6 +36,7 @@
#import "google/protobuf/MapUnittest.pbobjc.h"
#import "google/protobuf/Unittest.pbobjc.h"
+#import "google/protobuf/UnittestCycle.pbobjc.h"
#import "google/protobuf/UnittestObjcStartup.pbobjc.h"
#import "google/protobuf/UnittestRuntimeProto2.pbobjc.h"
#import "google/protobuf/UnittestRuntimeProto3.pbobjc.h"
@@ -49,11 +50,24 @@
// specific.
- (void)testStartupOrdering {
- // Just have to create a message. Nothing else uses the classes from
- // this file, so the first selector invoked on the class will initialize
- // it, which also initializes the root.
+ // Message class/Root class initialization is a little tricky, so these just
+ // create some possible patterns that can be a problem. The messages don't
+ // have to be exercised, just creating them is enough to test. If there
+ // is a problem, the runtime should assert or hang.
+ //
+ // Note: the messages from these proto files should not be used in any other
+ // tests, that way when they are referenced here it will be the first use and
+ // initialization will take place now.
+
TestObjCStartupMessage *message = [TestObjCStartupMessage message];
XCTAssertNotNil(message);
+
+ CycleBaz *baz = [CycleBaz message];
+ CycleBar *bar = [CycleBar message];
+ CycleFoo *foo = [CycleFoo message];
+ XCTAssertNotNil(baz);
+ XCTAssertNotNil(bar);
+ XCTAssertNotNil(foo);
}
- (void)testProto2HasMethodSupport {
@@ -326,6 +340,17 @@
//% [msg release];
//% }
//%
+//%PDDM-DEFINE PROTO2_TEST_CLEAR_FIELD_WITH_NIL(FIELD, VALUE)
+//% { // optional##FIELD
+//% Message2 *msg = [[Message2 alloc] init];
+//% XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message2_FieldNumber_Optional##FIELD));
+//% msg.optional##FIELD = VALUE;
+//% XCTAssertTrue(GPBMessageHasFieldNumberSet(msg, Message2_FieldNumber_Optional##FIELD));
+//% msg.optional##FIELD = nil;
+//% XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message2_FieldNumber_Optional##FIELD));
+//% [msg release];
+//% }
+//%
//%PDDM-DEFINE PROTO2_TEST_HAS_FIELDS()
//%PROTO2_TEST_HAS_FIELD(Int32, 1, 0)
//%PROTO2_TEST_HAS_FIELD(Int64, 1, 0)
@@ -347,6 +372,14 @@
//% //
//%
//%PROTO2_TEST_HAS_FIELD(Enum, Message2_Enum_Bar, Message2_Enum_Foo)
+//% //
+//% // Nil can also be used to clear strings, bytes, groups, and messages.
+//% //
+//%
+//%PROTO2_TEST_CLEAR_FIELD_WITH_NIL(String, @"foo")
+//%PROTO2_TEST_CLEAR_FIELD_WITH_NIL(Bytes, [@"foo" dataUsingEncoding:NSUTF8StringEncoding])
+//%PROTO2_TEST_CLEAR_FIELD_WITH_NIL(Group, [Message2_OptionalGroup message])
+//%PROTO2_TEST_CLEAR_FIELD_WITH_NIL(Message, [Message2 message])
//%PDDM-EXPAND PROTO2_TEST_HAS_FIELDS()
// This block of code is generated, do not edit it directly.
@@ -658,13 +691,57 @@
[msg release];
}
+ //
+ // Nil can also be used to clear strings, bytes, groups, and messages.
+ //
+
+ { // optionalString
+ Message2 *msg = [[Message2 alloc] init];
+ XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message2_FieldNumber_OptionalString));
+ msg.optionalString = @"foo";
+ XCTAssertTrue(GPBMessageHasFieldNumberSet(msg, Message2_FieldNumber_OptionalString));
+ msg.optionalString = nil;
+ XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message2_FieldNumber_OptionalString));
+ [msg release];
+ }
+
+ { // optionalBytes
+ Message2 *msg = [[Message2 alloc] init];
+ XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message2_FieldNumber_OptionalBytes));
+ msg.optionalBytes = [@"foo" dataUsingEncoding:NSUTF8StringEncoding];
+ XCTAssertTrue(GPBMessageHasFieldNumberSet(msg, Message2_FieldNumber_OptionalBytes));
+ msg.optionalBytes = nil;
+ XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message2_FieldNumber_OptionalBytes));
+ [msg release];
+ }
+
+ { // optionalGroup
+ Message2 *msg = [[Message2 alloc] init];
+ XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message2_FieldNumber_OptionalGroup));
+ msg.optionalGroup = [Message2_OptionalGroup message];
+ XCTAssertTrue(GPBMessageHasFieldNumberSet(msg, Message2_FieldNumber_OptionalGroup));
+ msg.optionalGroup = nil;
+ XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message2_FieldNumber_OptionalGroup));
+ [msg release];
+ }
+
+ { // optionalMessage
+ Message2 *msg = [[Message2 alloc] init];
+ XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message2_FieldNumber_OptionalMessage));
+ msg.optionalMessage = [Message2 message];
+ XCTAssertTrue(GPBMessageHasFieldNumberSet(msg, Message2_FieldNumber_OptionalMessage));
+ msg.optionalMessage = nil;
+ XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message2_FieldNumber_OptionalMessage));
+ [msg release];
+ }
+
//%PDDM-EXPAND-END PROTO2_TEST_HAS_FIELDS()
}
- (void)testProto3SingleFieldHasBehavior {
//
- // Setting to any value including the default value (0) should result has*
- // being true.
+ // Setting to any value but the default value (0) should result has*
+ // being true. When set to the default, shouldn't be true.
//
//%PDDM-DEFINE PROTO3_TEST_HAS_FIELD(FIELD, NON_ZERO_VALUE, ZERO_VALUE)
@@ -678,6 +755,17 @@
//% [msg release];
//% }
//%
+//%PDDM-DEFINE PROTO3_TEST_CLEAR_FIELD_WITH_NIL(FIELD, VALUE)
+//% { // optional##FIELD
+//% Message3 *msg = [[Message3 alloc] init];
+//% XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message3_FieldNumber_Optional##FIELD));
+//% msg.optional##FIELD = VALUE;
+//% XCTAssertTrue(GPBMessageHasFieldNumberSet(msg, Message3_FieldNumber_Optional##FIELD));
+//% msg.optional##FIELD = nil;
+//% XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message3_FieldNumber_Optional##FIELD));
+//% [msg release];
+//% }
+//%
//%PDDM-DEFINE PROTO3_TEST_HAS_FIELDS()
//%PROTO3_TEST_HAS_FIELD(Int32, 1, 0)
//%PROTO3_TEST_HAS_FIELD(Int64, 1, 0)
@@ -695,10 +783,17 @@
//%PROTO3_TEST_HAS_FIELD(String, @"foo", @"")
//%PROTO3_TEST_HAS_FIELD(Bytes, [@"foo" dataUsingEncoding:NSUTF8StringEncoding], [NSData data])
//% //
-//% // Test doesn't apply to optionalGroup/optionalMessage.
+//% // Test doesn't apply to optionalMessage (no groups in proto3).
//% //
//%
//%PROTO3_TEST_HAS_FIELD(Enum, Message3_Enum_Bar, Message3_Enum_Foo)
+//% //
+//% // Nil can also be used to clear strings, bytes, and messages (no groups in proto3).
+//% //
+//%
+//%PROTO3_TEST_CLEAR_FIELD_WITH_NIL(String, @"foo")
+//%PROTO3_TEST_CLEAR_FIELD_WITH_NIL(Bytes, [@"foo" dataUsingEncoding:NSUTF8StringEncoding])
+//%PROTO3_TEST_CLEAR_FIELD_WITH_NIL(Message, [Message3 message])
//%PDDM-EXPAND PROTO3_TEST_HAS_FIELDS()
// This block of code is generated, do not edit it directly.
@@ -853,7 +948,7 @@
}
//
- // Test doesn't apply to optionalGroup/optionalMessage.
+ // Test doesn't apply to optionalMessage (no groups in proto3).
//
{ // optionalEnum
@@ -866,6 +961,40 @@
[msg release];
}
+ //
+ // Nil can also be used to clear strings, bytes, and messages (no groups in proto3).
+ //
+
+ { // optionalString
+ Message3 *msg = [[Message3 alloc] init];
+ XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message3_FieldNumber_OptionalString));
+ msg.optionalString = @"foo";
+ XCTAssertTrue(GPBMessageHasFieldNumberSet(msg, Message3_FieldNumber_OptionalString));
+ msg.optionalString = nil;
+ XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message3_FieldNumber_OptionalString));
+ [msg release];
+ }
+
+ { // optionalBytes
+ Message3 *msg = [[Message3 alloc] init];
+ XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message3_FieldNumber_OptionalBytes));
+ msg.optionalBytes = [@"foo" dataUsingEncoding:NSUTF8StringEncoding];
+ XCTAssertTrue(GPBMessageHasFieldNumberSet(msg, Message3_FieldNumber_OptionalBytes));
+ msg.optionalBytes = nil;
+ XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message3_FieldNumber_OptionalBytes));
+ [msg release];
+ }
+
+ { // optionalMessage
+ Message3 *msg = [[Message3 alloc] init];
+ XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message3_FieldNumber_OptionalMessage));
+ msg.optionalMessage = [Message3 message];
+ XCTAssertTrue(GPBMessageHasFieldNumberSet(msg, Message3_FieldNumber_OptionalMessage));
+ msg.optionalMessage = nil;
+ XCTAssertFalse(GPBMessageHasFieldNumberSet(msg, Message3_FieldNumber_OptionalMessage));
+ [msg release];
+ }
+
//%PDDM-EXPAND-END PROTO3_TEST_HAS_FIELDS()
}
@@ -1972,6 +2101,262 @@
[msg release];
}
+- (void)testProto2OneofSetToDefault {
+
+ // proto3 doesn't normally write out zero (default) fields, but if they are
+ // in a oneof it does. proto2 doesn't have this special behavior, but we
+ // still confirm setting to the explicit default does set the case to be
+ // sure the runtime is working correctly.
+
+ NSString *oneofStringDefault = @"string";
+ NSData *oneofBytesDefault = [@"data" dataUsingEncoding:NSUTF8StringEncoding];
+
+ Message2 *msg = [[Message2 alloc] init];
+
+ uint32_t values[] = {
+ Message2_O_OneOfCase_OneofInt32,
+ Message2_O_OneOfCase_OneofInt64,
+ Message2_O_OneOfCase_OneofUint32,
+ Message2_O_OneOfCase_OneofUint64,
+ Message2_O_OneOfCase_OneofSint32,
+ Message2_O_OneOfCase_OneofSint64,
+ Message2_O_OneOfCase_OneofFixed32,
+ Message2_O_OneOfCase_OneofFixed64,
+ Message2_O_OneOfCase_OneofSfixed32,
+ Message2_O_OneOfCase_OneofSfixed64,
+ Message2_O_OneOfCase_OneofFloat,
+ Message2_O_OneOfCase_OneofDouble,
+ Message2_O_OneOfCase_OneofBool,
+ Message2_O_OneOfCase_OneofString,
+ Message2_O_OneOfCase_OneofBytes,
+ // Skip group
+ // Skip message
+ Message2_O_OneOfCase_OneofEnum,
+ };
+
+ for (size_t i = 0; i < GPBARRAYSIZE(values); ++i) {
+ switch (values[i]) {
+ case Message2_O_OneOfCase_OneofInt32:
+ msg.oneofInt32 = 100;
+ break;
+ case Message2_O_OneOfCase_OneofInt64:
+ msg.oneofInt64 = 101;
+ break;
+ case Message2_O_OneOfCase_OneofUint32:
+ msg.oneofUint32 = 102;
+ break;
+ case Message2_O_OneOfCase_OneofUint64:
+ msg.oneofUint64 = 103;
+ break;
+ case Message2_O_OneOfCase_OneofSint32:
+ msg.oneofSint32 = 104;
+ break;
+ case Message2_O_OneOfCase_OneofSint64:
+ msg.oneofSint64 = 105;
+ break;
+ case Message2_O_OneOfCase_OneofFixed32:
+ msg.oneofFixed32 = 106;
+ break;
+ case Message2_O_OneOfCase_OneofFixed64:
+ msg.oneofFixed64 = 107;
+ break;
+ case Message2_O_OneOfCase_OneofSfixed32:
+ msg.oneofSfixed32 = 108;
+ break;
+ case Message2_O_OneOfCase_OneofSfixed64:
+ msg.oneofSfixed64 = 109;
+ break;
+ case Message2_O_OneOfCase_OneofFloat:
+ msg.oneofFloat = 110.0f;
+ break;
+ case Message2_O_OneOfCase_OneofDouble:
+ msg.oneofDouble = 111.0;
+ break;
+ case Message2_O_OneOfCase_OneofBool:
+ msg.oneofBool = YES;
+ break;
+ case Message2_O_OneOfCase_OneofString:
+ msg.oneofString = oneofStringDefault;
+ break;
+ case Message2_O_OneOfCase_OneofBytes:
+ msg.oneofBytes = oneofBytesDefault;
+ break;
+ case Message2_O_OneOfCase_OneofEnum:
+ msg.oneofEnum = Message3_Enum_Baz;
+ break;
+ default:
+ XCTFail(@"shouldn't happen, loop: %zd, value: %d", i, values[i]);
+ break;
+ }
+
+ // Should be set to the correct case.
+ XCTAssertEqual(msg.oOneOfCase, values[i], "Loop: %zd", i);
+
+ // Confirm everything is the defaults.
+ XCTAssertEqual(msg.oneofInt32, 100, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofInt64, 101, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofUint32, 102U, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofUint64, 103U, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofSint32, 104, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofSint64, 105, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofFixed32, 106U, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofFixed64, 107U, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofSfixed32, 108, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofSfixed64, 109, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofFloat, 110.0f, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofDouble, 111.0, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofBool, YES, "Loop: %zd", i);
+ XCTAssertEqualObjects(msg.oneofString, oneofStringDefault, "Loop: %zd", i);
+ XCTAssertEqualObjects(msg.oneofBytes, oneofBytesDefault, "Loop: %zd", i);
+ // Skip group, no default to consider.
+ // Skip message, no default to consider.
+ XCTAssertEqual(msg.oneofEnum, Message2_Enum_Baz, "Loop: %zd", i);
+ }
+
+ // We special case nil on string, data, group, and message, ensure they work
+ // as expected. i.e. - it clears the case.
+ msg.oneofString = nil;
+ XCTAssertEqualObjects(msg.oneofString, oneofStringDefault);
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase_GPBUnsetOneOfCase);
+ msg.oneofBytes = nil;
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase_GPBUnsetOneOfCase);
+ XCTAssertEqualObjects(msg.oneofBytes, oneofBytesDefault);
+ msg.oneofGroup = nil;
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase_GPBUnsetOneOfCase);
+ XCTAssertNotNil(msg.oneofGroup);
+ msg.oneofMessage = nil;
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase_GPBUnsetOneOfCase);
+ XCTAssertNotNil(msg.oneofMessage);
+
+ [msg release];
+}
+
+- (void)testProto3OneofSetToZero {
+
+ // Normally setting a proto3 field to the zero value should result in it being
+ // reset/cleared. But in a oneof, it still gets recored so it can go out
+ // over the wire and the other side can see what was set in the oneof.
+
+ NSString *oneofStringDefault = @"";
+ NSData *oneofBytesDefault = [NSData data];
+
+ Message3 *msg = [[Message3 alloc] init];
+
+ uint32_t values[] = {
+ Message3_O_OneOfCase_OneofInt32,
+ Message3_O_OneOfCase_OneofInt64,
+ Message3_O_OneOfCase_OneofUint32,
+ Message3_O_OneOfCase_OneofUint64,
+ Message3_O_OneOfCase_OneofSint32,
+ Message3_O_OneOfCase_OneofSint64,
+ Message3_O_OneOfCase_OneofFixed32,
+ Message3_O_OneOfCase_OneofFixed64,
+ Message3_O_OneOfCase_OneofSfixed32,
+ Message3_O_OneOfCase_OneofSfixed64,
+ Message3_O_OneOfCase_OneofFloat,
+ Message3_O_OneOfCase_OneofDouble,
+ Message3_O_OneOfCase_OneofBool,
+ Message3_O_OneOfCase_OneofString,
+ Message3_O_OneOfCase_OneofBytes,
+ Message3_O_OneOfCase_OneofMessage,
+ Message3_O_OneOfCase_OneofEnum,
+ };
+
+ for (size_t i = 0; i < GPBARRAYSIZE(values); ++i) {
+ switch (values[i]) {
+ case Message3_O_OneOfCase_OneofInt32:
+ msg.oneofInt32 = 0;
+ break;
+ case Message3_O_OneOfCase_OneofInt64:
+ msg.oneofInt64 = 0;
+ break;
+ case Message3_O_OneOfCase_OneofUint32:
+ msg.oneofUint32 = 0;
+ break;
+ case Message3_O_OneOfCase_OneofUint64:
+ msg.oneofUint64 = 0;
+ break;
+ case Message3_O_OneOfCase_OneofSint32:
+ msg.oneofSint32 = 0;
+ break;
+ case Message3_O_OneOfCase_OneofSint64:
+ msg.oneofSint64 = 0;
+ break;
+ case Message3_O_OneOfCase_OneofFixed32:
+ msg.oneofFixed32 = 0;
+ break;
+ case Message3_O_OneOfCase_OneofFixed64:
+ msg.oneofFixed64 = 0;
+ break;
+ case Message3_O_OneOfCase_OneofSfixed32:
+ msg.oneofSfixed32 = 0;
+ break;
+ case Message3_O_OneOfCase_OneofSfixed64:
+ msg.oneofSfixed64 = 0;
+ break;
+ case Message3_O_OneOfCase_OneofFloat:
+ msg.oneofFloat = 0.0f;
+ break;
+ case Message3_O_OneOfCase_OneofDouble:
+ msg.oneofDouble = 0.0;
+ break;
+ case Message3_O_OneOfCase_OneofBool:
+ msg.oneofBool = NO;
+ break;
+ case Message3_O_OneOfCase_OneofString:
+ msg.oneofString = oneofStringDefault;
+ break;
+ case Message3_O_OneOfCase_OneofBytes:
+ msg.oneofBytes = oneofBytesDefault;
+ break;
+ case Message3_O_OneOfCase_OneofMessage:
+ msg.oneofMessage.optionalInt32 = 0;
+ break;
+ case Message3_O_OneOfCase_OneofEnum:
+ msg.oneofEnum = Message3_Enum_Foo;
+ break;
+ default:
+ XCTFail(@"shouldn't happen, loop: %zd, value: %d", i, values[i]);
+ break;
+ }
+
+ // Should be set to the correct case.
+ XCTAssertEqual(msg.oOneOfCase, values[i], "Loop: %zd", i);
+
+ // Confirm everything is still zeros.
+ XCTAssertEqual(msg.oneofInt32, 0, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofInt64, 0, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofUint32, 0U, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofUint64, 0U, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofSint32, 0, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofSint64, 0, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofFixed32, 0U, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofFixed64, 0U, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofSfixed32, 0, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofSfixed64, 0, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofFloat, 0.0f, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofDouble, 0.0, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofBool, NO, "Loop: %zd", i);
+ XCTAssertEqualObjects(msg.oneofString, oneofStringDefault, "Loop: %zd", i);
+ XCTAssertEqualObjects(msg.oneofBytes, oneofBytesDefault, "Loop: %zd", i);
+ XCTAssertNotNil(msg.oneofMessage, "Loop: %zd", i);
+ XCTAssertEqual(msg.oneofEnum, Message3_Enum_Foo, "Loop: %zd", i);
+ }
+
+ // We special case nil on string, data, message, ensure they work as expected.
+ msg.oneofString = nil;
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase_GPBUnsetOneOfCase);
+ XCTAssertEqualObjects(msg.oneofString, oneofStringDefault);
+ msg.oneofBytes = nil;
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase_GPBUnsetOneOfCase);
+ XCTAssertEqualObjects(msg.oneofBytes, oneofBytesDefault);
+ msg.oneofMessage = nil;
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase_GPBUnsetOneOfCase);
+ XCTAssertNotNil(msg.oneofMessage);
+
+ [msg release];
+}
+
- (void)testCopyingMakesUniqueObjects {
const int repeatCount = 5;
TestAllTypes *msg1 = [TestAllTypes message];
@@ -2066,6 +2451,46 @@
}];
}
+- (void)test_GPBGetMessageRepeatedField {
+ TestAllTypes *message = [TestAllTypes message];
+ GPBFieldDescriptor *fieldDescriptor = [[message descriptor] fieldWithName:@"repeatedStringArray"];
+ XCTAssertNotNil(fieldDescriptor);
+ NSMutableArray *fieldArray = GPBGetMessageRepeatedField(message, fieldDescriptor);
+ XCTAssertNotNil(fieldArray); // Should have autocreated.
+ XCTAssertTrue(fieldArray == message.repeatedStringArray); // Same pointer
+}
+
+- (void)test_GPBSetMessageRepeatedField {
+ TestAllTypes *message = [TestAllTypes message];
+ GPBFieldDescriptor *fieldDescriptor = [[message descriptor] fieldWithName:@"repeatedStringArray"];
+ XCTAssertNotNil(fieldDescriptor);
+
+ NSMutableArray *fieldArray = [NSMutableArray arrayWithObject:@"foo"];
+ GPBSetMessageRepeatedField(message, fieldDescriptor, fieldArray);
+ XCTAssertTrue(fieldArray == message.repeatedStringArray); // Same pointer
+ XCTAssertEqualObjects(@"foo", message.repeatedStringArray.firstObject);
+}
+
+- (void)test_GPBGetMessageMapField {
+ TestMap *message = [TestMap message];
+ GPBFieldDescriptor *fieldDescriptor = [[message descriptor] fieldWithName:@"mapStringString"];
+ XCTAssertNotNil(fieldDescriptor);
+ NSMutableDictionary *fieldMap = GPBGetMessageMapField(message, fieldDescriptor);
+ XCTAssertNotNil(fieldMap); // Should have autocreated.
+ XCTAssertTrue(fieldMap == message.mapStringString); // Same pointer
+}
+
+- (void)test_GPBSetMessageMapField {
+ TestMap *message = [TestMap message];
+ GPBFieldDescriptor *fieldDescriptor = [[message descriptor] fieldWithName:@"mapStringString"];
+ XCTAssertNotNil(fieldDescriptor);
+
+ NSMutableDictionary *fieldMap = [NSMutableDictionary dictionaryWithObject:@"bar" forKey:@"foo"];
+ GPBSetMessageMapField(message, fieldDescriptor, fieldMap);
+ XCTAssertTrue(fieldMap == message.mapStringString); // Same pointer
+ XCTAssertEqualObjects(@"bar", message.mapStringString[@"foo"]);
+}
+
#pragma mark - Subset from from map_tests.cc
// TEST(GeneratedMapFieldTest, IsInitialized)
diff --git a/objectivec/Tests/GPBMessageTests+Serialization.m b/objectivec/Tests/GPBMessageTests+Serialization.m
index 0d811a96..921feab7 100644
--- a/objectivec/Tests/GPBMessageTests+Serialization.m
+++ b/objectivec/Tests/GPBMessageTests+Serialization.m
@@ -42,10 +42,6 @@
#import "google/protobuf/UnittestRuntimeProto2.pbobjc.h"
#import "google/protobuf/UnittestRuntimeProto3.pbobjc.h"
-static NSData *DataFromCStr(const char *str) {
- return [NSData dataWithBytes:str length:strlen(str)];
-}
-
@interface MessageSerializationTests : GPBTestCase
@end
@@ -113,35 +109,6 @@ static NSData *DataFromCStr(const char *str) {
[msg release];
}
-- (void)testProto3DroppingUnknownFields {
- DropUnknownsFooWithExtraFields *fooWithExtras =
- [[DropUnknownsFooWithExtraFields alloc] init];
-
- fooWithExtras.int32Value = 1;
- fooWithExtras.enumValue = DropUnknownsFooWithExtraFields_NestedEnum_Baz;
- fooWithExtras.extraInt32Value = 2;
-
- NSData *data = [fooWithExtras data];
- XCTAssertNotNil(data);
- DropUnknownsFoo *foo = [DropUnknownsFoo parseFromData:data error:NULL];
-
- XCTAssertEqual(foo.int32Value, 1);
- XCTAssertEqual(foo.enumValue, DropUnknownsFoo_NestedEnum_Baz);
- // Nothing should end up in the unknowns.
- XCTAssertEqual([foo.unknownFields countOfFields], 0U);
-
- [fooWithExtras release];
- data = [foo data];
- fooWithExtras =
- [DropUnknownsFooWithExtraFields parseFromData:data error:NULL];
- XCTAssertEqual(fooWithExtras.int32Value, 1);
- XCTAssertEqual(fooWithExtras.enumValue,
- DropUnknownsFooWithExtraFields_NestedEnum_Baz);
- // And the extra value is gone (back to the default).
- XCTAssertEqual(fooWithExtras.extraInt32Value, 0);
- XCTAssertEqual([foo.unknownFields countOfFields], 0U);
-}
-
- (void)testProto2UnknownEnumToUnknownField {
Message3 *orig = [[Message3 alloc] init];
@@ -881,6 +848,156 @@ static NSData *DataFromCStr(const char *str) {
XCTAssertEqualObjects(extsParse, extsOrig);
}
+- (void)testErrorSubsectionInvalidLimit {
+ NSData *data = DataFromCStr(
+ "\x0A\x08\x0A\x07\x12\x04\x72\x02\x4B\x50\x12\x04\x72\x02\x4B\x50");
+ NSError *error = nil;
+ NestedTestAllTypes *msg = [NestedTestAllTypes parseFromData:data
+ error:&error];
+ XCTAssertNil(msg);
+ XCTAssertNotNil(error);
+ XCTAssertEqualObjects(error.domain, GPBCodedInputStreamErrorDomain);
+ XCTAssertEqual(error.code, GPBCodedInputStreamErrorInvalidSubsectionLimit);
+}
+
+- (void)testErrorSubsectionLimitReached {
+ NSData *data = DataFromCStr("\x0A\x06\x12\x03\x72\x02\x4B\x50");
+ NSError *error = nil;
+ NestedTestAllTypes *msg = [NestedTestAllTypes parseFromData:data
+ error:&error];
+ XCTAssertNil(msg);
+ XCTAssertNotNil(error);
+ XCTAssertEqualObjects(error.domain, GPBCodedInputStreamErrorDomain);
+ XCTAssertEqual(error.code, GPBCodedInputStreamErrorSubsectionLimitReached);
+}
+
+- (void)testErrorInvalidVarint {
+ NSData *data = DataFromCStr("\x72\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF");
+ NSError *error = nil;
+ TestAllTypes *msg = [TestAllTypes parseFromData:data error:&error];
+ XCTAssertNil(msg);
+ XCTAssertNotNil(error);
+ XCTAssertEqualObjects(error.domain, GPBCodedInputStreamErrorDomain);
+ XCTAssertEqual(error.code, GPBCodedInputStreamErrorInvalidVarInt);
+}
+
+- (void)testErrorInvalidUTF8 {
+ NSData *data = DataFromCStr("\x72\x04\xF4\xFF\xFF\xFF");
+ NSError *error = nil;
+ TestAllTypes *msg = [TestAllTypes parseFromData:data error:&error];
+ XCTAssertNil(msg);
+ XCTAssertNotNil(error);
+ XCTAssertEqualObjects(error.domain, GPBCodedInputStreamErrorDomain);
+ XCTAssertEqual(error.code, GPBCodedInputStreamErrorInvalidUTF8);
+}
+
+- (void)testErrorInvalidSize {
+ NSData *data = DataFromCStr("\x72\x03\x4B\x50");
+ NSError *error = nil;
+ NestedTestAllTypes *msg = [NestedTestAllTypes parseFromData:data
+ error:&error];
+ XCTAssertNil(msg);
+ XCTAssertNotNil(error);
+ XCTAssertEqualObjects(error.domain, GPBCodedInputStreamErrorDomain);
+ XCTAssertEqual(error.code, GPBCodedInputStreamErrorInvalidSize);
+}
+
+- (void)testErrorInvalidTag {
+ NSData *data = DataFromCStr("\x0F");
+ NSError *error = nil;
+ NestedTestAllTypes *msg = [NestedTestAllTypes parseFromData:data
+ error:&error];
+ XCTAssertNil(msg);
+ XCTAssertNotNil(error);
+ XCTAssertEqualObjects(error.domain, GPBCodedInputStreamErrorDomain);
+ XCTAssertEqual(error.code, GPBCodedInputStreamErrorInvalidTag);
+}
+
+- (void)testZeroFieldNum {
+ // These are ConformanceTestSuite::TestIllegalTags.
+
+ const char *tests[] = {
+ "\1DEADBEEF",
+ "\2\1\1",
+ "\3\4",
+ "\5DEAD"
+ };
+
+ for (size_t i = 0; i < GPBARRAYSIZE(tests); ++i) {
+ NSData *data = DataFromCStr(tests[i]);
+
+ {
+ // Message from proto2 syntax file
+ NSError *error = nil;
+ Message2 *msg = [Message2 parseFromData:data error:&error];
+ XCTAssertNil(msg, @"i = %zd", i);
+ XCTAssertNotNil(error, @"i = %zd", i);
+ XCTAssertEqualObjects(error.domain, GPBCodedInputStreamErrorDomain, @"i = %zd", i);
+ XCTAssertEqual(error.code, GPBCodedInputStreamErrorInvalidTag, @"i = %zd", i);
+ }
+
+ {
+ // Message from proto3 syntax file
+ NSError *error = nil;
+ Message3 *msg = [Message3 parseFromData:data error:&error];
+ XCTAssertNil(msg, @"i = %zd", i);
+ XCTAssertNotNil(error, @"i = %zd", i);
+ XCTAssertEqualObjects(error.domain, GPBCodedInputStreamErrorDomain, @"i = %zd", i);
+ XCTAssertEqual(error.code, GPBCodedInputStreamErrorInvalidTag, @"i = %zd", i);
+ }
+ }
+}
+
+- (void)testErrorRecursionDepthReached {
+ NSData *data = DataFromCStr(
+ "\x0A\xF2\x01\x0A\xEF\x01\x0A\xEC\x01\x0A\xE9\x01\x0A\xE6\x01"
+ "\x0A\xE3\x01\x0A\xE0\x01\x0A\xDD\x01\x0A\xDA\x01\x0A\xD7\x01"
+ "\x0A\xD4\x01\x0A\xD1\x01\x0A\xCE\x01\x0A\xCB\x01\x0A\xC8\x01"
+ "\x0A\xC5\x01\x0A\xC2\x01\x0A\xBF\x01\x0A\xBC\x01\x0A\xB9\x01"
+ "\x0A\xB6\x01\x0A\xB3\x01\x0A\xB0\x01\x0A\xAD\x01\x0A\xAA\x01"
+ "\x0A\xA7\x01\x0A\xA4\x01\x0A\xA1\x01\x0A\x9E\x01\x0A\x9B\x01"
+ "\x0A\x98\x01\x0A\x95\x01\x0A\x92\x01\x0A\x8F\x01\x0A\x8C\x01"
+ "\x0A\x89\x01\x0A\x86\x01\x0A\x83\x01\x0A\x80\x01\x0A\x7E"
+ "\x0A\x7C\x0A\x7A\x0A\x78\x0A\x76\x0A\x74\x0A\x72\x0A\x70"
+ "\x0A\x6E\x0A\x6C\x0A\x6A\x0A\x68\x0A\x66\x0A\x64\x0A\x62"
+ "\x0A\x60\x0A\x5E\x0A\x5C\x0A\x5A\x0A\x58\x0A\x56\x0A\x54"
+ "\x0A\x52\x0A\x50\x0A\x4E\x0A\x4C\x0A\x4A\x0A\x48\x0A\x46"
+ "\x0A\x44\x0A\x42\x0A\x40\x0A\x3E\x0A\x3C\x0A\x3A\x0A\x38"
+ "\x0A\x36\x0A\x34\x0A\x32\x0A\x30\x0A\x2E\x0A\x2C\x0A\x2A"
+ "\x0A\x28\x0A\x26\x0A\x24\x0A\x22\x0A\x20\x0A\x1E\x0A\x1C"
+ "\x0A\x1A\x0A\x18\x0A\x16\x0A\x14\x0A\x12\x0A\x10\x0A\x0E"
+ "\x0A\x0C\x0A\x0A\x0A\x08\x0A\x06\x12\x04\x72\x02\x4B\x50");
+ NSError *error = nil;
+ NestedTestAllTypes *msg = [NestedTestAllTypes parseFromData:data
+ error:&error];
+ XCTAssertNil(msg);
+ XCTAssertNotNil(error);
+ XCTAssertEqualObjects(error.domain, GPBCodedInputStreamErrorDomain);
+ XCTAssertEqual(error.code, GPBCodedInputStreamErrorRecursionDepthExceeded);
+}
+
+- (void)testParseDelimitedDataWithNegativeSize {
+ NSData *data = DataFromCStr("\xFF\xFF\xFF\xFF\x0F");
+ GPBCodedInputStream *input = [GPBCodedInputStream streamWithData:data];
+ NSError *error;
+ [GPBMessage parseDelimitedFromCodedInputStream:input
+ extensionRegistry:nil
+ error:&error];
+ XCTAssertNil(error);
+}
+
+#ifdef DEBUG
+- (void)testErrorMissingRequiredField {
+ NSData *data = DataFromCStr("");
+ NSError *error = nil;
+ TestRequired *msg = [TestRequired parseFromData:data error:&error];
+ XCTAssertNil(msg);
+ XCTAssertNotNil(error);
+ XCTAssertEqualObjects(error.domain, GPBMessageErrorDomain);
+ XCTAssertEqual(error.code, GPBMessageErrorCodeMissingRequiredField);
+}
+#endif
+
#pragma mark - Subset from from map_tests.cc
// TEST(GeneratedMapFieldTest, StandardWireFormat)
@@ -890,7 +1007,7 @@ static NSData *DataFromCStr(const char *str) {
TestMap *msg = [[TestMap alloc] initWithData:data error:NULL];
XCTAssertEqual(msg.mapInt32Int32.count, 1U);
int32_t val = 666;
- XCTAssertTrue([msg.mapInt32Int32 valueForKey:1 value:&val]);
+ XCTAssertTrue([msg.mapInt32Int32 getInt32:&val forKey:1]);
XCTAssertEqual(val, 1);
[msg release];
@@ -904,7 +1021,7 @@ static NSData *DataFromCStr(const char *str) {
TestMap *msg = [[TestMap alloc] initWithData:data error:NULL];
XCTAssertEqual(msg.mapInt32Int32.count, 1U);
int32_t val = 666;
- XCTAssertTrue([msg.mapInt32Int32 valueForKey:2 value:&val]);
+ XCTAssertTrue([msg.mapInt32Int32 getInt32:&val forKey:2]);
XCTAssertEqual(val, 1);
[msg release];
@@ -918,7 +1035,7 @@ static NSData *DataFromCStr(const char *str) {
TestMap *msg = [[TestMap alloc] initWithData:data error:NULL];
XCTAssertEqual(msg.mapInt32Int32.count, 1U);
int32_t val = 666;
- XCTAssertTrue([msg.mapInt32Int32 valueForKey:2 value:&val]);
+ XCTAssertTrue([msg.mapInt32Int32 getInt32:&val forKey:2]);
XCTAssertEqual(val, 1);
[msg release];
@@ -932,7 +1049,7 @@ static NSData *DataFromCStr(const char *str) {
TestMap *msg = [[TestMap alloc] initWithData:data error:NULL];
XCTAssertEqual(msg.mapInt32Int32.count, 1U);
int32_t val = 666;
- XCTAssertTrue([msg.mapInt32Int32 valueForKey:1 value:&val]);
+ XCTAssertTrue([msg.mapInt32Int32 getInt32:&val forKey:1]);
XCTAssertEqual(val, 2);
[msg release];
@@ -946,7 +1063,7 @@ static NSData *DataFromCStr(const char *str) {
TestMap *msg = [[TestMap alloc] initWithData:data error:NULL];
XCTAssertEqual(msg.mapInt32Int32.count, 1U);
int32_t val = 666;
- XCTAssertTrue([msg.mapInt32Int32 valueForKey:0 value:&val]);
+ XCTAssertTrue([msg.mapInt32Int32 getInt32:&val forKey:0]);
XCTAssertEqual(val, 1);
[msg release];
@@ -960,7 +1077,7 @@ static NSData *DataFromCStr(const char *str) {
TestMap *msg = [[TestMap alloc] initWithData:data error:NULL];
XCTAssertEqual(msg.mapInt32Int32.count, 1U);
int32_t val = 666;
- XCTAssertTrue([msg.mapInt32Int32 valueForKey:1 value:&val]);
+ XCTAssertTrue([msg.mapInt32Int32 getInt32:&val forKey:1]);
XCTAssertEqual(val, 0);
[msg release];
@@ -974,7 +1091,7 @@ static NSData *DataFromCStr(const char *str) {
TestMap *msg = [[TestMap alloc] initWithData:data error:NULL];
XCTAssertEqual(msg.mapInt32Int32.count, 1U);
int32_t val = 666;
- XCTAssertTrue([msg.mapInt32Int32 valueForKey:2 value:&val]);
+ XCTAssertTrue([msg.mapInt32Int32 getInt32:&val forKey:2]);
XCTAssertEqual(val, 3);
[msg release];
@@ -989,29 +1106,29 @@ static NSData *DataFromCStr(const char *str) {
TestMap *msg = [TestMap parseFromData:data error:&error];
XCTAssertNil(msg);
XCTAssertNotNil(error);
- XCTAssertEqualObjects(error.domain, GPBMessageErrorDomain);
- XCTAssertEqual(error.code, GPBMessageErrorCodeMalformedData);
+ XCTAssertEqualObjects(error.domain, GPBCodedInputStreamErrorDomain);
+ XCTAssertEqual(error.code, GPBCodedInputStreamErrorInvalidSubsectionLimit);
}
// TEST(GeneratedMapFieldTest, Proto2UnknownEnum)
- (void)testMap_Proto2UnknownEnum {
TestEnumMapPlusExtra *orig = [[TestEnumMapPlusExtra alloc] init];
- orig.knownMapField = [GPBInt32EnumDictionary
- dictionaryWithValidationFunction:Proto2MapEnumPlusExtra_IsValidValue];
- orig.unknownMapField = [GPBInt32EnumDictionary
- dictionaryWithValidationFunction:Proto2MapEnumPlusExtra_IsValidValue];
- [orig.knownMapField setValue:Proto2MapEnumPlusExtra_EProto2MapEnumFoo
- forKey:0];
- [orig.unknownMapField setValue:Proto2MapEnumPlusExtra_EProto2MapEnumExtra
- forKey:0];
+ orig.knownMapField = [[[GPBInt32EnumDictionary alloc]
+ initWithValidationFunction:Proto2MapEnumPlusExtra_IsValidValue] autorelease];
+ orig.unknownMapField = [[[GPBInt32EnumDictionary alloc]
+ initWithValidationFunction:Proto2MapEnumPlusExtra_IsValidValue] autorelease];
+ [orig.knownMapField setEnum:Proto2MapEnumPlusExtra_EProto2MapEnumFoo
+ forKey:0];
+ [orig.unknownMapField setEnum:Proto2MapEnumPlusExtra_EProto2MapEnumExtra
+ forKey:0];
NSData *data = [orig data];
XCTAssertNotNil(data);
TestEnumMap *msg1 = [TestEnumMap parseFromData:data error:NULL];
XCTAssertEqual(msg1.knownMapField.count, 1U);
int32_t val = -1;
- XCTAssertTrue([msg1.knownMapField valueForKey:0 value:&val]);
+ XCTAssertTrue([msg1.knownMapField getEnum:&val forKey:0]);
XCTAssertEqual(val, Proto2MapEnum_Proto2MapEnumFoo);
XCTAssertEqual(msg1.unknownFields.countOfFields, 1U);
@@ -1020,11 +1137,11 @@ static NSData *DataFromCStr(const char *str) {
[TestEnumMapPlusExtra parseFromData:data error:NULL];
val = -1;
XCTAssertEqual(msg2.knownMapField.count, 1U);
- XCTAssertTrue([msg2.knownMapField valueForKey:0 value:&val]);
+ XCTAssertTrue([msg2.knownMapField getEnum:&val forKey:0]);
XCTAssertEqual(val, Proto2MapEnumPlusExtra_EProto2MapEnumFoo);
val = -1;
XCTAssertEqual(msg2.unknownMapField.count, 1U);
- XCTAssertTrue([msg2.unknownMapField valueForKey:0 value:&val]);
+ XCTAssertTrue([msg2.unknownMapField getEnum:&val forKey:0]);
XCTAssertEqual(val, Proto2MapEnumPlusExtra_EProto2MapEnumExtra);
XCTAssertEqual(msg2.unknownFields.countOfFields, 0U);
@@ -1040,32 +1157,37 @@ static NSData *DataFromCStr(const char *str) {
// Key/Value data should result in different byte lengths on wire to ensure
// everything is right.
- [msg.mapInt32Int32 setValue:1000 forKey:200];
- [msg.mapInt32Int32 setValue:101 forKey:2001];
- [msg.mapInt64Int64 setValue:1002 forKey:202];
- [msg.mapInt64Int64 setValue:103 forKey:2003];
- [msg.mapUint32Uint32 setValue:1004 forKey:204];
- [msg.mapUint32Uint32 setValue:105 forKey:2005];
- [msg.mapUint64Uint64 setValue:1006 forKey:206];
- [msg.mapUint64Uint64 setValue:107 forKey:2007];
- [msg.mapSint32Sint32 setValue:1008 forKey:208];
- [msg.mapSint32Sint32 setValue:109 forKey:2009];
- [msg.mapSint64Sint64 setValue:1010 forKey:210];
- [msg.mapSint64Sint64 setValue:111 forKey:2011];
- [msg.mapFixed32Fixed32 setValue:1012 forKey:212];
- [msg.mapFixed32Fixed32 setValue:113 forKey:2013];
- [msg.mapFixed64Fixed64 setValue:1014 forKey:214];
- [msg.mapFixed64Fixed64 setValue:115 forKey:2015];
- [msg.mapSfixed32Sfixed32 setValue:1016 forKey:216];
- [msg.mapSfixed32Sfixed32 setValue:117 forKey:2017];
- [msg.mapSfixed64Sfixed64 setValue:1018 forKey:218];
- [msg.mapSfixed64Sfixed64 setValue:119 forKey:2019];
- [msg.mapInt32Float setValue:1020.f forKey:220];
- [msg.mapInt32Float setValue:121.f forKey:2021];
- [msg.mapInt32Double setValue:1022. forKey:222];
- [msg.mapInt32Double setValue:123. forKey:2023];
- [msg.mapBoolBool setValue:false forKey:true];
- [msg.mapBoolBool setValue:true forKey:false];
+ [msg.mapInt32Int32 setInt32:1000 forKey:200];
+ [msg.mapInt32Int32 setInt32:101 forKey:2001];
+ [msg.mapInt64Int64 setInt64:1002 forKey:202];
+ [msg.mapInt64Int64 setInt64:103 forKey:2003];
+ [msg.mapInt64Int64 setInt64:4294967296 forKey:4294967297];
+ [msg.mapUint32Uint32 setUInt32:1004 forKey:204];
+ [msg.mapUint32Uint32 setUInt32:105 forKey:2005];
+ [msg.mapUint64Uint64 setUInt64:1006 forKey:206];
+ [msg.mapUint64Uint64 setUInt64:107 forKey:2007];
+ [msg.mapUint64Uint64 setUInt64:4294967298 forKey:4294967299];
+ [msg.mapSint32Sint32 setInt32:1008 forKey:208];
+ [msg.mapSint32Sint32 setInt32:109 forKey:2009];
+ [msg.mapSint64Sint64 setInt64:1010 forKey:210];
+ [msg.mapSint64Sint64 setInt64:111 forKey:2011];
+ [msg.mapSint64Sint64 setInt64:4294967300 forKey:4294967301];
+ [msg.mapFixed32Fixed32 setUInt32:1012 forKey:212];
+ [msg.mapFixed32Fixed32 setUInt32:113 forKey:2013];
+ [msg.mapFixed64Fixed64 setUInt64:1014 forKey:214];
+ [msg.mapFixed64Fixed64 setUInt64:115 forKey:2015];
+ [msg.mapFixed64Fixed64 setUInt64:4294967302 forKey:4294967303];
+ [msg.mapSfixed32Sfixed32 setInt32:1016 forKey:216];
+ [msg.mapSfixed32Sfixed32 setInt32:117 forKey:2017];
+ [msg.mapSfixed64Sfixed64 setInt64:1018 forKey:218];
+ [msg.mapSfixed64Sfixed64 setInt64:119 forKey:2019];
+ [msg.mapSfixed64Sfixed64 setInt64:4294967304 forKey:4294967305];
+ [msg.mapInt32Float setFloat:1020.f forKey:220];
+ [msg.mapInt32Float setFloat:121.f forKey:2021];
+ [msg.mapInt32Double setDouble:1022. forKey:222];
+ [msg.mapInt32Double setDouble:123. forKey:2023];
+ [msg.mapBoolBool setBool:false forKey:true];
+ [msg.mapBoolBool setBool:true forKey:false];
msg.mapStringString[@"224"] = @"1024";
msg.mapStringString[@"2025"] = @"125";
msg.mapStringBytes[@"226"] = DataFromCStr("1026");
@@ -1074,12 +1196,12 @@ static NSData *DataFromCStr(const char *str) {
val1.optionalInt32 = 1028;
Message2 *val2 = [[Message2 alloc] init];
val2.optionalInt32 = 129;
- [msg.mapStringMessage setValue:val1 forKey:@"228"];
- [msg.mapStringMessage setValue:val2 forKey:@"2029"];
+ [msg.mapStringMessage setObject:val1 forKey:@"228"];
+ [msg.mapStringMessage setObject:val2 forKey:@"2029"];
[msg.mapInt32Bytes setObject:DataFromCStr("1030 bytes") forKey:230];
[msg.mapInt32Bytes setObject:DataFromCStr("131") forKey:2031];
- [msg.mapInt32Enum setValue:Message2_Enum_Bar forKey:232];
- [msg.mapInt32Enum setValue:Message2_Enum_Baz forKey:2033];
+ [msg.mapInt32Enum setEnum:Message2_Enum_Bar forKey:232];
+ [msg.mapInt32Enum setEnum:Message2_Enum_Baz forKey:2033];
Message2 *val3 = [[Message2 alloc] init];
val3.optionalInt32 = 1034;
Message2 *val4 = [[Message2 alloc] init];
diff --git a/objectivec/Tests/GPBMessageTests.m b/objectivec/Tests/GPBMessageTests.m
index 7b37ca95..a3149096 100644
--- a/objectivec/Tests/GPBMessageTests.m
+++ b/objectivec/Tests/GPBMessageTests.m
@@ -1082,6 +1082,20 @@
[repeatedStringArray release];
}
+- (void)testSetOverAutocreatedArrayAndSetAgain {
+ // Ensure when dealing with replacing an array it is handled being either
+ // an autocreated one or a straight NSArray.
+
+ // The real test here is that nothing crashes while doing the work.
+ TestAllTypes *message = [TestAllTypes message];
+ [message.repeatedStringArray addObject:@"foo"];
+ XCTAssertEqual(message.repeatedStringArray_Count, (NSUInteger)1);
+ message.repeatedStringArray = [NSMutableArray arrayWithObjects:@"bar", @"bar2", nil];
+ XCTAssertEqual(message.repeatedStringArray_Count, (NSUInteger)2);
+ message.repeatedStringArray = [NSMutableArray arrayWithObject:@"baz"];
+ XCTAssertEqual(message.repeatedStringArray_Count, (NSUInteger)1);
+}
+
- (void)testReplaceAutocreatedArray {
// Replacing array should orphan the old one and cause its creator to become
// visible.
@@ -1171,7 +1185,7 @@
XCTAssertFalse([message2.a hasA]);
// But adding an element to the map should.
- [message.a.a.iToI setValue:100 forKey:200];
+ [message.a.a.iToI setInt32:100 forKey:200];
XCTAssertTrue([message hasA]);
XCTAssertTrue([message.a hasA]);
XCTAssertEqual([message.a.a.iToI count], (NSUInteger)1);
@@ -1190,7 +1204,7 @@
message1a.a.iToI = message1b.a.iToI;
XCTAssertTrue([message1a hasA]);
XCTAssertFalse([message1b hasA]);
- [message1a.a.iToI setValue:1 forKey:2];
+ [message1a.a.iToI setInt32:1 forKey:2];
XCTAssertTrue([message1a hasA]);
XCTAssertTrue([message1b hasA]);
XCTAssertEqual(message1a.a.iToI, message1b.a.iToI);
@@ -1224,7 +1238,8 @@
// with different objects that are equal).
TestRecursiveMessageWithRepeatedField *message3 =
[TestRecursiveMessageWithRepeatedField message];
- message3.iToI = [GPBInt32Int32Dictionary dictionaryWithValue:10 forKey:20];
+ message3.iToI = [[[GPBInt32Int32Dictionary alloc] init] autorelease];
+ [message3.iToI setInt32:10 forKey:20];
message3.strToStr =
[NSMutableDictionary dictionaryWithObject:@"abc" forKey:@"123"];
XCTAssertNotNil(message.iToI);
@@ -1281,6 +1296,23 @@
[strToStr release];
}
+- (void)testSetOverAutocreatedMapAndSetAgain {
+ // Ensure when dealing with replacing a map it is handled being either
+ // an autocreated one or a straight NSDictionary.
+
+ // The real test here is that nothing crashes while doing the work.
+ TestRecursiveMessageWithRepeatedField *message =
+ [TestRecursiveMessageWithRepeatedField message];
+ message.strToStr[@"foo"] = @"bar";
+ XCTAssertEqual(message.strToStr_Count, (NSUInteger)1);
+ message.strToStr =
+ [NSMutableDictionary dictionaryWithObjectsAndKeys:@"bar", @"key1", @"baz", @"key2", nil];
+ XCTAssertEqual(message.strToStr_Count, (NSUInteger)2);
+ message.strToStr =
+ [NSMutableDictionary dictionaryWithObject:@"baz" forKey:@"mumble"];
+ XCTAssertEqual(message.strToStr_Count, (NSUInteger)1);
+}
+
- (void)testReplaceAutocreatedMap {
// Replacing map should orphan the old one and cause its creator to become
// visible.
@@ -1292,7 +1324,8 @@
XCTAssertFalse([message hasA]);
GPBInt32Int32Dictionary *iToI = [message.a.iToI retain];
XCTAssertEqual(iToI->_autocreator, message.a); // Pointer comparision
- message.a.iToI = [GPBInt32Int32Dictionary dictionaryWithValue:6 forKey:7];
+ message.a.iToI = [[[GPBInt32Int32Dictionary alloc] init] autorelease];
+ [message.a.iToI setInt32:6 forKey:7];
XCTAssertTrue([message hasA]);
XCTAssertNotEqual(message.a.iToI, iToI); // Pointer comparision
XCTAssertNil(iToI->_autocreator);
@@ -1820,6 +1853,24 @@
XCTAssertEqualObjects(enumDescriptor, expectedDescriptor);
}
+- (void)testPropertyNaming {
+ // objectivec_helpers.cc has some special handing to get proper all caps
+ // for a few cases to meet objc developer expectations.
+ //
+ // This "test" confirms that the expected names are generated, otherwise the
+ // test itself will fail to compile.
+ ObjCPropertyNaming *msg = [ObjCPropertyNaming message];
+ // On their own, at the end, in the middle.
+ msg.URL = @"good";
+ msg.thumbnailURL = @"good";
+ msg.URLFoo = @"good";
+ msg.someURLBlah = @"good";
+ msg.HTTP = @"good";
+ msg.HTTPS = @"good";
+ // No caps since it was "urls".
+ [msg.urlsArray addObject:@"good"];
+}
+
- (void)testEnumNaming {
// objectivec_helpers.cc has some interesting cases to deal with in
// EnumValueName/EnumValueShortName. Confirm that things generated as
@@ -1929,4 +1980,127 @@
EnumTestMsg_MyEnum_NegTwo);
}
+- (void)testOneBasedEnumHolder {
+ // Test case for https://github.com/google/protobuf/issues/1453
+ // Message with no explicit defaults, but a non zero default for an enum.
+ MessageWithOneBasedEnum *enumMsg = [MessageWithOneBasedEnum message];
+ XCTAssertEqual(enumMsg.enumField, MessageWithOneBasedEnum_OneBasedEnum_One);
+}
+
+- (void)testBoolOffsetUsage {
+ // Bools use storage within has_bits; this test ensures that this is honored
+ // in all places where things should crash or fail based on reading out of
+ // field storage instead.
+ BoolOnlyMessage *msg1 = [BoolOnlyMessage message];
+ BoolOnlyMessage *msg2 = [BoolOnlyMessage message];
+
+ msg1.boolField1 = YES;
+ msg2.boolField1 = YES;
+ msg1.boolField3 = YES;
+ msg2.boolField3 = YES;
+ msg1.boolField5 = YES;
+ msg2.boolField5 = YES;
+ msg1.boolField7 = YES;
+ msg2.boolField7 = YES;
+ msg1.boolField9 = YES;
+ msg2.boolField9 = YES;
+ msg1.boolField11 = YES;
+ msg2.boolField11 = YES;
+ msg1.boolField13 = YES;
+ msg2.boolField13 = YES;
+ msg1.boolField15 = YES;
+ msg2.boolField15 = YES;
+ msg1.boolField17 = YES;
+ msg2.boolField17 = YES;
+ msg1.boolField19 = YES;
+ msg2.boolField19 = YES;
+ msg1.boolField21 = YES;
+ msg2.boolField21 = YES;
+ msg1.boolField23 = YES;
+ msg2.boolField23 = YES;
+ msg1.boolField25 = YES;
+ msg2.boolField25 = YES;
+ msg1.boolField27 = YES;
+ msg2.boolField27 = YES;
+ msg1.boolField29 = YES;
+ msg2.boolField29 = YES;
+ msg1.boolField31 = YES;
+ msg2.boolField31 = YES;
+
+ msg1.boolField32 = YES;
+ msg2.boolField32 = YES;
+
+ XCTAssertTrue(msg1 != msg2); // Different pointers.
+ XCTAssertEqual([msg1 hash], [msg2 hash]);
+ XCTAssertEqualObjects(msg1, msg2);
+
+ BoolOnlyMessage *msg1Prime = [[msg1 copy] autorelease];
+ XCTAssertTrue(msg1Prime != msg1); // Different pointers.
+ XCTAssertEqual([msg1 hash], [msg1Prime hash]);
+ XCTAssertEqualObjects(msg1, msg1Prime);
+
+ // Field set in one, but not the other means they don't match (even if
+ // set to default value).
+ msg1Prime.boolField2 = NO;
+ XCTAssertNotEqualObjects(msg1Prime, msg1);
+ // And when set to different values.
+ msg1.boolField2 = YES;
+ XCTAssertNotEqualObjects(msg1Prime, msg1);
+ // And then they match again.
+ msg1.boolField2 = NO;
+ XCTAssertEqualObjects(msg1Prime, msg1);
+ XCTAssertEqual([msg1 hash], [msg1Prime hash]);
+}
+
+- (void)testCopyingMapFileds {
+ TestMessageOfMaps *msg = [TestMessageOfMaps message];
+
+ msg.strToStr[@"foo"] = @"bar";
+
+ [msg.strToInt setInt32:1 forKey:@"mumble"];
+ [msg.intToStr setObject:@"wee" forKey:42];
+ [msg.intToInt setInt32:123 forKey:321];
+
+ [msg.strToBool setBool:YES forKey:@"one"];
+ [msg.boolToStr setObject:@"something" forKey:YES];
+ [msg.boolToBool setBool:YES forKey:NO];
+
+ [msg.intToBool setBool:YES forKey:13];
+ [msg.boolToInt setInt32:111 forKey:NO];
+
+ TestAllTypes *subMsg1 = [TestAllTypes message];
+ subMsg1.optionalInt32 = 1;
+ TestAllTypes *subMsg2 = [TestAllTypes message];
+ subMsg1.optionalInt32 = 2;
+ TestAllTypes *subMsg3 = [TestAllTypes message];
+ subMsg1.optionalInt32 = 3;
+
+ msg.strToMsg[@"baz"] = subMsg1;
+ [msg.intToMsg setObject:subMsg2 forKey:222];
+ [msg.boolToMsg setObject:subMsg3 forKey:YES];
+
+ TestMessageOfMaps *msg2 = [[msg copy] autorelease];
+ XCTAssertNotNil(msg2);
+ XCTAssertEqualObjects(msg2, msg);
+ XCTAssertTrue(msg2 != msg); // ptr compare
+ XCTAssertTrue(msg.strToStr != msg2.strToStr); // ptr compare
+ XCTAssertTrue(msg.intToStr != msg2.intToStr); // ptr compare
+ XCTAssertTrue(msg.intToInt != msg2.intToInt); // ptr compare
+ XCTAssertTrue(msg.strToBool != msg2.strToBool); // ptr compare
+ XCTAssertTrue(msg.boolToStr != msg2.boolToStr); // ptr compare
+ XCTAssertTrue(msg.boolToBool != msg2.boolToBool); // ptr compare
+ XCTAssertTrue(msg.intToBool != msg2.intToBool); // ptr compare
+ XCTAssertTrue(msg.boolToInt != msg2.boolToInt); // ptr compare
+ XCTAssertTrue(msg.strToMsg != msg2.strToMsg); // ptr compare
+ XCTAssertTrue(msg.intToMsg != msg2.intToMsg); // ptr compare
+ XCTAssertTrue(msg.boolToMsg != msg2.boolToMsg); // ptr compare
+
+ XCTAssertTrue(msg.strToMsg[@"baz"] != msg2.strToMsg[@"baz"]); // ptr compare
+ XCTAssertEqualObjects(msg.strToMsg[@"baz"], msg2.strToMsg[@"baz"]);
+ XCTAssertTrue([msg.intToMsg objectForKey:222] != [msg2.intToMsg objectForKey:222]); // ptr compare
+ XCTAssertEqualObjects([msg.intToMsg objectForKey:222], [msg2.intToMsg objectForKey:222]);
+ XCTAssertTrue([msg.boolToMsg objectForKey:YES] != [msg2.boolToMsg objectForKey:YES]); // ptr compare
+ XCTAssertEqualObjects([msg.boolToMsg objectForKey:YES], [msg2.boolToMsg objectForKey:YES]);
+}
+
@end
diff --git a/objectivec/Tests/GPBPerfTests.m b/objectivec/Tests/GPBPerfTests.m
index 1259d146..8dd0ffc5 100644
--- a/objectivec/Tests/GPBPerfTests.m
+++ b/objectivec/Tests/GPBPerfTests.m
@@ -64,6 +64,112 @@ static const uint32_t kRepeatedCount = 100;
}];
}
+- (void)testMessageSerialParsingPerformance {
+ // This and the next test are meant to monitor that the parsing functionality of protos does not
+ // lock across threads when parsing different instances. The Serial version of the test should run
+ // around ~2 times slower than the Parallel version since it's parsing the protos in the same
+ // thread.
+ TestAllTypes *allTypesMessage = [TestAllTypes message];
+ [self setAllFields:allTypesMessage repeatedCount:2];
+ NSData *allTypesData = allTypesMessage.data;
+
+ [self measureBlock:^{
+ for (int i = 0; i < 500; ++i) {
+ [TestAllTypes parseFromData:allTypesData error:NULL];
+ [TestAllTypes parseFromData:allTypesData error:NULL];
+ }
+ }];
+}
+
+- (void)testMessageParallelParsingPerformance {
+ // This and the previous test are meant to monitor that the parsing functionality of protos does
+ // not lock across threads when parsing different instances. The Serial version of the test should
+ // run around ~2 times slower than the Parallel version since it's parsing the protos in the same
+ // thread.
+ TestAllTypes *allTypesMessage = [TestAllTypes message];
+ [self setAllFields:allTypesMessage repeatedCount:2];
+ NSData *allTypesData = allTypesMessage.data;
+
+ dispatch_queue_t concurrentQueue = dispatch_queue_create("perfQueue", DISPATCH_QUEUE_CONCURRENT);
+
+ [self measureBlock:^{
+ for (int i = 0; i < 500; ++i) {
+ dispatch_group_t group = dispatch_group_create();
+
+ dispatch_group_async(group, concurrentQueue, ^{
+ [TestAllTypes parseFromData:allTypesData error:NULL];
+ });
+
+ dispatch_group_async(group, concurrentQueue, ^{
+ [TestAllTypes parseFromData:allTypesData error:NULL];
+ });
+
+ dispatch_group_notify(group, concurrentQueue, ^{});
+
+ dispatch_release(group);
+ }
+ }];
+
+ dispatch_release(concurrentQueue);
+}
+
+- (void)testMessageSerialExtensionsParsingPerformance {
+ // This and the next test are meant to monitor that the parsing functionality of protos does not
+ // lock across threads when parsing different instances when using extensions. The Serial version
+ // of the test should run around ~2 times slower than the Parallel version since it's parsing the
+ // protos in the same thread.
+ TestAllExtensions *allExtensionsMessage = [TestAllExtensions message];
+ [self setAllExtensions:allExtensionsMessage repeatedCount:2];
+ NSData *allExtensionsData = allExtensionsMessage.data;
+
+ [self measureBlock:^{
+ for (int i = 0; i < 500; ++i) {
+ [TestAllExtensions parseFromData:allExtensionsData
+ extensionRegistry:[self extensionRegistry]
+ error:NULL];
+ [TestAllExtensions parseFromData:allExtensionsData
+ extensionRegistry:[self extensionRegistry]
+ error:NULL];
+ }
+ }];
+}
+
+- (void)testMessageParallelExtensionsParsingPerformance {
+ // This and the previous test are meant to monitor that the parsing functionality of protos does
+ // not lock across threads when parsing different instances when using extensions. The Serial
+ // version of the test should run around ~2 times slower than the Parallel version since it's
+ // parsing the protos in the same thread.
+ TestAllExtensions *allExtensionsMessage = [TestAllExtensions message];
+ [self setAllExtensions:allExtensionsMessage repeatedCount:2];
+ NSData *allExtensionsData = allExtensionsMessage.data;
+
+ dispatch_queue_t concurrentQueue = dispatch_queue_create("perfQueue", DISPATCH_QUEUE_CONCURRENT);
+
+ [self measureBlock:^{
+ for (int i = 0; i < 500; ++i) {
+ dispatch_group_t group = dispatch_group_create();
+
+ dispatch_group_async(group, concurrentQueue, ^{
+ [TestAllExtensions parseFromData:allExtensionsData
+ extensionRegistry:[UnittestRoot extensionRegistry]
+ error:NULL];
+ });
+
+ dispatch_group_async(group, concurrentQueue, ^{
+ [TestAllExtensions parseFromData:allExtensionsData
+ extensionRegistry:[UnittestRoot extensionRegistry]
+ error:NULL];
+ });
+
+ dispatch_group_notify(group, concurrentQueue, ^{});
+
+ dispatch_release(group);
+ }
+ }];
+
+ dispatch_release(concurrentQueue);
+}
+
- (void)testExtensionsPerformance {
[self measureBlock:^{
for (int i = 0; i < 200; ++i) {
diff --git a/objectivec/Tests/GPBSwiftTests.swift b/objectivec/Tests/GPBSwiftTests.swift
index 36ed2a62..9d8a0fae 100644
--- a/objectivec/Tests/GPBSwiftTests.swift
+++ b/objectivec/Tests/GPBSwiftTests.swift
@@ -42,23 +42,23 @@ class GPBBridgeTests: XCTestCase {
msg.optionalInt32 = 100
msg.optionalString = "abc"
- msg.optionalEnum = .Bar
+ msg.optionalEnum = .bar
msg2.optionalString = "other"
- msg.optionalMessage = msg2
+ msg.optional = msg2
msg3.a = 200
msg.optionalGroup = msg3
msg.repeatedInt32Array.addValue(300)
msg.repeatedInt32Array.addValue(301)
- msg.repeatedStringArray.addObject("mno")
- msg.repeatedStringArray.addObject("pqr")
- msg.repeatedEnumArray.addValue(Message2_Enum.Bar.rawValue)
- msg.repeatedEnumArray.addValue(Message2_Enum.Baz.rawValue)
- msg.mapInt32Int32.setValue(400, forKey:500)
- msg.mapInt32Int32.setValue(401, forKey:501)
- msg.mapStringString.setObject("foo", forKey:"bar")
- msg.mapStringString.setObject("abc", forKey:"xyz")
- msg.mapInt32Enum.setValue(Message2_Enum.Bar.rawValue, forKey:600)
- msg.mapInt32Enum.setValue(Message2_Enum.Baz.rawValue, forKey:601)
+ msg.repeatedStringArray.add("mno")
+ msg.repeatedStringArray.add("pqr")
+ msg.repeatedEnumArray.addValue(Message2_Enum.bar.rawValue)
+ msg.repeatedEnumArray.addValue(Message2_Enum.baz.rawValue)
+ msg.mapInt32Int32.setInt32(400, forKey:500)
+ msg.mapInt32Int32.setInt32(401, forKey:501)
+ msg.mapStringString.setObject("foo", forKey:"bar" as NSString)
+ msg.mapStringString.setObject("abc", forKey:"xyz" as NSString)
+ msg.mapInt32Enum.setEnum(Message2_Enum.bar.rawValue, forKey:600)
+ msg.mapInt32Enum.setEnum(Message2_Enum.baz.rawValue, forKey:601)
// Check has*.
XCTAssertTrue(msg.hasOptionalInt32)
@@ -75,34 +75,34 @@ class GPBBridgeTests: XCTestCase {
XCTAssertEqual(msg.optionalInt32, Int32(100))
XCTAssertEqual(msg.optionalString, "abc")
XCTAssertEqual(msg2.optionalString, "other")
- XCTAssertTrue(msg.optionalMessage === msg2)
- XCTAssertEqual(msg.optionalEnum, Message2_Enum.Bar)
+ XCTAssertTrue(msg.optional === msg2)
+ XCTAssertEqual(msg.optionalEnum, Message2_Enum.bar)
XCTAssertEqual(msg3.a, Int32(200))
XCTAssertTrue(msg.optionalGroup === msg3)
XCTAssertEqual(msg.repeatedInt32Array.count, UInt(2))
- XCTAssertEqual(msg.repeatedInt32Array.valueAtIndex(0), Int32(300))
- XCTAssertEqual(msg.repeatedInt32Array.valueAtIndex(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.objectAtIndex(0) as? String, "mno")
- XCTAssertEqual(msg.repeatedStringArray.objectAtIndex(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.valueAtIndex(0), Message2_Enum.Bar.rawValue)
- XCTAssertEqual(msg.repeatedEnumArray.valueAtIndex(1), Message2_Enum.Baz.rawValue)
+ XCTAssertEqual(msg.repeatedEnumArray.value(at: 0), Message2_Enum.bar.rawValue)
+ XCTAssertEqual(msg.repeatedEnumArray.value(at: 1), Message2_Enum.baz.rawValue)
XCTAssertEqual(msg.repeatedInt64Array.count, UInt(0))
XCTAssertEqual(msg.mapInt32Int32.count, UInt(2))
- var intValue: Int32 = 0;
- XCTAssertTrue(msg.mapInt32Int32.valueForKey(500, value:&intValue))
+ var intValue: Int32 = 0
+ XCTAssertTrue(msg.mapInt32Int32.getInt32(&intValue, forKey: 500))
XCTAssertEqual(intValue, Int32(400))
- XCTAssertTrue(msg.mapInt32Int32.valueForKey(501, value:&intValue))
+ XCTAssertTrue(msg.mapInt32Int32.getInt32(&intValue, forKey: 501))
XCTAssertEqual(intValue, Int32(401))
XCTAssertEqual(msg.mapStringString.count, Int(2))
- XCTAssertEqual(msg.mapStringString.objectForKey("bar") as? String, "foo")
- XCTAssertEqual(msg.mapStringString.objectForKey("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.valueForKey(600, value:&intValue))
- XCTAssertEqual(intValue, Message2_Enum.Bar.rawValue)
- XCTAssertTrue(msg.mapInt32Enum.valueForKey(601, value:&intValue))
- XCTAssertEqual(intValue, Message2_Enum.Baz.rawValue)
+ XCTAssertTrue(msg.mapInt32Enum.getEnum(&intValue, forKey:600))
+ XCTAssertEqual(intValue, Message2_Enum.bar.rawValue)
+ XCTAssertTrue(msg.mapInt32Enum.getEnum(&intValue, forKey:601))
+ XCTAssertEqual(intValue, Message2_Enum.baz.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.optionalMessage !== msg2) // New instance
- XCTAssertEqual(msg.optionalEnum, Message2_Enum.Foo) // Default
+ XCTAssertTrue(msg.optional !== msg2) // New instance
+ XCTAssertEqual(msg.optionalEnum, Message2_Enum.foo) // 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 = .Bar
+ msg.optionalEnum = .bar
msg2.optionalString = "other"
- msg.optionalMessage = msg2
+ msg.optional = msg2
msg.repeatedInt32Array.addValue(300)
msg.repeatedInt32Array.addValue(301)
- msg.repeatedStringArray.addObject("mno")
- msg.repeatedStringArray.addObject("pqr")
+ msg.repeatedStringArray.add("mno")
+ msg.repeatedStringArray.add("pqr")
// "proto3" syntax lets enum get unknown values.
- msg.repeatedEnumArray.addValue(Message3_Enum.Bar.rawValue)
+ msg.repeatedEnumArray.addValue(Message3_Enum.bar.rawValue)
msg.repeatedEnumArray.addRawValue(666)
SetMessage3_OptionalEnum_RawValue(msg2, 666)
- msg.mapInt32Int32.setValue(400, forKey:500)
- msg.mapInt32Int32.setValue(401, forKey:501)
- msg.mapStringString.setObject("foo", forKey:"bar")
- msg.mapStringString.setObject("abc", forKey:"xyz")
- msg.mapInt32Enum.setValue(Message2_Enum.Bar.rawValue, forKey:600)
+ msg.mapInt32Int32.setInt32(400, forKey:500)
+ msg.mapInt32Int32.setInt32(401, forKey:501)
+ msg.mapStringString.setObject("foo", forKey:"bar" as NSString)
+ msg.mapStringString.setObject("abc", forKey:"xyz" as NSString)
+ msg.mapInt32Enum.setEnum(Message2_Enum.bar.rawValue, forKey:600)
// "proto3" syntax lets enum get unknown values.
msg.mapInt32Enum.setRawValue(666, forKey:601)
@@ -167,36 +167,36 @@ class GPBBridgeTests: XCTestCase {
XCTAssertEqual(msg.optionalInt32, Int32(100))
XCTAssertEqual(msg.optionalString, "abc")
XCTAssertEqual(msg2.optionalString, "other")
- XCTAssertTrue(msg.optionalMessage === msg2)
- XCTAssertEqual(msg.optionalEnum, Message3_Enum.Bar)
+ XCTAssertTrue(msg.optional === msg2)
+ XCTAssertEqual(msg.optionalEnum, Message3_Enum.bar)
XCTAssertEqual(msg.repeatedInt32Array.count, UInt(2))
- XCTAssertEqual(msg.repeatedInt32Array.valueAtIndex(0), Int32(300))
- XCTAssertEqual(msg.repeatedInt32Array.valueAtIndex(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.objectAtIndex(0) as? String, "mno")
- XCTAssertEqual(msg.repeatedStringArray.objectAtIndex(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.valueAtIndex(0), Message3_Enum.Bar.rawValue)
- XCTAssertEqual(msg.repeatedEnumArray.valueAtIndex(1), Message3_Enum.GPBUnrecognizedEnumeratorValue.rawValue)
- XCTAssertEqual(msg.repeatedEnumArray.rawValueAtIndex(1), 666)
- XCTAssertEqual(msg2.optionalEnum, Message3_Enum.GPBUnrecognizedEnumeratorValue)
+ XCTAssertEqual(msg.repeatedEnumArray.value(at: 0), Message3_Enum.bar.rawValue)
+ XCTAssertEqual(msg.repeatedEnumArray.value(at: 1), Message3_Enum.gpbUnrecognizedEnumeratorValue.rawValue)
+ XCTAssertEqual(msg.repeatedEnumArray.rawValue(at: 1), 666)
+ XCTAssertEqual(msg2.optionalEnum, Message3_Enum.gpbUnrecognizedEnumeratorValue)
XCTAssertEqual(Message3_OptionalEnum_RawValue(msg2), Int32(666))
XCTAssertEqual(msg.mapInt32Int32.count, UInt(2))
- var intValue: Int32 = 0;
- XCTAssertTrue(msg.mapInt32Int32.valueForKey(500, value:&intValue))
+ var intValue: Int32 = 0
+ XCTAssertTrue(msg.mapInt32Int32.getInt32(&intValue, forKey:500))
XCTAssertEqual(intValue, Int32(400))
- XCTAssertTrue(msg.mapInt32Int32.valueForKey(501, value:&intValue))
+ XCTAssertTrue(msg.mapInt32Int32.getInt32(&intValue, forKey:501))
XCTAssertEqual(intValue, Int32(401))
XCTAssertEqual(msg.mapStringString.count, Int(2))
- XCTAssertEqual(msg.mapStringString.objectForKey("bar") as? String, "foo")
- XCTAssertEqual(msg.mapStringString.objectForKey("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.valueForKey(600, value:&intValue))
- XCTAssertEqual(intValue, Message2_Enum.Bar.rawValue)
- XCTAssertTrue(msg.mapInt32Enum.valueForKey(601, value:&intValue))
- XCTAssertEqual(intValue, Message3_Enum.GPBUnrecognizedEnumeratorValue.rawValue)
- XCTAssertTrue(msg.mapInt32Enum.valueForKey(601, rawValue:&intValue))
+ XCTAssertTrue(msg.mapInt32Enum.getEnum(&intValue, forKey:600))
+ XCTAssertEqual(intValue, Message2_Enum.bar.rawValue)
+ XCTAssertTrue(msg.mapInt32Enum.getEnum(&intValue, forKey:601))
+ XCTAssertEqual(intValue, Message3_Enum.gpbUnrecognizedEnumeratorValue.rawValue)
+ XCTAssertTrue(msg.mapInt32Enum.getRawValue(&intValue, forKey:601))
XCTAssertEqual(intValue, 666)
// Clearing a string with nil.
@@ -204,23 +204,23 @@ class GPBBridgeTests: XCTestCase {
XCTAssertEqual(msg2.optionalString, "")
// Clearing a message with nil.
- msg.optionalMessage = nil
+ msg.optional = nil
XCTAssertFalse(msg.hasOptionalMessage)
- XCTAssertTrue(msg.optionalMessage !== 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.optionalMessage !== msg2) // New instance
- XCTAssertEqual(msg.optionalEnum, Message3_Enum.Foo) // Default
+ XCTAssertTrue(msg.optional !== msg2) // New instance
+ XCTAssertEqual(msg.optionalEnum, Message3_Enum.foo) // 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.Foo) // Default
- XCTAssertEqual(Message3_OptionalEnum_RawValue(msg2), Message3_Enum.Foo.rawValue)
+ XCTAssertEqual(msg2.optionalEnum, Message3_Enum.foo) // Default
+ XCTAssertEqual(Message3_OptionalEnum_RawValue(msg2), Message3_Enum.foo.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.optionalMessage.optionalMessage
- let msg4 = msg.optionalMessage
+ let msg3 = msg.optional.optional
+ let msg4 = msg.optional
XCTAssertNotNil(msg2)
XCTAssertNotNil(msg3)
XCTAssertFalse(msg.hasOptionalGroup)
- XCTAssertFalse(msg.optionalMessage.hasOptionalMessage)
+ XCTAssertFalse(msg.optional.hasOptionalMessage)
XCTAssertFalse(msg.hasOptionalMessage)
// Setting things should trigger has* getting set.
msg.optionalGroup.a = 10
- msg.optionalMessage.optionalMessage.optionalInt32 = 100
+ msg.optional.optional.optionalInt32 = 100
XCTAssertTrue(msg.hasOptionalGroup)
- XCTAssertTrue(msg.optionalMessage.hasOptionalMessage)
+ XCTAssertTrue(msg.optional.hasOptionalMessage)
XCTAssertTrue(msg.hasOptionalMessage)
// And they should be the same pointer as before.
XCTAssertTrue(msg2 === msg.optionalGroup)
- XCTAssertTrue(msg3 === msg.optionalMessage.optionalMessage)
- XCTAssertTrue(msg4 === msg.optionalMessage)
+ XCTAssertTrue(msg3 === msg.optional.optional)
+ XCTAssertTrue(msg4 === msg.optional)
// Clear gets us new objects next time around.
msg.clear()
XCTAssertFalse(msg.hasOptionalGroup)
- XCTAssertFalse(msg.optionalMessage.hasOptionalMessage)
+ XCTAssertFalse(msg.optional.hasOptionalMessage)
XCTAssertFalse(msg.hasOptionalMessage)
msg.optionalGroup.a = 20
- msg.optionalMessage.optionalMessage.optionalInt32 = 200
+ msg.optional.optional.optionalInt32 = 200
XCTAssertTrue(msg.hasOptionalGroup)
- XCTAssertTrue(msg.optionalMessage.hasOptionalMessage)
+ XCTAssertTrue(msg.optional.hasOptionalMessage)
XCTAssertTrue(msg.hasOptionalMessage)
XCTAssertTrue(msg2 !== msg.optionalGroup)
- XCTAssertTrue(msg3 !== msg.optionalMessage.optionalMessage)
- XCTAssertTrue(msg4 !== msg.optionalMessage)
+ 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.optionalMessage
+ let autoCreated = msg.optional
XCTAssertFalse(msg.hasOptionalMessage)
let msg5 = Message2()
msg5.optionalInt32 = 123
- msg.optionalMessage = 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.optionalMessage === msg5)
- XCTAssertEqual(msg.optionalMessage.optionalInt32, Int32(123))
+ XCTAssertTrue(msg.optional === msg5)
+ XCTAssertEqual(msg.optional.optionalInt32, Int32(123))
}
func testProto2OneOfSupport() {
let msg = Message2()
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.GPBUnsetOneOfCase)
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.gpbUnsetOneOfCase)
XCTAssertEqual(msg.oneofInt32, Int32(100)) // Default
XCTAssertEqual(msg.oneofFloat, Float(110.0)) // Default
- XCTAssertEqual(msg.oneofEnum, Message2_Enum.Baz) // Default
- let autoCreated = msg.oneofMessage // Default create one.
+ XCTAssertEqual(msg.oneofEnum, Message2_Enum.baz) // Default
+ let autoCreated = msg.oneof // Default create one.
XCTAssertNotNil(autoCreated)
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.GPBUnsetOneOfCase)
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.gpbUnsetOneOfCase)
msg.oneofInt32 = 10
XCTAssertEqual(msg.oneofInt32, Int32(10))
XCTAssertEqual(msg.oneofFloat, Float(110.0)) // Default
- XCTAssertEqual(msg.oneofEnum, Message2_Enum.Baz) // Default
- XCTAssertTrue(msg.oneofMessage === autoCreated) // Still the same
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.OneofInt32)
+ XCTAssertEqual(msg.oneofEnum, Message2_Enum.baz) // Default
+ XCTAssertTrue(msg.oneof === autoCreated) // Still the same
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.oneofInt32)
msg.oneofFloat = 20.0
XCTAssertEqual(msg.oneofInt32, Int32(100)) // Default
XCTAssertEqual(msg.oneofFloat, Float(20.0))
- XCTAssertEqual(msg.oneofEnum, Message2_Enum.Baz) // Default
- XCTAssertTrue(msg.oneofMessage === autoCreated) // Still the same
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.OneofFloat)
+ XCTAssertEqual(msg.oneofEnum, Message2_Enum.baz) // Default
+ XCTAssertTrue(msg.oneof === autoCreated) // Still the same
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.oneofFloat)
- msg.oneofEnum = .Bar
+ msg.oneofEnum = .bar
XCTAssertEqual(msg.oneofInt32, Int32(100)) // Default
XCTAssertEqual(msg.oneofFloat, Float(110.0)) // Default
- XCTAssertEqual(msg.oneofEnum, Message2_Enum.Bar)
- XCTAssertTrue(msg.oneofMessage === autoCreated) // Still the same
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.OneofEnum)
+ XCTAssertEqual(msg.oneofEnum, Message2_Enum.bar)
+ XCTAssertTrue(msg.oneof === autoCreated) // Still the same
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.oneofEnum)
// Sets via the autocreated instance.
- msg.oneofMessage.optionalInt32 = 200
+ msg.oneof.optionalInt32 = 200
XCTAssertEqual(msg.oneofInt32, Int32(100)) // Default
XCTAssertEqual(msg.oneofFloat, Float(110.0)) // Default
- XCTAssertEqual(msg.oneofEnum, Message2_Enum.Baz) // Default
- XCTAssertTrue(msg.oneofMessage === autoCreated) // Still the same
- XCTAssertEqual(msg.oneofMessage.optionalInt32, Int32(200))
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.OneofMessage)
+ XCTAssertEqual(msg.oneofEnum, Message2_Enum.baz) // Default
+ XCTAssertTrue(msg.oneof === autoCreated) // Still the same
+ XCTAssertEqual(msg.oneof.optionalInt32, Int32(200))
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.oneofMessage)
// Clear the oneof.
Message2_ClearOOneOfCase(msg)
XCTAssertEqual(msg.oneofInt32, Int32(100)) // Default
XCTAssertEqual(msg.oneofFloat, Float(110.0)) // Default
- XCTAssertEqual(msg.oneofEnum, Message2_Enum.Baz) // Default
- let autoCreated2 = msg.oneofMessage // Default create one
+ XCTAssertEqual(msg.oneofEnum, Message2_Enum.baz) // Default
+ let autoCreated2 = msg.oneof // Default create one
XCTAssertNotNil(autoCreated2)
XCTAssertTrue(autoCreated2 !== autoCreated) // New instance
- XCTAssertEqual(msg.oneofMessage.optionalInt32, Int32(0)) // Default
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.GPBUnsetOneOfCase)
+ XCTAssertEqual(msg.oneof.optionalInt32, Int32(0)) // Default
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.gpbUnsetOneOfCase)
msg.oneofInt32 = 10
XCTAssertEqual(msg.oneofInt32, Int32(10))
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.OneofInt32)
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.oneofInt32)
// Confirm Message.clear() handles the oneof correctly.
msg.clear()
XCTAssertEqual(msg.oneofInt32, Int32(100)) // Default
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.GPBUnsetOneOfCase)
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.gpbUnsetOneOfCase)
// Sets via the autocreated instance.
- msg.oneofMessage.optionalInt32 = 300
- XCTAssertTrue(msg.oneofMessage !== autoCreated) // New instance
- XCTAssertTrue(msg.oneofMessage !== autoCreated2) // New instance
- XCTAssertEqual(msg.oneofMessage.optionalInt32, Int32(300))
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.OneofMessage)
+ 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.oneofMessage)
// Set message to nil clears the oneof.
- msg.oneofMessage = nil
- XCTAssertEqual(msg.oneofMessage.optionalInt32, Int32(0)) // Default
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.GPBUnsetOneOfCase)
+ msg.oneof = nil
+ XCTAssertEqual(msg.oneof.optionalInt32, Int32(0)) // Default
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.gpbUnsetOneOfCase)
}
func testProto3OneOfSupport() {
let msg = Message3()
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.GPBUnsetOneOfCase)
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.gpbUnsetOneOfCase)
XCTAssertEqual(msg.oneofInt32, Int32(0)) // Default
XCTAssertEqual(msg.oneofFloat, Float(0.0)) // Default
- XCTAssertEqual(msg.oneofEnum, Message3_Enum.Foo) // Default
- let autoCreated = msg.oneofMessage // Default create one.
+ XCTAssertEqual(msg.oneofEnum, Message3_Enum.foo) // Default
+ let autoCreated = msg.oneof // Default create one.
XCTAssertNotNil(autoCreated)
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.GPBUnsetOneOfCase)
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.gpbUnsetOneOfCase)
msg.oneofInt32 = 10
XCTAssertEqual(msg.oneofInt32, Int32(10))
XCTAssertEqual(msg.oneofFloat, Float(0.0)) // Default
- XCTAssertEqual(msg.oneofEnum, Message3_Enum.Foo) // Default
- XCTAssertTrue(msg.oneofMessage === autoCreated) // Still the same
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.OneofInt32)
+ XCTAssertEqual(msg.oneofEnum, Message3_Enum.foo) // Default
+ XCTAssertTrue(msg.oneof === autoCreated) // Still the same
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.oneofInt32)
msg.oneofFloat = 20.0
XCTAssertEqual(msg.oneofInt32, Int32(0)) // Default
XCTAssertEqual(msg.oneofFloat, Float(20.0))
- XCTAssertEqual(msg.oneofEnum, Message3_Enum.Foo) // Default
- XCTAssertTrue(msg.oneofMessage === autoCreated) // Still the same
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.OneofFloat)
+ XCTAssertEqual(msg.oneofEnum, Message3_Enum.foo) // Default
+ XCTAssertTrue(msg.oneof === autoCreated) // Still the same
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.oneofFloat)
- msg.oneofEnum = .Bar
+ msg.oneofEnum = .bar
XCTAssertEqual(msg.oneofInt32, Int32(0)) // Default
XCTAssertEqual(msg.oneofFloat, Float(0.0)) // Default
- XCTAssertEqual(msg.oneofEnum, Message3_Enum.Bar)
- XCTAssertTrue(msg.oneofMessage === autoCreated) // Still the same
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.OneofEnum)
+ XCTAssertEqual(msg.oneofEnum, Message3_Enum.bar)
+ XCTAssertTrue(msg.oneof === autoCreated) // Still the same
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.oneofEnum)
// Sets via the autocreated instance.
- msg.oneofMessage.optionalInt32 = 200
+ msg.oneof.optionalInt32 = 200
XCTAssertEqual(msg.oneofInt32, Int32(0)) // Default
XCTAssertEqual(msg.oneofFloat, Float(0.0)) // Default
- XCTAssertEqual(msg.oneofEnum, Message3_Enum.Foo) // Default
- XCTAssertTrue(msg.oneofMessage === autoCreated) // Still the same
- XCTAssertEqual(msg.oneofMessage.optionalInt32, Int32(200))
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.OneofMessage)
+ XCTAssertEqual(msg.oneofEnum, Message3_Enum.foo) // Default
+ XCTAssertTrue(msg.oneof === autoCreated) // Still the same
+ XCTAssertEqual(msg.oneof.optionalInt32, Int32(200))
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.oneofMessage)
// Clear the oneof.
Message3_ClearOOneOfCase(msg)
XCTAssertEqual(msg.oneofInt32, Int32(0)) // Default
XCTAssertEqual(msg.oneofFloat, Float(0.0)) // Default
- XCTAssertEqual(msg.oneofEnum, Message3_Enum.Foo) // Default
- let autoCreated2 = msg.oneofMessage // Default create one
+ XCTAssertEqual(msg.oneofEnum, Message3_Enum.foo) // Default
+ let autoCreated2 = msg.oneof // Default create one
XCTAssertNotNil(autoCreated2)
XCTAssertTrue(autoCreated2 !== autoCreated) // New instance
- XCTAssertEqual(msg.oneofMessage.optionalInt32, Int32(0)) // Default
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.GPBUnsetOneOfCase)
+ XCTAssertEqual(msg.oneof.optionalInt32, Int32(0)) // Default
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.gpbUnsetOneOfCase)
msg.oneofInt32 = 10
XCTAssertEqual(msg.oneofInt32, Int32(10))
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.OneofInt32)
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.oneofInt32)
// Confirm Message.clear() handles the oneof correctly.
msg.clear()
XCTAssertEqual(msg.oneofInt32, Int32(0)) // Default
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.GPBUnsetOneOfCase)
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.gpbUnsetOneOfCase)
// Sets via the autocreated instance.
- msg.oneofMessage.optionalInt32 = 300
- XCTAssertTrue(msg.oneofMessage !== autoCreated) // New instance
- XCTAssertTrue(msg.oneofMessage !== autoCreated2) // New instance
- XCTAssertEqual(msg.oneofMessage.optionalInt32, Int32(300))
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.OneofMessage)
+ 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.oneofMessage)
// Set message to nil clears the oneof.
- msg.oneofMessage = nil
- XCTAssertEqual(msg.oneofMessage.optionalInt32, Int32(0)) // Default
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.GPBUnsetOneOfCase)
+ msg.oneof = nil
+ XCTAssertEqual(msg.oneof.optionalInt32, Int32(0)) // Default
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.gpbUnsetOneOfCase)
}
func testSerialization() {
@@ -437,16 +437,16 @@ class GPBBridgeTests: XCTestCase {
msg.optionalInt32 = 100
msg.optionalInt64 = 101
msg.optionalGroup.a = 102
- msg.repeatedStringArray.addObject("abc")
- msg.repeatedStringArray.addObject("def")
- msg.mapInt32Int32.setValue(200, forKey:300)
- msg.mapInt32Int32.setValue(201, forKey:201)
- msg.mapStringString.setObject("foo", forKey:"bar")
- msg.mapStringString.setObject("abc", forKey:"xyz")
+ 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" as NSString)
+ msg.mapStringString.setObject("abc", forKey:"xyz" as NSString)
let data = msg.data()
- let msg2 = Message2(data: data!, error:nil)
+ let msg2 = try! Message2(data: data!)
XCTAssertTrue(msg2 !== msg) // New instance
XCTAssertEqual(msg.optionalInt32, Int32(100))
XCTAssertEqual(msg.optionalInt64, Int64(101))
diff --git a/objectivec/Tests/GPBTestUtilities.h b/objectivec/Tests/GPBTestUtilities.h
index 44c80844..780184b0 100644
--- a/objectivec/Tests/GPBTestUtilities.h
+++ b/objectivec/Tests/GPBTestUtilities.h
@@ -39,6 +39,9 @@
@class TestUnpackedExtensions;
@class GPBExtensionRegistry;
+static inline NSData *DataFromCStr(const char *str) {
+ return [NSData dataWithBytes:str length:strlen(str)];
+}
// Helper for uses of C arrays in tests cases.
#ifndef GPBARRAYSIZE
diff --git a/objectivec/Tests/GPBTestUtilities.m b/objectivec/Tests/GPBTestUtilities.m
index 726761a7..ebccaac9 100644
--- a/objectivec/Tests/GPBTestUtilities.m
+++ b/objectivec/Tests/GPBTestUtilities.m
@@ -1089,19 +1089,19 @@ const uint32_t kGPBDefaultRepeatCount = 2;
- (void)setAllMapFields:(TestMap *)message numEntries:(uint32_t)count {
for (uint32_t i = 0; i < count; i++) {
- [message.mapInt32Int32 setValue:(i + 1) forKey:100 + i * 100];
- [message.mapInt64Int64 setValue:(i + 1) forKey:101 + i * 100];
- [message.mapUint32Uint32 setValue:(i + 1) forKey:102 + i * 100];
- [message.mapUint64Uint64 setValue:(i + 1) forKey:103 + i * 100];
- [message.mapSint32Sint32 setValue:(i + 1) forKey:104 + i * 100];
- [message.mapSint64Sint64 setValue:(i + 1) forKey:105 + i * 100];
- [message.mapFixed32Fixed32 setValue:(i + 1) forKey:106 + i * 100];
- [message.mapFixed64Fixed64 setValue:(i + 1) forKey:107 + i * 100];
- [message.mapSfixed32Sfixed32 setValue:(i + 1) forKey:108 + i * 100];
- [message.mapSfixed64Sfixed64 setValue:(i + 1) forKey:109 + i * 100];
- [message.mapInt32Float setValue:(i + 1) forKey:110 + i * 100];
- [message.mapInt32Double setValue:(i + 1) forKey:111 + i * 100];
- [message.mapBoolBool setValue:((i % 2) == 1) forKey:((i % 2) == 0)];
+ [message.mapInt32Int32 setInt32:(i + 1) forKey:100 + i * 100];
+ [message.mapInt64Int64 setInt64:(i + 1) forKey:101 + i * 100];
+ [message.mapUint32Uint32 setUInt32:(i + 1) forKey:102 + i * 100];
+ [message.mapUint64Uint64 setUInt64:(i + 1) forKey:103 + i * 100];
+ [message.mapSint32Sint32 setInt32:(i + 1) forKey:104 + i * 100];
+ [message.mapSint64Sint64 setInt64:(i + 1) forKey:105 + i * 100];
+ [message.mapFixed32Fixed32 setUInt32:(i + 1) forKey:106 + i * 100];
+ [message.mapFixed64Fixed64 setUInt64:(i + 1) forKey:107 + i * 100];
+ [message.mapSfixed32Sfixed32 setInt32:(i + 1) forKey:108 + i * 100];
+ [message.mapSfixed64Sfixed64 setInt64:(i + 1) forKey:109 + i * 100];
+ [message.mapInt32Float setFloat:(i + 1) forKey:110 + i * 100];
+ [message.mapInt32Double setDouble:(i + 1) forKey:111 + i * 100];
+ [message.mapBoolBool setBool:((i % 2) == 1) forKey:((i % 2) == 0)];
NSString *keyStr = [[NSString alloc] initWithFormat:@"%d", 112 + i * 100];
NSString *dataStr = [[NSString alloc] initWithFormat:@"%d", i + 1];
@@ -1114,8 +1114,8 @@ const uint32_t kGPBDefaultRepeatCount = 2;
[data release];
[message.mapInt32Enum
- setValue:(i % 2) ? MapEnum_MapEnumBar : MapEnum_MapEnumBaz
- forKey:114 + i * 100];
+ setEnum:(i % 2) ? MapEnum_MapEnumBar : MapEnum_MapEnumBaz
+ forKey:114 + i * 100];
ForeignMessage *subMsg = [[ForeignMessage alloc] init];
subMsg.c = i + 1;
diff --git a/objectivec/Tests/GPBUnittestProtos.m b/objectivec/Tests/GPBUnittestProtos.m
index 50c4dfa9..756bd99e 100644
--- a/objectivec/Tests/GPBUnittestProtos.m
+++ b/objectivec/Tests/GPBUnittestProtos.m
@@ -31,12 +31,20 @@
// Collects all the compiled protos into one file and compiles them to make sure
// the compiler is generating valid code.
+// The unittest_custom_options.proto extends the messages in descriptor.proto
+// so we build it in to test extending in general. The library doesn't provide
+// a descriptor as it doesn't use the classes/enums.
+#import "google/protobuf/Descriptor.pbobjc.m"
+
+#import "google/protobuf/AnyTest.pbobjc.m"
#import "google/protobuf/MapProto2Unittest.pbobjc.m"
#import "google/protobuf/MapUnittest.pbobjc.m"
#import "google/protobuf/Unittest.pbobjc.m"
#import "google/protobuf/UnittestArena.pbobjc.m"
#import "google/protobuf/UnittestCustomOptions.pbobjc.m"
#import "google/protobuf/UnittestCycle.pbobjc.m"
+#import "google/protobuf/UnittestDeprecated.pbobjc.m"
+#import "google/protobuf/UnittestDeprecatedFile.pbobjc.m"
#import "google/protobuf/UnittestDropUnknownFields.pbobjc.m"
#import "google/protobuf/UnittestEmbedOptimizeFor.pbobjc.m"
#import "google/protobuf/UnittestEmpty.pbobjc.m"
@@ -57,3 +65,11 @@
#import "google/protobuf/UnittestPreserveUnknownEnum.pbobjc.m"
#import "google/protobuf/UnittestRuntimeProto2.pbobjc.m"
#import "google/protobuf/UnittestRuntimeProto3.pbobjc.m"
+
+#import "google/protobuf/UnittestExtensionChainA.pbobjc.m"
+#import "google/protobuf/UnittestExtensionChainB.pbobjc.m"
+#import "google/protobuf/UnittestExtensionChainC.pbobjc.m"
+#import "google/protobuf/UnittestExtensionChainD.pbobjc.m"
+#import "google/protobuf/UnittestExtensionChainE.pbobjc.m"
+// See GPBUnittestProtos2.m for for "UnittestExtensionChainF.pbobjc.m"
+#import "google/protobuf/UnittestExtensionChainG.pbobjc.m"
diff --git a/objectivec/Tests/GPBUnittestProtos2.m b/objectivec/Tests/GPBUnittestProtos2.m
new file mode 100644
index 00000000..ef9f0702
--- /dev/null
+++ b/objectivec/Tests/GPBUnittestProtos2.m
@@ -0,0 +1,34 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// This one file in the chain tests is compiled by itself to ensure if was
+// generated with the extra #imports needed to pull in the indirect Root class
+// used in its Root registry.
+#import "google/protobuf/UnittestExtensionChainF.pbobjc.m"
diff --git a/objectivec/Tests/GPBUnknownFieldSetTest.m b/objectivec/Tests/GPBUnknownFieldSetTest.m
index 01217ca6..8e03a427 100644
--- a/objectivec/Tests/GPBUnknownFieldSetTest.m
+++ b/objectivec/Tests/GPBUnknownFieldSetTest.m
@@ -60,8 +60,93 @@
unknownFields_ = emptyMessage_.unknownFields;
}
-- (GPBUnknownField *)getField:(int32_t)number {
- return [unknownFields_ getField:number];
+- (void)testInvalidFieldNumber {
+ GPBUnknownFieldSet *set = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ GPBUnknownField* field = [[[GPBUnknownField alloc] initWithNumber:0] autorelease];
+ XCTAssertThrowsSpecificNamed([set addField:field], NSException, NSInvalidArgumentException);
+}
+
+- (void)testEqualityAndHash {
+ // Empty
+
+ GPBUnknownFieldSet *set1 = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ XCTAssertTrue([set1 isEqual:set1]);
+ XCTAssertFalse([set1 isEqual:@"foo"]);
+ GPBUnknownFieldSet *set2 = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ XCTAssertEqualObjects(set1, set2);
+ XCTAssertEqual([set1 hash], [set2 hash]);
+
+ // Varint
+
+ GPBUnknownField* field1 = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
+ [field1 addVarint:1];
+ [set1 addField:field1];
+ XCTAssertNotEqualObjects(set1, set2);
+ GPBUnknownField* field2 = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
+ [field2 addVarint:1];
+ [set2 addField:field2];
+ XCTAssertEqualObjects(set1, set2);
+ XCTAssertEqual([set1 hash], [set2 hash]);
+
+ // Fixed32
+
+ field1 = [[[GPBUnknownField alloc] initWithNumber:2] autorelease];
+ [field1 addFixed32:2];
+ [set1 addField:field1];
+ XCTAssertNotEqualObjects(set1, set2);
+ field2 = [[[GPBUnknownField alloc] initWithNumber:2] autorelease];
+ [field2 addFixed32:2];
+ [set2 addField:field2];
+ XCTAssertEqualObjects(set1, set2);
+ XCTAssertEqual([set1 hash], [set2 hash]);
+
+ // Fixed64
+
+ field1 = [[[GPBUnknownField alloc] initWithNumber:3] autorelease];
+ [field1 addFixed64:3];
+ [set1 addField:field1];
+ XCTAssertNotEqualObjects(set1, set2);
+ field2 = [[[GPBUnknownField alloc] initWithNumber:3] autorelease];
+ [field2 addFixed64:3];
+ [set2 addField:field2];
+ XCTAssertEqualObjects(set1, set2);
+ XCTAssertEqual([set1 hash], [set2 hash]);
+
+ // LengthDelimited
+
+ field1 = [[[GPBUnknownField alloc] initWithNumber:4] autorelease];
+ [field1 addLengthDelimited:DataFromCStr("foo")];
+ [set1 addField:field1];
+ XCTAssertNotEqualObjects(set1, set2);
+ field2 = [[[GPBUnknownField alloc] initWithNumber:4] autorelease];
+ [field2 addLengthDelimited:DataFromCStr("foo")];
+ [set2 addField:field2];
+ XCTAssertEqualObjects(set1, set2);
+ XCTAssertEqual([set1 hash], [set2 hash]);
+
+ // Group
+
+ GPBUnknownFieldSet *group1 = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ GPBUnknownField* fieldGroup1 = [[[GPBUnknownField alloc] initWithNumber:10] autorelease];
+ [fieldGroup1 addVarint:1];
+ [group1 addField:fieldGroup1];
+ GPBUnknownFieldSet *group2 = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ GPBUnknownField* fieldGroup2 = [[[GPBUnknownField alloc] initWithNumber:10] autorelease];
+ [fieldGroup2 addVarint:1];
+ [group2 addField:fieldGroup2];
+
+ field1 = [[[GPBUnknownField alloc] initWithNumber:5] autorelease];
+ [field1 addGroup:group1];
+ [set1 addField:field1];
+ XCTAssertNotEqualObjects(set1, set2);
+ field2 = [[[GPBUnknownField alloc] initWithNumber:5] autorelease];
+ [field2 addGroup:group2];
+ [set2 addField:field2];
+ XCTAssertEqualObjects(set1, set2);
+ XCTAssertEqual([set1 hash], [set2 hash]);
+
+ // Exercise description for completeness.
+ XCTAssertTrue(set1.description.length > 10);
}
// Constructs a protocol buffer which contains fields with all the same
@@ -116,6 +201,24 @@
field = [[[GPBUnknownField alloc] initWithNumber:3] autorelease];
[field addVarint:4];
[set1 addField:field];
+ field = [[[GPBUnknownField alloc] initWithNumber:4] autorelease];
+ [field addFixed32:6];
+ [set1 addField:field];
+ field = [[[GPBUnknownField alloc] initWithNumber:5] autorelease];
+ [field addFixed64:20];
+ [set1 addField:field];
+ field = [[[GPBUnknownField alloc] initWithNumber:10] autorelease];
+ [field addLengthDelimited:DataFromCStr("data1")];
+ [set1 addField:field];
+
+ GPBUnknownFieldSet *group1 = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ GPBUnknownField* fieldGroup1 = [[[GPBUnknownField alloc] initWithNumber:200] autorelease];
+ [fieldGroup1 addVarint:100];
+ [group1 addField:fieldGroup1];
+
+ field = [[[GPBUnknownField alloc] initWithNumber:11] autorelease];
+ [field addGroup:group1];
+ [set1 addField:field];
GPBUnknownFieldSet* set2 = [[[GPBUnknownFieldSet alloc] init] autorelease];
field = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
@@ -124,22 +227,63 @@
field = [[[GPBUnknownField alloc] initWithNumber:3] autorelease];
[field addVarint:3];
[set2 addField:field];
+ field = [[[GPBUnknownField alloc] initWithNumber:4] autorelease];
+ [field addFixed32:7];
+ [set2 addField:field];
+ field = [[[GPBUnknownField alloc] initWithNumber:5] autorelease];
+ [field addFixed64:30];
+ [set2 addField:field];
+ field = [[[GPBUnknownField alloc] initWithNumber:10] autorelease];
+ [field addLengthDelimited:DataFromCStr("data2")];
+ [set2 addField:field];
+
+ GPBUnknownFieldSet *group2 = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ GPBUnknownField* fieldGroup2 = [[[GPBUnknownField alloc] initWithNumber:201] autorelease];
+ [fieldGroup2 addVarint:99];
+ [group2 addField:fieldGroup2];
+
+ field = [[[GPBUnknownField alloc] initWithNumber:11] autorelease];
+ [field addGroup:group2];
+ [set2 addField:field];
GPBUnknownFieldSet* set3 = [[[GPBUnknownFieldSet alloc] init] autorelease];
field = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
[field addVarint:1];
[set3 addField:field];
- field = [[[GPBUnknownField alloc] initWithNumber:3] autorelease];
- [field addVarint:4];
- [set3 addField:field];
-
- GPBUnknownFieldSet* set4 = [[[GPBUnknownFieldSet alloc] init] autorelease];
field = [[[GPBUnknownField alloc] initWithNumber:2] autorelease];
[field addVarint:2];
- [set4 addField:field];
+ [set3 addField:field];
field = [[[GPBUnknownField alloc] initWithNumber:3] autorelease];
+ [field addVarint:4];
+ [set3 addField:field];
[field addVarint:3];
- [set4 addField:field];
+ [set3 addField:field];
+ field = [[[GPBUnknownField alloc] initWithNumber:4] autorelease];
+ [field addFixed32:6];
+ [field addFixed32:7];
+ [set3 addField:field];
+ field = [[[GPBUnknownField alloc] initWithNumber:5] autorelease];
+ [field addFixed64:20];
+ [field addFixed64:30];
+ [set3 addField:field];
+ field = [[[GPBUnknownField alloc] initWithNumber:10] autorelease];
+ [field addLengthDelimited:DataFromCStr("data1")];
+ [field addLengthDelimited:DataFromCStr("data2")];
+ [set3 addField:field];
+
+ GPBUnknownFieldSet *group3a = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ GPBUnknownField* fieldGroup3a1 = [[[GPBUnknownField alloc] initWithNumber:200] autorelease];
+ [fieldGroup3a1 addVarint:100];
+ [group3a addField:fieldGroup3a1];
+ GPBUnknownFieldSet *group3b = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ GPBUnknownField* fieldGroup3b2 = [[[GPBUnknownField alloc] initWithNumber:201] autorelease];
+ [fieldGroup3b2 addVarint:99];
+ [group3b addField:fieldGroup3b2];
+
+ field = [[[GPBUnknownField alloc] initWithNumber:11] autorelease];
+ [field addGroup:group1];
+ [field addGroup:group3b];
+ [set3 addField:field];
TestEmptyMessage* source1 = [TestEmptyMessage message];
[source1 setUnknownFields:set1];
@@ -147,8 +291,6 @@
[source2 setUnknownFields:set2];
TestEmptyMessage* source3 = [TestEmptyMessage message];
[source3 setUnknownFields:set3];
- TestEmptyMessage* source4 = [TestEmptyMessage message];
- [source4 setUnknownFields:set4];
TestEmptyMessage* destination1 = [TestEmptyMessage message];
[destination1 mergeFrom:source1];
@@ -156,9 +298,10 @@
TestEmptyMessage* destination2 = [TestEmptyMessage message];
[destination2 mergeFrom:source3];
- [destination2 mergeFrom:source4];
XCTAssertEqualObjects(destination1.data, destination2.data);
+ XCTAssertEqualObjects(destination1.data, source3.data);
+ XCTAssertEqualObjects(destination2.data, source3.data);
}
- (void)testClearMessage {
@@ -244,6 +387,107 @@
XCTAssertEqual(0x7FFFFFFFFFFFFFFFULL, [field2.varintList valueAtIndex:0]);
}
+#pragma mark - Field tests
+// Some tests directly on fields since the dictionary in FieldSet can gate
+// testing some of these.
+
+- (void)testFieldEqualityAndHash {
+ GPBUnknownField* field1 = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
+ XCTAssertTrue([field1 isEqual:field1]);
+ XCTAssertFalse([field1 isEqual:@"foo"]);
+ GPBUnknownField* field2 = [[[GPBUnknownField alloc] initWithNumber:2] autorelease];
+ XCTAssertNotEqualObjects(field1, field2);
+
+ field2 = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+
+ // Varint
+
+ [field1 addVarint:10];
+ XCTAssertNotEqualObjects(field1, field2);
+ [field2 addVarint:10];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+ [field1 addVarint:11];
+ XCTAssertNotEqualObjects(field1, field2);
+ [field2 addVarint:11];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+
+ // Fixed32
+
+ [field1 addFixed32:20];
+ XCTAssertNotEqualObjects(field1, field2);
+ [field2 addFixed32:20];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+ [field1 addFixed32:21];
+ XCTAssertNotEqualObjects(field1, field2);
+ [field2 addFixed32:21];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+
+ // Fixed64
+
+ [field1 addFixed64:30];
+ XCTAssertNotEqualObjects(field1, field2);
+ [field2 addFixed64:30];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+ [field1 addFixed64:31];
+ XCTAssertNotEqualObjects(field1, field2);
+ [field2 addFixed64:31];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+
+ // LengthDelimited
+
+ [field1 addLengthDelimited:DataFromCStr("foo")];
+ XCTAssertNotEqualObjects(field1, field2);
+ [field2 addLengthDelimited:DataFromCStr("foo")];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+ [field1 addLengthDelimited:DataFromCStr("bar")];
+ XCTAssertNotEqualObjects(field1, field2);
+ [field2 addLengthDelimited:DataFromCStr("bar")];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+
+ // Group
+
+ GPBUnknownFieldSet *group = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ GPBUnknownField* fieldGroup = [[[GPBUnknownField alloc] initWithNumber:100] autorelease];
+ [fieldGroup addVarint:100];
+ [group addField:fieldGroup];
+ [field1 addGroup:group];
+ XCTAssertNotEqualObjects(field1, field2);
+ group = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ fieldGroup = [[[GPBUnknownField alloc] initWithNumber:100] autorelease];
+ [fieldGroup addVarint:100];
+ [group addField:fieldGroup];
+ [field2 addGroup:group];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+
+ group = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ fieldGroup = [[[GPBUnknownField alloc] initWithNumber:101] autorelease];
+ [fieldGroup addVarint:101];
+ [group addField:fieldGroup];
+ [field1 addGroup:group];
+ XCTAssertNotEqualObjects(field1, field2);
+ group = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ fieldGroup = [[[GPBUnknownField alloc] initWithNumber:101] autorelease];
+ [fieldGroup addVarint:101];
+ [group addField:fieldGroup];
+ [field2 addGroup:group];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+
+ // Exercise description for completeness.
+ XCTAssertTrue(field1.description.length > 10);
+}
+
- (void)testMergingFields {
GPBUnknownField* field1 = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
[field1 addVarint:1];
@@ -251,9 +495,8 @@
[field1 addFixed64:3];
[field1 addLengthDelimited:[NSData dataWithBytes:"hello" length:5]];
[field1 addGroup:[[unknownFields_ copy] autorelease]];
- GPBUnknownField* field2 = [[[GPBUnknownField alloc] initWithNumber:2] autorelease];
+ GPBUnknownField* field2 = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
[field2 mergeFromField:field1];
- XCTAssertEqualObjects(field1, field2);
}
@end
diff --git a/objectivec/Tests/GPBUtilitiesTests.m b/objectivec/Tests/GPBUtilitiesTests.m
index ba1fc270..8a8ba93e 100644
--- a/objectivec/Tests/GPBUtilitiesTests.m
+++ b/objectivec/Tests/GPBUtilitiesTests.m
@@ -39,6 +39,7 @@
#import "GPBDescriptor.h"
#import "GPBDescriptor_PackagePrivate.h"
#import "GPBMessage.h"
+#import "GPBUnknownField_PackagePrivate.h"
#import "google/protobuf/MapUnittest.pbobjc.h"
#import "google/protobuf/Unittest.pbobjc.h"
@@ -51,12 +52,12 @@
- (void)testRightShiftFunctions {
XCTAssertEqual((1UL << 31) >> 31, 1UL);
- XCTAssertEqual((1 << 31) >> 31, -1);
+ XCTAssertEqual((int32_t)(1U << 31) >> 31, -1);
XCTAssertEqual((1ULL << 63) >> 63, 1ULL);
- XCTAssertEqual((1LL << 63) >> 63, -1LL);
+ XCTAssertEqual((int64_t)(1ULL << 63) >> 63, -1LL);
- XCTAssertEqual(GPBLogicalRightShift32((1 << 31), 31), 1);
- XCTAssertEqual(GPBLogicalRightShift64((1LL << 63), 63), 1LL);
+ XCTAssertEqual(GPBLogicalRightShift32((1U << 31), 31), 1);
+ XCTAssertEqual(GPBLogicalRightShift64((1ULL << 63), 63), 1LL);
}
- (void)testGPBDecodeTextFormatName {
@@ -170,4 +171,230 @@
// 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]);
+ }
+}
+
+// Helper to make an unknown field set with something in it.
+static GPBUnknownFieldSet *UnknownFieldsSetHelper(int num) {
+ GPBUnknownFieldSet *result =
+ [[[GPBUnknownFieldSet alloc] init] autorelease];
+
+ GPBUnknownField *field =
+ [[[GPBUnknownField alloc] initWithNumber:num] autorelease];
+ [field addVarint:num];
+ [result addField:field];
+
+ return result;
+}
+
+- (void)testDropMessageUnknownFieldsRecursively {
+ TestAllExtensions *message = [TestAllExtensions message];
+
+ // Give it unknownFields.
+ message.unknownFields = UnknownFieldsSetHelper(777);
+
+ // Given it extensions that include a message with unknown fields of its own.
+ {
+ // Int
+ [message setExtension:[UnittestRoot optionalInt32Extension] value:@5];
+
+ // Group
+ OptionalGroup_extension *optionalGroup = [OptionalGroup_extension message];
+ optionalGroup.a = 123;
+ optionalGroup.unknownFields = UnknownFieldsSetHelper(779);
+ [message setExtension:[UnittestRoot optionalGroupExtension]
+ value:optionalGroup];
+
+ // Message
+ TestAllTypes_NestedMessage *nestedMessage =
+ [TestAllTypes_NestedMessage message];
+ nestedMessage.bb = 456;
+ nestedMessage.unknownFields = UnknownFieldsSetHelper(778);
+ [message setExtension:[UnittestRoot optionalNestedMessageExtension]
+ value:nestedMessage];
+
+ // Repeated Group
+ RepeatedGroup_extension *repeatedGroup =
+ [[RepeatedGroup_extension alloc] init];
+ repeatedGroup.a = 567;
+ repeatedGroup.unknownFields = UnknownFieldsSetHelper(780);
+ [message addExtension:[UnittestRoot repeatedGroupExtension]
+ value:repeatedGroup];
+ [repeatedGroup release];
+
+ // Repeated Message
+ nestedMessage = [[TestAllTypes_NestedMessage alloc] init];
+ nestedMessage.bb = 678;
+ nestedMessage.unknownFields = UnknownFieldsSetHelper(781);
+ [message addExtension:[UnittestRoot repeatedNestedMessageExtension]
+ value:nestedMessage];
+ [nestedMessage release];
+ }
+
+ // Confirm everything is there.
+
+ XCTAssertNotNil(message);
+ XCTAssertNotNil(message.unknownFields);
+ XCTAssertTrue([message hasExtension:[UnittestRoot optionalInt32Extension]]);
+
+ {
+ XCTAssertTrue([message hasExtension:[UnittestRoot optionalGroupExtension]]);
+ OptionalGroup_extension *optionalGroup =
+ [message getExtension:[UnittestRoot optionalGroupExtension]];
+ XCTAssertNotNil(optionalGroup);
+ XCTAssertEqual(optionalGroup.a, 123);
+ XCTAssertNotNil(optionalGroup.unknownFields);
+ }
+
+ {
+ XCTAssertTrue([message hasExtension:[UnittestRoot optionalNestedMessageExtension]]);
+ TestAllTypes_NestedMessage *nestedMessage =
+ [message getExtension:[UnittestRoot optionalNestedMessageExtension]];
+ XCTAssertNotNil(nestedMessage);
+ XCTAssertEqual(nestedMessage.bb, 456);
+ XCTAssertNotNil(nestedMessage.unknownFields);
+ }
+
+ {
+ XCTAssertTrue([message hasExtension:[UnittestRoot repeatedGroupExtension]]);
+ NSArray *repeatedGroups = [message getExtension:[UnittestRoot repeatedGroupExtension]];
+ XCTAssertEqual(repeatedGroups.count, (NSUInteger)1);
+ RepeatedGroup_extension *repeatedGroup = repeatedGroups.firstObject;
+ XCTAssertNotNil(repeatedGroup);
+ XCTAssertEqual(repeatedGroup.a, 567);
+ XCTAssertNotNil(repeatedGroup.unknownFields);
+ }
+
+ {
+ XCTAssertTrue([message hasExtension:[UnittestRoot repeatedNestedMessageExtension]]);
+ NSArray *repeatedNestedMessages = [message getExtension:[UnittestRoot repeatedNestedMessageExtension]];
+ XCTAssertEqual(repeatedNestedMessages.count, (NSUInteger)1);
+ TestAllTypes_NestedMessage *repeatedNestedMessage = repeatedNestedMessages.firstObject;
+ XCTAssertNotNil(repeatedNestedMessage);
+ XCTAssertEqual(repeatedNestedMessage.bb, 678);
+ XCTAssertNotNil(repeatedNestedMessage.unknownFields);
+ }
+
+ // Drop them.
+ GPBMessageDropUnknownFieldsRecursively(message);
+
+ // Confirm unknowns are gone from within the messages.
+
+ XCTAssertNotNil(message);
+ XCTAssertNil(message.unknownFields);
+ XCTAssertTrue([message hasExtension:[UnittestRoot optionalInt32Extension]]);
+
+ {
+ XCTAssertTrue([message hasExtension:[UnittestRoot optionalGroupExtension]]);
+ OptionalGroup_extension *optionalGroup =
+ [message getExtension:[UnittestRoot optionalGroupExtension]];
+ XCTAssertNotNil(optionalGroup);
+ XCTAssertEqual(optionalGroup.a, 123);
+ XCTAssertNil(optionalGroup.unknownFields);
+ }
+
+ {
+ XCTAssertTrue([message hasExtension:[UnittestRoot optionalNestedMessageExtension]]);
+ TestAllTypes_NestedMessage *nestedMessage =
+ [message getExtension:[UnittestRoot optionalNestedMessageExtension]];
+ XCTAssertNotNil(nestedMessage);
+ XCTAssertEqual(nestedMessage.bb, 456);
+ XCTAssertNil(nestedMessage.unknownFields);
+ }
+
+ {
+ XCTAssertTrue([message hasExtension:[UnittestRoot repeatedGroupExtension]]);
+ NSArray *repeatedGroups = [message getExtension:[UnittestRoot repeatedGroupExtension]];
+ XCTAssertEqual(repeatedGroups.count, (NSUInteger)1);
+ RepeatedGroup_extension *repeatedGroup = repeatedGroups.firstObject;
+ XCTAssertNotNil(repeatedGroup);
+ XCTAssertEqual(repeatedGroup.a, 567);
+ XCTAssertNil(repeatedGroup.unknownFields);
+ }
+
+ {
+ XCTAssertTrue([message hasExtension:[UnittestRoot repeatedNestedMessageExtension]]);
+ NSArray *repeatedNestedMessages = [message getExtension:[UnittestRoot repeatedNestedMessageExtension]];
+ XCTAssertEqual(repeatedNestedMessages.count, (NSUInteger)1);
+ TestAllTypes_NestedMessage *repeatedNestedMessage = repeatedNestedMessages.firstObject;
+ XCTAssertNotNil(repeatedNestedMessage);
+ XCTAssertEqual(repeatedNestedMessage.bb, 678);
+ XCTAssertNil(repeatedNestedMessage.unknownFields);
+ }
+
+}
+
+- (void)testDropMessageUnknownFieldsRecursively_Maps {
+ TestMap *message = [TestMap message];
+
+ {
+ ForeignMessage *foreignMessage = [ForeignMessage message];
+ foreignMessage.unknownFields = UnknownFieldsSetHelper(100);
+ [message.mapInt32ForeignMessage setObject:foreignMessage forKey:100];
+
+ foreignMessage = [ForeignMessage message];
+ foreignMessage.unknownFields = UnknownFieldsSetHelper(101);
+ [message.mapStringForeignMessage setObject:foreignMessage forKey:@"101"];
+ }
+
+ // Confirm everything is there.
+
+ XCTAssertNotNil(message);
+
+ {
+ ForeignMessage *foreignMessage = [message.mapInt32ForeignMessage objectForKey:100];
+ XCTAssertNotNil(foreignMessage);
+ XCTAssertNotNil(foreignMessage.unknownFields);
+ }
+
+ {
+ ForeignMessage *foreignMessage = [message.mapStringForeignMessage objectForKey:@"101"];
+ XCTAssertNotNil(foreignMessage);
+ XCTAssertNotNil(foreignMessage.unknownFields);
+ }
+
+ GPBMessageDropUnknownFieldsRecursively(message);
+
+ // Confirm unknowns are gone from within the messages.
+
+ XCTAssertNotNil(message);
+
+ {
+ ForeignMessage *foreignMessage = [message.mapInt32ForeignMessage objectForKey:100];
+ XCTAssertNotNil(foreignMessage);
+ XCTAssertNil(foreignMessage.unknownFields);
+ }
+
+ {
+ ForeignMessage *foreignMessage = [message.mapStringForeignMessage objectForKey:@"101"];
+ XCTAssertNotNil(foreignMessage);
+ XCTAssertNil(foreignMessage.unknownFields);
+ }
+
+}
+
@end
diff --git a/objectivec/Tests/GPBWellKnownTypesTest.m b/objectivec/Tests/GPBWellKnownTypesTest.m
index 78f4e637..592d5afd 100644
--- a/objectivec/Tests/GPBWellKnownTypesTest.m
+++ b/objectivec/Tests/GPBWellKnownTypesTest.m
@@ -32,8 +32,8 @@
#import <XCTest/XCTest.h>
-// A basically random interval into the future for testing with.
-static const NSTimeInterval kFutureOffsetInterval = 15000;
+#import "GPBTestUtilities.h"
+#import "google/protobuf/AnyTest.pbobjc.h"
// Nanosecond time accuracy
static const NSTimeInterval kTimeAccuracy = 1e-9;
@@ -44,59 +44,171 @@ static const NSTimeInterval kTimeAccuracy = 1e-9;
@implementation WellKnownTypesTest
- (void)testTimeStamp {
- // Test Creation.
- NSDate *date = [NSDate date];
- GPBTimestamp *timeStamp = [[GPBTimestamp alloc] initWithDate:date];
- NSDate *timeStampDate = timeStamp.date;
-
- // Comparing timeIntervals instead of directly comparing dates because date
- // equality requires the time intervals to be exactly the same, and the
- // timeintervals go through a bit of floating point error as they are
- // converted back and forth from the internal representation.
- XCTAssertEqualWithAccuracy(date.timeIntervalSince1970,
- timeStampDate.timeIntervalSince1970,
- kTimeAccuracy);
-
- NSTimeInterval time = [date timeIntervalSince1970];
- GPBTimestamp *timeStamp2 =
- [[GPBTimestamp alloc] initWithTimeIntervalSince1970:time];
- NSTimeInterval durationTime = timeStamp2.timeIntervalSince1970;
- XCTAssertEqualWithAccuracy(time, durationTime, kTimeAccuracy);
- [timeStamp release];
-
- // Test Mutation.
- date = [NSDate dateWithTimeIntervalSinceNow:kFutureOffsetInterval];
- timeStamp2.date = date;
- timeStampDate = timeStamp2.date;
- XCTAssertEqualWithAccuracy(date.timeIntervalSince1970,
- timeStampDate.timeIntervalSince1970,
- kTimeAccuracy);
-
- time = date.timeIntervalSince1970;
- timeStamp2.timeIntervalSince1970 = time;
- durationTime = timeStamp2.timeIntervalSince1970;
- XCTAssertEqualWithAccuracy(time, durationTime, kTimeAccuracy);
- [timeStamp2 release];
+ // Test negative and positive values.
+ NSTimeInterval values[] = {
+ -428027599.483999967, -1234567.0, -0.5, 0, 0.75, 54321.0, 2468086,483999967
+ };
+ for (size_t i = 0; i < GPBARRAYSIZE(values); ++i) {
+ NSTimeInterval value = values[i];
+
+ // Test Creation - date.
+ NSDate *date = [NSDate dateWithTimeIntervalSince1970:value];
+ GPBTimestamp *timeStamp = [[GPBTimestamp alloc] initWithDate:date];
+
+ XCTAssertGreaterThanOrEqual(timeStamp.nanos, 0,
+ @"Offset %f - Date: %@", (double)value, date);
+ XCTAssertLessThan(timeStamp.nanos, 1e9,
+ @"Offset %f - Date: %@", (double)value, date);
+
+ // Comparing timeIntervals instead of directly comparing dates because date
+ // equality requires the time intervals to be exactly the same, and the
+ // timeintervals go through a bit of floating point error as they are
+ // converted back and forth from the internal representation.
+ XCTAssertEqualWithAccuracy(value, timeStamp.date.timeIntervalSince1970,
+ kTimeAccuracy,
+ @"Offset %f - Date: %@", (double)value, date);
+ [timeStamp release];
+
+ // Test Creation - timeIntervalSince1970.
+ timeStamp = [[GPBTimestamp alloc] initWithTimeIntervalSince1970:value];
+
+ XCTAssertGreaterThanOrEqual(timeStamp.nanos, 0,
+ @"Offset %f - Date: %@", (double)value, date);
+ XCTAssertLessThan(timeStamp.nanos, 1e9,
+ @"Offset %f - Date: %@", (double)value, date);
+
+ XCTAssertEqualWithAccuracy(value, timeStamp.timeIntervalSince1970,
+ kTimeAccuracy,
+ @"Offset %f - Date: %@", (double)value, date);
+ [timeStamp release];
+
+ // Test Mutation - date.
+ timeStamp = [[GPBTimestamp alloc] init];
+ timeStamp.date = date;
+
+ XCTAssertGreaterThanOrEqual(timeStamp.nanos, 0,
+ @"Offset %f - Date: %@", (double)value, date);
+ XCTAssertLessThan(timeStamp.nanos, 1e9,
+ @"Offset %f - Date: %@", (double)value, date);
+
+ XCTAssertEqualWithAccuracy(value, timeStamp.date.timeIntervalSince1970,
+ kTimeAccuracy,
+ @"Offset %f - Date: %@", (double)value, date);
+ [timeStamp release];
+
+ // Test Mutation - timeIntervalSince1970.
+ timeStamp = [[GPBTimestamp alloc] init];
+ timeStamp.timeIntervalSince1970 = value;
+
+ XCTAssertGreaterThanOrEqual(timeStamp.nanos, 0,
+ @"Offset %f - Date: %@", (double)value, date);
+ XCTAssertLessThan(timeStamp.nanos, 1e9,
+ @"Offset %f - Date: %@", (double)value, date);
+
+ XCTAssertEqualWithAccuracy(value, timeStamp.date.timeIntervalSince1970,
+ kTimeAccuracy,
+ @"Offset %f - Date: %@", (double)value, date);
+
+ [timeStamp release];
+ }
}
- (void)testDuration {
- // Test Creation.
- NSTimeInterval time = [[NSDate date] timeIntervalSince1970];
- GPBDuration *duration =
- [[GPBDuration alloc] initWithTimeIntervalSince1970:time];
- NSTimeInterval durationTime = duration.timeIntervalSince1970;
- XCTAssertEqualWithAccuracy(time, durationTime, kTimeAccuracy);
- [duration release];
-
- // Test Mutation.
- GPBDuration *duration2 =
- [[GPBDuration alloc] initWithTimeIntervalSince1970:time];
- NSDate *date = [NSDate dateWithTimeIntervalSinceNow:kFutureOffsetInterval];
- time = date.timeIntervalSince1970;
- duration2.timeIntervalSince1970 = time;
- durationTime = duration2.timeIntervalSince1970;
- XCTAssertEqualWithAccuracy(time, durationTime, kTimeAccuracy);
- [duration2 release];
+ // Test negative and positive values.
+ NSTimeInterval values[] = { -1000.0001, -500.0, -0.5, 0, 0.75, 1000.0, 2000.0002 };
+ for (size_t i = 0; i < GPBARRAYSIZE(values); ++i) {
+ NSTimeInterval value = values[i];
+
+ // Test Creation.
+ GPBDuration *duration =
+ [[GPBDuration alloc] initWithTimeInterval:value];
+ XCTAssertEqualWithAccuracy(value, duration.timeInterval, kTimeAccuracy,
+ @"For interval %f", (double)value);
+ if (value > 0) {
+ XCTAssertGreaterThanOrEqual(duration.seconds, 0,
+ @"For interval %f", (double)value);
+ XCTAssertGreaterThanOrEqual(duration.nanos, 0,
+ @"For interval %f", (double)value);
+ } else {
+ XCTAssertLessThanOrEqual(duration.seconds, 0,
+ @"For interval %f", (double)value);
+ XCTAssertLessThanOrEqual(duration.nanos, 0,
+ @"For interval %f", (double)value);
+ }
+ [duration release];
+
+ // Test Mutation.
+ duration = [[GPBDuration alloc] init];
+ duration.timeInterval = value;
+ XCTAssertEqualWithAccuracy(value, duration.timeInterval, kTimeAccuracy,
+ @"For interval %f", (double)value);
+ if (value > 0) {
+ XCTAssertGreaterThanOrEqual(duration.seconds, 0,
+ @"For interval %f", (double)value);
+ XCTAssertGreaterThanOrEqual(duration.nanos, 0,
+ @"For interval %f", (double)value);
+ } else {
+ XCTAssertLessThanOrEqual(duration.seconds, 0,
+ @"For interval %f", (double)value);
+ XCTAssertLessThanOrEqual(duration.nanos, 0,
+ @"For interval %f", (double)value);
+ }
+ [duration release];
+ }
+}
+
+- (void)testAnyHelpers {
+
+ // Set and extract covers most of the code.
+
+ TestAny *subMessage = [TestAny message];
+ subMessage.int32Value = 12345;
+ TestAny *message = [TestAny message];
+ NSError *err = nil;
+ message.anyValue = [GPBAny anyWithMessage:subMessage error:&err];
+ XCTAssertNil(err);
+
+ NSData *data = message.data;
+ XCTAssertNotNil(data);
+
+ TestAny *message2 = [TestAny parseFromData:data error:&err];
+ XCTAssertNil(err);
+ XCTAssertNotNil(message2);
+ XCTAssertTrue(message2.hasAnyValue);
+
+ TestAny *subMessage2 =
+ (TestAny *)[message.anyValue unpackMessageClass:[TestAny class]
+ error:&err];
+ XCTAssertNil(err);
+ XCTAssertNotNil(subMessage2);
+ XCTAssertEqual(subMessage2.int32Value, 12345);
+
+ // NULL errorPtr in the two calls.
+
+ message.anyValue = [GPBAny anyWithMessage:subMessage error:NULL];
+ NSData *data2 = message.data;
+ XCTAssertEqualObjects(data2, data);
+
+ TestAny *subMessage3 =
+ (TestAny *)[message.anyValue unpackMessageClass:[TestAny class]
+ error:NULL];
+ XCTAssertNotNil(subMessage3);
+ XCTAssertEqualObjects(subMessage2, subMessage3);
+
+ // Try to extract wrong type.
+
+ GPBTimestamp *wrongMessage =
+ (GPBTimestamp *)[message.anyValue unpackMessageClass:[GPBTimestamp class]
+ error:&err];
+ XCTAssertNotNil(err);
+ XCTAssertNil(wrongMessage);
+ XCTAssertEqualObjects(err.domain, GPBWellKnownTypesErrorDomain);
+ XCTAssertEqual(err.code, GPBWellKnownTypesErrorCodeTypeURLMismatch);
+
+ wrongMessage =
+ (GPBTimestamp *)[message.anyValue unpackMessageClass:[GPBTimestamp class]
+ error:NULL];
+ XCTAssertNil(wrongMessage);
}
@end
diff --git a/objectivec/Tests/GPBWireFormatTests.m b/objectivec/Tests/GPBWireFormatTests.m
index 2a406f11..dbeab215 100644
--- a/objectivec/Tests/GPBWireFormatTests.m
+++ b/objectivec/Tests/GPBWireFormatTests.m
@@ -46,6 +46,7 @@
TestAllTypes* message = [self allSetRepeatedCount:kGPBDefaultRepeatCount];
NSData* rawBytes = message.data;
+ [self assertFieldsInOrder:rawBytes];
XCTAssertEqual(message.serializedSize, (size_t)rawBytes.length);
TestAllTypes* message2 = [TestAllTypes parseFromData:rawBytes error:NULL];
@@ -58,6 +59,7 @@
[self packedSetRepeatedCount:kGPBDefaultRepeatCount];
NSData* rawBytes = message.data;
+ [self assertFieldsInOrder:rawBytes];
XCTAssertEqual(message.serializedSize, (size_t)rawBytes.length);
TestPackedTypes* message2 =
@@ -74,6 +76,7 @@
TestAllExtensions* message =
[self allExtensionsSetRepeatedCount:kGPBDefaultRepeatCount];
NSData* rawBytes = message.data;
+ [self assertFieldsInOrder:rawBytes];
XCTAssertEqual(message.serializedSize, (size_t)rawBytes.length);
TestAllTypes* message2 = [TestAllTypes parseFromData:rawBytes error:NULL];
@@ -87,6 +90,7 @@
TestPackedExtensions* message =
[self packedExtensionsSetRepeatedCount:kGPBDefaultRepeatCount];
NSData* rawBytes = message.data;
+ [self assertFieldsInOrder:rawBytes];
TestPackedTypes* message2 =
[self packedSetRepeatedCount:kGPBDefaultRepeatCount];
@@ -102,6 +106,7 @@
TestAllTypes* message = [self allSetRepeatedCount:kGPBDefaultRepeatCount];
NSData* rawBytes = message.data;
+ [self assertFieldsInOrder:rawBytes];
GPBExtensionRegistry* registry = [self extensionRegistry];
@@ -113,7 +118,7 @@
}
-- (void) testExtensionsSerializedSize {
+- (void)testExtensionsSerializedSize {
size_t allSet = [self allSetRepeatedCount:kGPBDefaultRepeatCount].serializedSize;
size_t extensionSet = [self allExtensionsSetRepeatedCount:kGPBDefaultRepeatCount].serializedSize;
XCTAssertEqual(allSet, extensionSet);
@@ -124,6 +129,7 @@
TestPackedExtensions* message =
[self packedExtensionsSetRepeatedCount:kGPBDefaultRepeatCount];
NSData* rawBytes = message.data;
+ [self assertFieldsInOrder:rawBytes];
GPBExtensionRegistry* registry = [self extensionRegistry];
diff --git a/objectivec/Tests/iOSTestHarness/AppDelegate.m b/objectivec/Tests/iOSTestHarness/AppDelegate.m
deleted file mode 100644
index 8c4a586b..00000000
--- a/objectivec/Tests/iOSTestHarness/AppDelegate.m
+++ /dev/null
@@ -1,35 +0,0 @@
-#import <UIKit/UIKit.h>
-
-@interface AppDelegate : UIResponder <UIApplicationDelegate>
-@property (strong, nonatomic) UIWindow *window;
-@end
-
-@implementation AppDelegate
-
-@synthesize window;
-
-- (BOOL)application:(UIApplication *)application
- didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
- #pragma unused (application, launchOptions)
-
- self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
- self.window.backgroundColor = [UIColor whiteColor];
- [self.window makeKeyAndVisible];
- self.window.rootViewController = [[UIViewController alloc] init];
-
- UILabel *label =
- [[UILabel alloc] initWithFrame:CGRectMake(0, 200, CGRectGetWidth(self.window.frame), 40)];
- label.text = @"Protocol Buffer Test Harness";
- label.textAlignment = NSTextAlignmentCenter;
- [self.window addSubview:label];
-
- return YES;
-}
-
-@end
-
-int main(int argc, char * argv[]) {
- @autoreleasepool {
- return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
- }
-}
diff --git a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad6.png b/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad6.png
deleted file mode 100644
index 43da2ee4..00000000
--- a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad6.png
+++ /dev/null
Binary files differ
diff --git a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad6_2x.png b/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad6_2x.png
deleted file mode 100644
index 2ec93704..00000000
--- a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad6_2x.png
+++ /dev/null
Binary files differ
diff --git a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad7.png b/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad7.png
deleted file mode 100644
index aec8bc1b..00000000
--- a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad7.png
+++ /dev/null
Binary files differ
diff --git a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad7_2x.png b/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad7_2x.png
deleted file mode 100644
index e39cc3e7..00000000
--- a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad7_2x.png
+++ /dev/null
Binary files differ
diff --git a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone6.png b/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone6.png
deleted file mode 100644
index 5572d79f..00000000
--- a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone6.png
+++ /dev/null
Binary files differ
diff --git a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone6_2x.png b/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone6_2x.png
deleted file mode 100644
index 2424997f..00000000
--- a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone6_2x.png
+++ /dev/null
Binary files differ
diff --git a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone7_2x.png b/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone7_2x.png
deleted file mode 100644
index 10bfc3cf..00000000
--- a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone7_2x.png
+++ /dev/null
Binary files differ
diff --git a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone7_3x.png b/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone7_3x.png
deleted file mode 100644
index 8d16f14d..00000000
--- a/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone7_3x.png
+++ /dev/null
Binary files differ
diff --git a/objectivec/Tests/iOSTestHarness/Images.xcassets/LaunchImage.launchimage/Contents.json b/objectivec/Tests/iOSTestHarness/Images.xcassets/LaunchImage.launchimage/Contents.json
deleted file mode 100644
index 5a296668..00000000
--- a/objectivec/Tests/iOSTestHarness/Images.xcassets/LaunchImage.launchimage/Contents.json
+++ /dev/null
@@ -1,49 +0,0 @@
-{
- "images" : [
- {
- "orientation" : "portrait",
- "idiom" : "ipad",
- "minimum-system-version" : "7.0",
- "extent" : "full-screen",
- "scale" : "2x"
- },
- {
- "orientation" : "landscape",
- "idiom" : "ipad",
- "minimum-system-version" : "7.0",
- "extent" : "full-screen",
- "scale" : "1x"
- },
- {
- "orientation" : "landscape",
- "idiom" : "ipad",
- "minimum-system-version" : "7.0",
- "extent" : "full-screen",
- "scale" : "2x"
- },
- {
- "orientation" : "portrait",
- "idiom" : "iphone",
- "minimum-system-version" : "7.0",
- "scale" : "2x"
- },
- {
- "orientation" : "portrait",
- "idiom" : "iphone",
- "minimum-system-version" : "7.0",
- "subtype" : "retina4",
- "scale" : "2x"
- },
- {
- "orientation" : "portrait",
- "idiom" : "ipad",
- "minimum-system-version" : "7.0",
- "extent" : "full-screen",
- "scale" : "1x"
- }
- ],
- "info" : {
- "version" : 1,
- "author" : "xcode"
- }
-} \ No newline at end of file
diff --git a/objectivec/Tests/iOSTestHarness/LaunchScreen.xib b/objectivec/Tests/iOSTestHarness/LaunchScreen.xib
deleted file mode 100644
index 22204bfe..00000000
--- a/objectivec/Tests/iOSTestHarness/LaunchScreen.xib
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6254" systemVersion="13F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
- <dependencies>
- <deployment identifier="iOS"/>
- <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
- <capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
- </dependencies>
- <objects>
- <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
- <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
- <view contentMode="scaleToFill" id="iN0-l3-epB">
- <rect key="frame" x="0.0" y="0.0" width="630" height="503"/>
- <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
- <subviews>
- <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Protocol Buffer Test Harness" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
- <rect key="frame" x="20" y="147" width="591" height="43"/>
- <fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
- <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
- <nil key="highlightedColor"/>
- </label>
- </subviews>
- <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
- <constraints>
- <constraint firstItem="kId-c2-rCX" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="bottom" multiplier="1/3" constant="1" id="Kid-kn-2rF"/>
- <constraint firstAttribute="centerX" secondItem="kId-c2-rCX" secondAttribute="centerX" id="Koa-jz-hwk"/>
- <constraint firstItem="kId-c2-rCX" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="fvb-Df-36g"/>
- </constraints>
- <nil key="simulatedStatusBarMetrics"/>
- <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
- <point key="canvasLocation" x="479" y="456.5"/>
- </view>
- </objects>
-</document>
diff --git a/objectivec/Tests/iOSTestHarness/en.lproj/InfoPlist.strings b/objectivec/Tests/iOSTestHarness/en.lproj/InfoPlist.strings
deleted file mode 100644
index 477b28ff..00000000
--- a/objectivec/Tests/iOSTestHarness/en.lproj/InfoPlist.strings
+++ /dev/null
@@ -1,2 +0,0 @@
-/* Localized versions of Info.plist keys */
-
diff --git a/objectivec/Tests/unittest_cycle.proto b/objectivec/Tests/unittest_cycle.proto
index 5f6f56a1..afc1b0fe 100644
--- a/objectivec/Tests/unittest_cycle.proto
+++ b/objectivec/Tests/unittest_cycle.proto
@@ -31,10 +31,8 @@ syntax = "proto2";
package protobuf_unittest;
-// Cycles in the Message graph can cause problems for the mutable classes
-// since the properties on the mutable class change types. This file just
-// needs to generate source, and that source must compile, to ensure the
-// generated source works for this sort of case.
+// Cycles in the Message graph can cause problems for message class
+// initialization order.
// You can't make a object graph that spans files, so this can only be done
// within a single proto file.
diff --git a/objectivec/Tests/unittest_deprecated.proto b/objectivec/Tests/unittest_deprecated.proto
new file mode 100644
index 00000000..96a52bbb
--- /dev/null
+++ b/objectivec/Tests/unittest_deprecated.proto
@@ -0,0 +1,95 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto2";
+
+package protobuf_deprecated;
+option objc_class_prefix = "Dep";
+
+//
+// This file is like unittest_deprecated_file.proto, but uses message, enum,
+// enum value, and field level deprecation.
+//
+// The source generated from this file needs to be inspect to confirm it has
+// all of the expected annotations. It also will be compiled into the unittest
+// and that compile should be clean without errors.
+//
+
+// Mix of field types marked as deprecated.
+message Msg1 {
+ extensions 100 to max;
+
+ optional string string_field = 1 [deprecated=true];
+ required int32 int_field = 2 [deprecated=true];
+ repeated fixed32 fixed_field = 3 [deprecated=true];
+ optional Msg1 msg_field = 4 [deprecated=true];
+}
+
+// Mix of extension field types marked as deprecated.
+extend Msg1 {
+ optional string string_ext_field = 101 [deprecated=true];
+ optional int32 int_ext_field = 102 [deprecated=true];
+ repeated fixed32 fixed_ext_field = 103 [deprecated=true];
+ optional Msg1 msg_ext_field = 104 [deprecated=true];
+}
+
+// Mix of extension field types (scoped to a message) marked as deprecated.
+message Msg1A {
+ extend Msg1 {
+ optional string string_ext2_field = 201 [deprecated=true];
+ optional int32 int_ext2_field = 202 [deprecated=true];
+ repeated fixed32 fixed_ext2_field = 203 [deprecated=true];
+ optional Msg1 msg_ext2_field = 204 [deprecated=true];
+ }
+}
+
+// Enum value marked as deprecated.
+enum Enum1 {
+ ENUM1_ONE = 1;
+ ENUM1_TWO = 2;
+ ENUM1_THREE = 3 [deprecated=true];
+}
+
+// Message marked as deprecated.
+message Msg2 {
+ option deprecated = true;
+
+ optional string string_field = 1;
+ required int32 int_field = 2;
+ repeated fixed32 fixed_field = 3;
+}
+
+// Enum marked as deprecated.
+enum Enum2 {
+ option deprecated = true;
+
+ ENUM2_ONE = 1;
+ ENUM2_TWO = 2;
+ ENUM2_THREE = 3;
+}
diff --git a/objectivec/Tests/unittest_deprecated_file.proto b/objectivec/Tests/unittest_deprecated_file.proto
new file mode 100644
index 00000000..ef92e7de
--- /dev/null
+++ b/objectivec/Tests/unittest_deprecated_file.proto
@@ -0,0 +1,76 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto2";
+
+package protobuf_deprecated_file;
+option objc_class_prefix = "FileDep";
+
+//
+// This file is like unittest_deprecated.proto, but does NOT use message, enum,
+// enum value, or field level deprecation; instead it uses the file level option
+// to mark everything.
+//
+// The source generated from this file needs to be inspect to confirm it has
+// all of the expected annotations. It also will be compiled into the unittest
+// and that compile should be clean without errors.
+//
+option deprecated = true;
+
+// Message to catch the deprecation.
+message Msg1 {
+ extensions 100 to max;
+
+ optional string string_field = 1;
+}
+
+// Mix of extension field types to catch the deprecation.
+extend Msg1 {
+ optional string string_ext_field = 101;
+ optional int32 int_ext_field = 102;
+ repeated fixed32 fixed_ext_field = 103;
+ optional Msg1 msg_ext_field = 104;
+}
+
+// Mix of extension field types (scoped to a message) to catch the deprecation.
+message Msg1A {
+ extend Msg1 {
+ optional string string_ext2_field = 201;
+ optional int32 int_ext2_field = 202;
+ repeated fixed32 fixed_ext2_field = 203;
+ optional Msg1 msg_ext2_field = 204;
+ }
+}
+
+// Enum to catch the deprecation.
+enum Enum1 {
+ ENUM1_ONE = 1;
+ ENUM1_TWO = 2;
+ ENUM1_THREE = 3;
+}
diff --git a/objectivec/Tests/unittest_extension_chain_a.proto b/objectivec/Tests/unittest_extension_chain_a.proto
new file mode 100644
index 00000000..6a227eb9
--- /dev/null
+++ b/objectivec/Tests/unittest_extension_chain_a.proto
@@ -0,0 +1,51 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto2";
+
+package protobuf_unittest;
+
+import "google/protobuf/unittest.proto";
+
+import "unittest_extension_chain_b.proto";
+import "unittest_extension_chain_c.proto";
+import "unittest_extension_chain_d.proto";
+
+// The Root for this file should end up adding the local extension and merging
+// in the extensions from D's Root (unittest and C will come via D's).
+
+message ChainAMessage {
+ optional ChainBMessage b = 1;
+ optional ChainCMessage c = 2;
+ optional ChainDMessage d = 3;
+}
+
+extend TestAllExtensions {
+ optional int32 chain_a_extension = 10001;
+}
diff --git a/objectivec/Tests/unittest_extension_chain_b.proto b/objectivec/Tests/unittest_extension_chain_b.proto
new file mode 100644
index 00000000..0da7ed3e
--- /dev/null
+++ b/objectivec/Tests/unittest_extension_chain_b.proto
@@ -0,0 +1,47 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto2";
+
+package protobuf_unittest;
+
+import "google/protobuf/unittest.proto";
+
+import "unittest_extension_chain_c.proto";
+
+// The Root for this file should end up adding the local extension and merging
+// in the extensions from C's Root (unittest will come via C's).
+
+message ChainBMessage {
+ optional ChainCMessage c = 1;
+}
+
+extend TestAllExtensions {
+ optional int32 chain_b_extension = 10002;
+}
diff --git a/objectivec/Tests/unittest_extension_chain_c.proto b/objectivec/Tests/unittest_extension_chain_c.proto
new file mode 100644
index 00000000..c702900a
--- /dev/null
+++ b/objectivec/Tests/unittest_extension_chain_c.proto
@@ -0,0 +1,45 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto2";
+
+package protobuf_unittest;
+
+import "google/protobuf/unittest.proto";
+
+// The Root for this file should end up adding the local extension and merging
+// in the extensions from unittest.proto's Root.
+
+message ChainCMessage {
+ optional int32 my_field = 1;
+}
+
+extend TestAllExtensions {
+ optional int32 chain_c_extension = 10003;
+}
diff --git a/objectivec/Tests/unittest_extension_chain_d.proto b/objectivec/Tests/unittest_extension_chain_d.proto
new file mode 100644
index 00000000..f9abe3ba
--- /dev/null
+++ b/objectivec/Tests/unittest_extension_chain_d.proto
@@ -0,0 +1,49 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto2";
+
+package protobuf_unittest;
+
+import "google/protobuf/unittest.proto";
+
+import "unittest_extension_chain_b.proto";
+import "unittest_extension_chain_c.proto";
+
+// The root should end up needing to merge B (C will be merged into B, so it
+// doesn't need to be directly merged).
+
+message ChainDMessage {
+ optional ChainBMessage b = 1;
+ optional ChainCMessage c = 2;
+}
+
+extend TestAllExtensions {
+ optional int32 chain_d_extension = 10004;
+}
diff --git a/objectivec/Tests/unittest_extension_chain_e.proto b/objectivec/Tests/unittest_extension_chain_e.proto
new file mode 100644
index 00000000..fe116631
--- /dev/null
+++ b/objectivec/Tests/unittest_extension_chain_e.proto
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto2";
+
+package protobuf_unittest;
+
+import "google/protobuf/unittest.proto";
+
+// The Root for this file should end up just merging in unittest's Root.
+
+message ChainEMessage {
+ optional TestAllTypes my_field = 1;
+}
diff --git a/objectivec/Tests/unittest_extension_chain_f.proto b/objectivec/Tests/unittest_extension_chain_f.proto
new file mode 100644
index 00000000..b9bed723
--- /dev/null
+++ b/objectivec/Tests/unittest_extension_chain_f.proto
@@ -0,0 +1,44 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto2";
+
+package protobuf_unittest;
+
+import "unittest_extension_chain_g.proto";
+
+// The Root for this file should just be merging in the extensions from C's
+// Root (because G doens't define anything itself).
+
+// The generated source will also have to directly import C's .h file so it can
+// compile the reference to C's Root class.
+
+message ChainFMessage {
+ optional ChainGMessage g = 1;
+}
diff --git a/objectivec/Tests/unittest_extension_chain_g.proto b/objectivec/Tests/unittest_extension_chain_g.proto
new file mode 100644
index 00000000..aee827b1
--- /dev/null
+++ b/objectivec/Tests/unittest_extension_chain_g.proto
@@ -0,0 +1,41 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto2";
+
+package protobuf_unittest;
+
+import "unittest_extension_chain_c.proto";
+
+// The Root for this file should just be merging in the extensions from C's
+// Root.
+
+message ChainGMessage {
+ optional ChainCMessage c = 1;
+}
diff --git a/objectivec/Tests/unittest_objc.proto b/objectivec/Tests/unittest_objc.proto
index 3bb92761..b0eb4723 100644
--- a/objectivec/Tests/unittest_objc.proto
+++ b/objectivec/Tests/unittest_objc.proto
@@ -29,10 +29,20 @@
syntax = "proto2";
+import "google/protobuf/any.proto";
import "google/protobuf/unittest.proto";
package protobuf_unittest;
+// Used to check that Headerdocs and appledoc work correctly. If these comments
+// are not handled correctly, Xcode will fail to build the tests.
+message TestGeneratedComments {
+ // This is a string that could contain stuff like
+ // mime types as image/* or */plain. Maybe twitter usernames
+ // like @protobuf, @google or @something.
+ optional string string_field = 1;
+}
+
// Using the messages in unittest.proto, setup for recursive cases for testing
// extensions at various depths.
extend TestAllExtensions {
@@ -48,6 +58,27 @@ message TestRecursiveMessageWithRepeatedField {
map<string, string> str_to_str = 5;
}
+// Message with a few types of maps to cover the different custom flows
+// in the runtime.
+message TestMessageOfMaps {
+ map<string, string> str_to_str = 1;
+
+ map<string, int32> str_to_int = 2;
+ map<int32, string> int_to_str = 3;
+ map<int32, int32> int_to_int = 4;
+
+ map<string, bool> str_to_bool = 5;
+ map<bool, string> bool_to_str = 6;
+ map<bool, bool> bool_to_bool = 7;
+
+ map<int32, bool> int_to_bool = 8;
+ map<bool, int32> bool_to_int = 9;
+
+ map<string, TestAllTypes> str_to_msg = 10;
+ map<int32, TestAllTypes> int_to_msg = 11;
+ map<bool, TestAllTypes> bool_to_msg = 12;
+}
+
// Recursive message and extension to for testing autocreators at different
// depths.
message TestRecursiveExtension {
@@ -112,6 +143,18 @@ enum retain {
serializedSize = 6;
}
+message ObjCPropertyNaming {
+ // Test that the properties properly get things all caps.
+ optional string url = 1;
+ optional string thumbnail_url = 2;
+ optional string url_foo = 3;
+ optional string some_url_blah = 4;
+ optional string http = 5;
+ optional string https = 6;
+ // This one doesn't.
+ repeated string urls = 7;
+}
+
// EnumValueShortName: The short names shouldn't get suffixes/prefixes.
enum Foo {
SERIALIZED_SIZE = 1;
@@ -389,3 +432,57 @@ message EnumTestMsg {
repeated MyEnum mumble = 4;
}
+
+// Test case for https://github.com/google/protobuf/issues/1453
+// Message with no explicit defaults, but a non zero default for an enum.
+message MessageWithOneBasedEnum {
+ enum OneBasedEnum {
+ ONE = 1;
+ TWO = 2;
+ }
+ optional OneBasedEnum enum_field = 1;
+}
+
+// Message with all bools for testing things related to bool storage.
+message BoolOnlyMessage {
+ optional bool bool_field_1 = 1;
+ optional bool bool_field_2 = 2;
+ optional bool bool_field_3 = 3;
+ optional bool bool_field_4 = 4;
+ optional bool bool_field_5 = 5;
+ optional bool bool_field_6 = 6;
+ optional bool bool_field_7 = 7;
+ optional bool bool_field_8 = 8;
+ optional bool bool_field_9 = 9;
+ optional bool bool_field_10 = 10;
+ optional bool bool_field_11 = 11;
+ optional bool bool_field_12 = 12;
+ optional bool bool_field_13 = 13;
+ optional bool bool_field_14 = 14;
+ optional bool bool_field_15 = 15;
+ optional bool bool_field_16 = 16;
+ optional bool bool_field_17 = 17;
+ optional bool bool_field_18 = 18;
+ optional bool bool_field_19 = 19;
+ optional bool bool_field_20 = 20;
+ optional bool bool_field_21 = 21;
+ optional bool bool_field_22 = 22;
+ optional bool bool_field_23 = 23;
+ optional bool bool_field_24 = 24;
+ optional bool bool_field_25 = 25;
+ optional bool bool_field_26 = 26;
+ optional bool bool_field_27 = 27;
+ optional bool bool_field_28 = 28;
+ optional bool bool_field_29 = 29;
+ optional bool bool_field_30 = 30;
+ optional bool bool_field_31 = 31;
+ optional bool bool_field_32 = 32;
+}
+
+// Reference to a WKT to test (via generated code inspection), the handling
+// of #imports. Within the WKTs, references to each other are just path
+// based imports, but when reference from another proto file, they should be
+// conditional to support the framework import style.
+message WKTRefereceMessage {
+ optional google.protobuf.Any an_any = 1;
+}