Merge pull request #841 from thomasvl/newer_xcodes
Cleanups for newer Xcodes
This commit is contained in:
commit
ebf3eb630d
15 changed files with 1216 additions and 1208 deletions
|
@ -202,9 +202,9 @@ if [[ "${DO_XCODE_IOS_TESTS}" == "yes" ]] ; then
|
|||
# Don't need to worry about form factors or retina/non retina;
|
||||
# just pick a mix of OS Versions and 32/64 bit.
|
||||
-destination "platform=iOS Simulator,name=iPhone 4s,OS=7.1" # 32bit
|
||||
-destination "platform=iOS Simulator,name=iPhone 6,OS=8.3" # 64bit
|
||||
-destination "platform=iOS Simulator,name=iPhone 6,OS=8.4" # 64bit
|
||||
-destination "platform=iOS Simulator,name=iPad 2,OS=7.1" # 32bit
|
||||
-destination "platform=iOS Simulator,name=iPad Air,OS=8.3" # 64bit
|
||||
-destination "platform=iOS Simulator,name=iPad Air,OS=8.4" # 64bit
|
||||
)
|
||||
header "Doing Xcode iOS build/tests - Debug"
|
||||
"${XCODEBUILD_TEST_BASE_IOS[@]}" -configuration Debug test
|
||||
|
|
|
@ -360,30 +360,30 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
@property(nonatomic, readonly) NSUInteger count;
|
||||
|
||||
+ (instancetype)dictionary;
|
||||
+ (instancetype)dictionaryWithValue:(id)value
|
||||
forKey:(uint32_t)key;
|
||||
+ (instancetype)dictionaryWithValues:(const id GPB_UNSAFE_UNRETAINED [])values
|
||||
forKeys:(const uint32_t [])keys
|
||||
count:(NSUInteger)count;
|
||||
+ (instancetype)dictionaryWithObject:(id)object
|
||||
forKey:(uint32_t)key;
|
||||
+ (instancetype)dictionaryWithObjects:(const id GPB_UNSAFE_UNRETAINED [])objects
|
||||
forKeys:(const uint32_t [])keys
|
||||
count:(NSUInteger)count;
|
||||
+ (instancetype)dictionaryWithDictionary:(GPBUInt32ObjectDictionary *)dictionary;
|
||||
+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
|
||||
|
||||
- (instancetype)initWithValues:(const id GPB_UNSAFE_UNRETAINED [])values
|
||||
forKeys:(const uint32_t [])keys
|
||||
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)initWithObjects:(const id GPB_UNSAFE_UNRETAINED [])objects
|
||||
forKeys:(const uint32_t [])keys
|
||||
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)initWithDictionary:(GPBUInt32ObjectDictionary *)dictionary;
|
||||
- (instancetype)initWithCapacity:(NSUInteger)numItems;
|
||||
|
||||
- (id)valueForKey:(uint32_t)key;
|
||||
- (id)objectForKey:(uint32_t)key;
|
||||
|
||||
- (void)enumerateKeysAndValuesUsingBlock:
|
||||
(void (^)(uint32_t key, id value, BOOL *stop))block;
|
||||
- (void)enumerateKeysAndObjectsUsingBlock:
|
||||
(void (^)(uint32_t key, id object, BOOL *stop))block;
|
||||
|
||||
- (void)addEntriesFromDictionary:(GPBUInt32ObjectDictionary *)otherDictionary;
|
||||
|
||||
- (void)setValue:(id)value forKey:(uint32_t)key;
|
||||
- (void)setObject:(id)object forKey:(uint32_t)key;
|
||||
|
||||
- (void)removeValueForKey:(uint32_t)aKey;
|
||||
- (void)removeObjectForKey:(uint32_t)aKey;
|
||||
- (void)removeAll;
|
||||
|
||||
@end
|
||||
|
@ -706,30 +706,30 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
@property(nonatomic, readonly) NSUInteger count;
|
||||
|
||||
+ (instancetype)dictionary;
|
||||
+ (instancetype)dictionaryWithValue:(id)value
|
||||
forKey:(int32_t)key;
|
||||
+ (instancetype)dictionaryWithValues:(const id GPB_UNSAFE_UNRETAINED [])values
|
||||
forKeys:(const int32_t [])keys
|
||||
count:(NSUInteger)count;
|
||||
+ (instancetype)dictionaryWithObject:(id)object
|
||||
forKey:(int32_t)key;
|
||||
+ (instancetype)dictionaryWithObjects:(const id GPB_UNSAFE_UNRETAINED [])objects
|
||||
forKeys:(const int32_t [])keys
|
||||
count:(NSUInteger)count;
|
||||
+ (instancetype)dictionaryWithDictionary:(GPBInt32ObjectDictionary *)dictionary;
|
||||
+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
|
||||
|
||||
- (instancetype)initWithValues:(const id GPB_UNSAFE_UNRETAINED [])values
|
||||
forKeys:(const int32_t [])keys
|
||||
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)initWithObjects:(const id GPB_UNSAFE_UNRETAINED [])objects
|
||||
forKeys:(const int32_t [])keys
|
||||
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)initWithDictionary:(GPBInt32ObjectDictionary *)dictionary;
|
||||
- (instancetype)initWithCapacity:(NSUInteger)numItems;
|
||||
|
||||
- (id)valueForKey:(int32_t)key;
|
||||
- (id)objectForKey:(int32_t)key;
|
||||
|
||||
- (void)enumerateKeysAndValuesUsingBlock:
|
||||
(void (^)(int32_t key, id value, BOOL *stop))block;
|
||||
- (void)enumerateKeysAndObjectsUsingBlock:
|
||||
(void (^)(int32_t key, id object, BOOL *stop))block;
|
||||
|
||||
- (void)addEntriesFromDictionary:(GPBInt32ObjectDictionary *)otherDictionary;
|
||||
|
||||
- (void)setValue:(id)value forKey:(int32_t)key;
|
||||
- (void)setObject:(id)object forKey:(int32_t)key;
|
||||
|
||||
- (void)removeValueForKey:(int32_t)aKey;
|
||||
- (void)removeObjectForKey:(int32_t)aKey;
|
||||
- (void)removeAll;
|
||||
|
||||
@end
|
||||
|
@ -1052,30 +1052,30 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
@property(nonatomic, readonly) NSUInteger count;
|
||||
|
||||
+ (instancetype)dictionary;
|
||||
+ (instancetype)dictionaryWithValue:(id)value
|
||||
forKey:(uint64_t)key;
|
||||
+ (instancetype)dictionaryWithValues:(const id GPB_UNSAFE_UNRETAINED [])values
|
||||
forKeys:(const uint64_t [])keys
|
||||
count:(NSUInteger)count;
|
||||
+ (instancetype)dictionaryWithObject:(id)object
|
||||
forKey:(uint64_t)key;
|
||||
+ (instancetype)dictionaryWithObjects:(const id GPB_UNSAFE_UNRETAINED [])objects
|
||||
forKeys:(const uint64_t [])keys
|
||||
count:(NSUInteger)count;
|
||||
+ (instancetype)dictionaryWithDictionary:(GPBUInt64ObjectDictionary *)dictionary;
|
||||
+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
|
||||
|
||||
- (instancetype)initWithValues:(const id GPB_UNSAFE_UNRETAINED [])values
|
||||
forKeys:(const uint64_t [])keys
|
||||
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)initWithObjects:(const id GPB_UNSAFE_UNRETAINED [])objects
|
||||
forKeys:(const uint64_t [])keys
|
||||
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)initWithDictionary:(GPBUInt64ObjectDictionary *)dictionary;
|
||||
- (instancetype)initWithCapacity:(NSUInteger)numItems;
|
||||
|
||||
- (id)valueForKey:(uint64_t)key;
|
||||
- (id)objectForKey:(uint64_t)key;
|
||||
|
||||
- (void)enumerateKeysAndValuesUsingBlock:
|
||||
(void (^)(uint64_t key, id value, BOOL *stop))block;
|
||||
- (void)enumerateKeysAndObjectsUsingBlock:
|
||||
(void (^)(uint64_t key, id object, BOOL *stop))block;
|
||||
|
||||
- (void)addEntriesFromDictionary:(GPBUInt64ObjectDictionary *)otherDictionary;
|
||||
|
||||
- (void)setValue:(id)value forKey:(uint64_t)key;
|
||||
- (void)setObject:(id)object forKey:(uint64_t)key;
|
||||
|
||||
- (void)removeValueForKey:(uint64_t)aKey;
|
||||
- (void)removeObjectForKey:(uint64_t)aKey;
|
||||
- (void)removeAll;
|
||||
|
||||
@end
|
||||
|
@ -1398,30 +1398,30 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
@property(nonatomic, readonly) NSUInteger count;
|
||||
|
||||
+ (instancetype)dictionary;
|
||||
+ (instancetype)dictionaryWithValue:(id)value
|
||||
forKey:(int64_t)key;
|
||||
+ (instancetype)dictionaryWithValues:(const id GPB_UNSAFE_UNRETAINED [])values
|
||||
forKeys:(const int64_t [])keys
|
||||
count:(NSUInteger)count;
|
||||
+ (instancetype)dictionaryWithObject:(id)object
|
||||
forKey:(int64_t)key;
|
||||
+ (instancetype)dictionaryWithObjects:(const id GPB_UNSAFE_UNRETAINED [])objects
|
||||
forKeys:(const int64_t [])keys
|
||||
count:(NSUInteger)count;
|
||||
+ (instancetype)dictionaryWithDictionary:(GPBInt64ObjectDictionary *)dictionary;
|
||||
+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
|
||||
|
||||
- (instancetype)initWithValues:(const id GPB_UNSAFE_UNRETAINED [])values
|
||||
forKeys:(const int64_t [])keys
|
||||
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)initWithObjects:(const id GPB_UNSAFE_UNRETAINED [])objects
|
||||
forKeys:(const int64_t [])keys
|
||||
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)initWithDictionary:(GPBInt64ObjectDictionary *)dictionary;
|
||||
- (instancetype)initWithCapacity:(NSUInteger)numItems;
|
||||
|
||||
- (id)valueForKey:(int64_t)key;
|
||||
- (id)objectForKey:(int64_t)key;
|
||||
|
||||
- (void)enumerateKeysAndValuesUsingBlock:
|
||||
(void (^)(int64_t key, id value, BOOL *stop))block;
|
||||
- (void)enumerateKeysAndObjectsUsingBlock:
|
||||
(void (^)(int64_t key, id object, BOOL *stop))block;
|
||||
|
||||
- (void)addEntriesFromDictionary:(GPBInt64ObjectDictionary *)otherDictionary;
|
||||
|
||||
- (void)setValue:(id)value forKey:(int64_t)key;
|
||||
- (void)setObject:(id)object forKey:(int64_t)key;
|
||||
|
||||
- (void)removeValueForKey:(int64_t)aKey;
|
||||
- (void)removeObjectForKey:(int64_t)aKey;
|
||||
- (void)removeAll;
|
||||
|
||||
@end
|
||||
|
@ -1744,30 +1744,30 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
@property(nonatomic, readonly) NSUInteger count;
|
||||
|
||||
+ (instancetype)dictionary;
|
||||
+ (instancetype)dictionaryWithValue:(id)value
|
||||
forKey:(BOOL)key;
|
||||
+ (instancetype)dictionaryWithValues:(const id GPB_UNSAFE_UNRETAINED [])values
|
||||
forKeys:(const BOOL [])keys
|
||||
count:(NSUInteger)count;
|
||||
+ (instancetype)dictionaryWithObject:(id)object
|
||||
forKey:(BOOL)key;
|
||||
+ (instancetype)dictionaryWithObjects:(const id GPB_UNSAFE_UNRETAINED [])objects
|
||||
forKeys:(const BOOL [])keys
|
||||
count:(NSUInteger)count;
|
||||
+ (instancetype)dictionaryWithDictionary:(GPBBoolObjectDictionary *)dictionary;
|
||||
+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
|
||||
|
||||
- (instancetype)initWithValues:(const id GPB_UNSAFE_UNRETAINED [])values
|
||||
forKeys:(const BOOL [])keys
|
||||
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)initWithObjects:(const id GPB_UNSAFE_UNRETAINED [])objects
|
||||
forKeys:(const BOOL [])keys
|
||||
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)initWithDictionary:(GPBBoolObjectDictionary *)dictionary;
|
||||
- (instancetype)initWithCapacity:(NSUInteger)numItems;
|
||||
|
||||
- (id)valueForKey:(BOOL)key;
|
||||
- (id)objectForKey:(BOOL)key;
|
||||
|
||||
- (void)enumerateKeysAndValuesUsingBlock:
|
||||
(void (^)(BOOL key, id value, BOOL *stop))block;
|
||||
- (void)enumerateKeysAndObjectsUsingBlock:
|
||||
(void (^)(BOOL key, id object, BOOL *stop))block;
|
||||
|
||||
- (void)addEntriesFromDictionary:(GPBBoolObjectDictionary *)otherDictionary;
|
||||
|
||||
- (void)setValue:(id)value forKey:(BOOL)key;
|
||||
- (void)setObject:(id)object forKey:(BOOL)key;
|
||||
|
||||
- (void)removeValueForKey:(BOOL)aKey;
|
||||
- (void)removeObjectForKey:(BOOL)aKey;
|
||||
- (void)removeAll;
|
||||
|
||||
@end
|
||||
|
@ -2107,13 +2107,13 @@ NS_ASSUME_NONNULL_END
|
|||
//%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Double, double)
|
||||
//%DICTIONARY_KEY_TO_ENUM_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Enum, int32_t)
|
||||
//%PDDM-DEFINE DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE)
|
||||
//%DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, POD)
|
||||
//%DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, POD, value)
|
||||
//%PDDM-DEFINE DICTIONARY_POD_KEY_TO_OBJECT_INTERFACE(KEY_NAME, KEY_TYPE, VALUE_NAME, VALUE_TYPE)
|
||||
//%DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, , POD, VALUE_NAME, VALUE_TYPE, OBJECT)
|
||||
//%DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, , POD, VALUE_NAME, VALUE_TYPE, OBJECT, object)
|
||||
//%PDDM-DEFINE VALUE_FOR_KEY_POD(KEY_TYPE, VALUE_TYPE)
|
||||
//%- (BOOL)valueForKey:(KEY_TYPE)key value:(nullable VALUE_TYPE *)value;
|
||||
//%PDDM-DEFINE VALUE_FOR_KEY_OBJECT(KEY_TYPE, VALUE_TYPE)
|
||||
//%- (VALUE_TYPE)valueForKey:(KEY_TYPE)key;
|
||||
//%- (VALUE_TYPE)objectForKey:(KEY_TYPE)key;
|
||||
//%PDDM-DEFINE VALUE_FOR_KEY_Enum(KEY_TYPE, VALUE_TYPE)
|
||||
//%VALUE_FOR_KEY_POD(KEY_TYPE, VALUE_TYPE)
|
||||
//%PDDM-DEFINE ARRAY_ARG_MODIFIERPOD()
|
||||
|
@ -2122,7 +2122,7 @@ NS_ASSUME_NONNULL_END
|
|||
// Nothing
|
||||
//%PDDM-DEFINE ARRAY_ARG_MODIFIEROBJECT()
|
||||
//%GPB_UNSAFE_UNRETAINED ##
|
||||
//%PDDM-DEFINE DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, VHELPER)
|
||||
//%PDDM-DEFINE DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME)
|
||||
//%#pragma mark - KEY_NAME -> VALUE_NAME
|
||||
//%
|
||||
//%@interface GPB##KEY_NAME##VALUE_NAME##Dictionary : NSObject <NSCopying>
|
||||
|
@ -2130,25 +2130,25 @@ NS_ASSUME_NONNULL_END
|
|||
//%@property(nonatomic, readonly) NSUInteger count;
|
||||
//%
|
||||
//%+ (instancetype)dictionary;
|
||||
//%+ (instancetype)dictionaryWithValue:(VALUE_TYPE)value
|
||||
//% forKey:(KEY_TYPE##KisP$S##KisP)key;
|
||||
//%+ (instancetype)dictionaryWithValues:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[])values
|
||||
//% forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[])keys
|
||||
//% count:(NSUInteger)count;
|
||||
//%+ (instancetype)dictionaryWith##VNAME$u##:(VALUE_TYPE)##VNAME
|
||||
//% ##VNAME$S## forKey:(KEY_TYPE##KisP$S##KisP)key;
|
||||
//%+ (instancetype)dictionaryWith##VNAME$u##s:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[])##VNAME##s
|
||||
//% ##VNAME$S## forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[])keys
|
||||
//% ##VNAME$S## count:(NSUInteger)count;
|
||||
//%+ (instancetype)dictionaryWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary;
|
||||
//%+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
|
||||
//%
|
||||
//%- (instancetype)initWithValues:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[])values
|
||||
//% forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[])keys
|
||||
//% count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
|
||||
//%- (instancetype)initWith##VNAME$u##s:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[])##VNAME##s
|
||||
//% ##VNAME$S## forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[])keys
|
||||
//% ##VNAME$S## count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
|
||||
//%- (instancetype)initWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary;
|
||||
//%- (instancetype)initWithCapacity:(NSUInteger)numItems;
|
||||
//%
|
||||
//%DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER)
|
||||
//%DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME)
|
||||
//%
|
||||
//%- (void)addEntriesFromDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)otherDictionary;
|
||||
//%
|
||||
//%DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER)
|
||||
//%DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME)
|
||||
//%
|
||||
//%@end
|
||||
//%
|
||||
|
@ -2189,7 +2189,7 @@ NS_ASSUME_NONNULL_END
|
|||
//%// is not a valid enumerator as defined by validationFunc. If the actual value is
|
||||
//%// desired, use "raw" version of the method.
|
||||
//%
|
||||
//%DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER)
|
||||
//%DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, value)
|
||||
//%
|
||||
//%// These methods bypass the validationFunc to provide access to values that were not
|
||||
//%// known at the time the binary was compiled.
|
||||
|
@ -2206,21 +2206,21 @@ NS_ASSUME_NONNULL_END
|
|||
//%// to the default value. Use the rawValue methods below to assign non enumerator
|
||||
//%// values.
|
||||
//%
|
||||
//%DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER)
|
||||
//%DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, value)
|
||||
//%
|
||||
//%@end
|
||||
//%
|
||||
|
||||
//%PDDM-DEFINE DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER)
|
||||
//%PDDM-DEFINE DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME)
|
||||
//%VALUE_FOR_KEY_##VHELPER(KEY_TYPE##KisP$S##KisP, VALUE_TYPE)
|
||||
//%
|
||||
//%- (void)enumerateKeysAndValuesUsingBlock:
|
||||
//% (void (^)(KEY_TYPE KisP##key, VALUE_TYPE value, BOOL *stop))block;
|
||||
//%- (void)enumerateKeysAnd##VNAME$u##sUsingBlock:
|
||||
//% (void (^)(KEY_TYPE KisP##key, VALUE_TYPE VNAME, BOOL *stop))block;
|
||||
|
||||
//%PDDM-DEFINE DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER)
|
||||
//%- (void)setValue:(VALUE_TYPE)value forKey:(KEY_TYPE##KisP$S##KisP)key;
|
||||
//%PDDM-DEFINE DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME)
|
||||
//%- (void)set##VNAME$u##:(VALUE_TYPE)##VNAME forKey:(KEY_TYPE##KisP$S##KisP)key;
|
||||
//%DICTIONARY_EXTRA_MUTABLE_METHODS_##VHELPER(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE)
|
||||
//%- (void)removeValueForKey:(KEY_TYPE##KisP$S##KisP)aKey;
|
||||
//%- (void)remove##VNAME$u##ForKey:(KEY_TYPE##KisP$S##KisP)aKey;
|
||||
//%- (void)removeAll;
|
||||
|
||||
//%PDDM-DEFINE DICTIONARY_EXTRA_MUTABLE_METHODS_POD(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE)
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -167,10 +167,10 @@
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 Fewer pairs; not equal
|
||||
|
@ -468,10 +468,10 @@
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 Fewer pairs; not equal
|
||||
|
@ -769,10 +769,10 @@
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 Fewer pairs; not equal
|
||||
|
@ -1070,10 +1070,10 @@
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 Fewer pairs; not equal
|
||||
|
@ -1371,10 +1371,10 @@
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 Fewer pairs; not equal
|
||||
|
@ -1672,10 +1672,10 @@
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 Fewer pairs; not equal
|
||||
|
@ -1973,10 +1973,10 @@
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 Fewer pairs; not equal
|
||||
|
@ -2161,46 +2161,46 @@
|
|||
GPBBoolObjectDictionary *dict = [[GPBBoolObjectDictionary alloc] init];
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertNil([dict valueForKey:YES]);
|
||||
[dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, id aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTAssertNil([dict objectForKey:YES]);
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(BOOL aKey, id aObject, BOOL *stop) {
|
||||
#pragma unused(aKey, aObject, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
}
|
||||
|
||||
- (void)testOne {
|
||||
GPBBoolObjectDictionary *dict = [GPBBoolObjectDictionary dictionaryWithValue:@"abc" forKey:YES];
|
||||
GPBBoolObjectDictionary *dict = [GPBBoolObjectDictionary dictionaryWithObject:@"abc" forKey:YES];
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 1U);
|
||||
XCTAssertEqualObjects([dict valueForKey:YES], @"abc");
|
||||
XCTAssertNil([dict valueForKey:NO]);
|
||||
[dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, id aValue, BOOL *stop) {
|
||||
XCTAssertEqualObjects([dict objectForKey:YES], @"abc");
|
||||
XCTAssertNil([dict objectForKey:NO]);
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(BOOL aKey, id aObject, BOOL *stop) {
|
||||
XCTAssertEqual(aKey, YES);
|
||||
XCTAssertEqualObjects(aValue, @"abc");
|
||||
XCTAssertEqualObjects(aObject, @"abc");
|
||||
XCTAssertNotEqual(stop, NULL);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)testBasics {
|
||||
const BOOL kKeys[] = { YES, NO };
|
||||
const id kValues[] = { @"abc", @"def" };
|
||||
const id kObjects[] = { @"abc", @"def" };
|
||||
GPBBoolObjectDictionary *dict =
|
||||
[[GPBBoolObjectDictionary alloc] initWithValues:kValues
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kObjects)];
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 2U);
|
||||
XCTAssertEqualObjects([dict valueForKey:YES], @"abc");
|
||||
XCTAssertEqualObjects([dict valueForKey:NO], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:YES], @"abc");
|
||||
XCTAssertEqualObjects([dict objectForKey:NO], @"def");
|
||||
|
||||
__block NSUInteger idx = 0;
|
||||
BOOL *seenKeys = malloc(2 * sizeof(BOOL));
|
||||
id *seenValues = malloc(2 * sizeof(id));
|
||||
[dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, id aValue, BOOL *stop) {
|
||||
id *seenObjects = malloc(2 * sizeof(id));
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(BOOL aKey, id aObject, BOOL *stop) {
|
||||
XCTAssertLessThan(idx, 2U);
|
||||
seenKeys[idx] = aKey;
|
||||
seenValues[idx] = aValue;
|
||||
seenObjects[idx] = aObject;
|
||||
XCTAssertNotEqual(stop, NULL);
|
||||
++idx;
|
||||
}];
|
||||
|
@ -2209,18 +2209,18 @@
|
|||
for (int j = 0; (j < 2) && !foundKey; ++j) {
|
||||
if (kKeys[i] == seenKeys[j]) {
|
||||
foundKey = YES;
|
||||
XCTAssertEqualObjects(kValues[i], seenValues[j], @"i = %d, j = %d", i, j);
|
||||
XCTAssertEqualObjects(kObjects[i], seenObjects[j], @"i = %d, j = %d", i, j);
|
||||
}
|
||||
}
|
||||
XCTAssertTrue(foundKey, @"i = %d", i);
|
||||
}
|
||||
free(seenKeys);
|
||||
free(seenValues);
|
||||
free(seenObjects);
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, id aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(BOOL aKey, id aObject, BOOL *stop) {
|
||||
#pragma unused(aKey, aObject)
|
||||
if (idx == 0) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
|
@ -2231,33 +2231,33 @@
|
|||
- (void)testEquality {
|
||||
const BOOL kKeys1[] = { YES, NO };
|
||||
const BOOL kKeys2[] = { NO, YES };
|
||||
const id kValues1[] = { @"abc", @"def" };
|
||||
const id kValues2[] = { @"def", @"abc" };
|
||||
const id kValues3[] = { @"def" };
|
||||
const id kObjects1[] = { @"abc", @"def" };
|
||||
const id kObjects2[] = { @"def", @"abc" };
|
||||
const id kObjects3[] = { @"def" };
|
||||
GPBBoolObjectDictionary *dict1 =
|
||||
[[GPBBoolObjectDictionary alloc] initWithValues:kValues1
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kValues1)];
|
||||
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects1
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kObjects1)];
|
||||
XCTAssertNotNil(dict1);
|
||||
GPBBoolObjectDictionary *dict1prime =
|
||||
[[GPBBoolObjectDictionary alloc] initWithValues:kValues1
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kValues1)];
|
||||
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects1
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kObjects1)];
|
||||
XCTAssertNotNil(dict1prime);
|
||||
GPBBoolObjectDictionary *dict2 =
|
||||
[[GPBBoolObjectDictionary alloc] initWithValues:kValues2
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kValues2)];
|
||||
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects2
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kObjects2)];
|
||||
XCTAssertNotNil(dict2);
|
||||
GPBBoolObjectDictionary *dict3 =
|
||||
[[GPBBoolObjectDictionary alloc] initWithValues:kValues1
|
||||
forKeys:kKeys2
|
||||
count:GPBARRAYSIZE(kValues1)];
|
||||
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects1
|
||||
forKeys:kKeys2
|
||||
count:GPBARRAYSIZE(kObjects1)];
|
||||
XCTAssertNotNil(dict3);
|
||||
GPBBoolObjectDictionary *dict4 =
|
||||
[[GPBBoolObjectDictionary alloc] initWithValues:kValues3
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kValues3)];
|
||||
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects3
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kObjects3)];
|
||||
XCTAssertNotNil(dict4);
|
||||
|
||||
// 1/1Prime should be different objects, but equal.
|
||||
|
@ -2266,10 +2266,10 @@
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different objects; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same objects; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 Fewer pairs; not equal
|
||||
|
@ -2284,11 +2284,11 @@
|
|||
|
||||
- (void)testCopy {
|
||||
const BOOL kKeys[] = { YES, NO };
|
||||
const id kValues[] = { @"abc", @"def" };
|
||||
const id kObjects[] = { @"abc", @"def" };
|
||||
GPBBoolObjectDictionary *dict =
|
||||
[[GPBBoolObjectDictionary alloc] initWithValues:kValues
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kObjects)];
|
||||
XCTAssertNotNil(dict);
|
||||
|
||||
GPBBoolObjectDictionary *dict2 = [dict copy];
|
||||
|
@ -2305,11 +2305,11 @@
|
|||
|
||||
- (void)testDictionaryFromDictionary {
|
||||
const BOOL kKeys[] = { YES, NO };
|
||||
const id kValues[] = { @"abc", @"def" };
|
||||
const id kObjects[] = { @"abc", @"def" };
|
||||
GPBBoolObjectDictionary *dict =
|
||||
[[GPBBoolObjectDictionary alloc] initWithValues:kValues
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kObjects)];
|
||||
XCTAssertNotNil(dict);
|
||||
|
||||
GPBBoolObjectDictionary *dict2 =
|
||||
|
@ -2327,85 +2327,85 @@
|
|||
XCTAssertNotNil(dict);
|
||||
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
[dict setValue:@"abc" forKey:YES];
|
||||
[dict setObject:@"abc" forKey:YES];
|
||||
XCTAssertEqual(dict.count, 1U);
|
||||
|
||||
const BOOL kKeys[] = { NO };
|
||||
const id kValues[] = { @"def" };
|
||||
const id kObjects[] = { @"def" };
|
||||
GPBBoolObjectDictionary *dict2 =
|
||||
[[GPBBoolObjectDictionary alloc] initWithValues:kValues
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kObjects)];
|
||||
XCTAssertNotNil(dict2);
|
||||
[dict addEntriesFromDictionary:dict2];
|
||||
XCTAssertEqual(dict.count, 2U);
|
||||
|
||||
XCTAssertEqualObjects([dict valueForKey:YES], @"abc");
|
||||
XCTAssertEqualObjects([dict valueForKey:NO], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:YES], @"abc");
|
||||
XCTAssertEqualObjects([dict objectForKey:NO], @"def");
|
||||
[dict2 release];
|
||||
}
|
||||
|
||||
- (void)testRemove {
|
||||
const BOOL kKeys[] = { YES, NO};
|
||||
const id kValues[] = { @"abc", @"def" };
|
||||
const id kObjects[] = { @"abc", @"def" };
|
||||
GPBBoolObjectDictionary *dict =
|
||||
[[GPBBoolObjectDictionary alloc] initWithValues:kValues
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kObjects)];
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 2U);
|
||||
|
||||
[dict removeValueForKey:NO];
|
||||
[dict removeObjectForKey:NO];
|
||||
XCTAssertEqual(dict.count, 1U);
|
||||
XCTAssertEqualObjects([dict valueForKey:YES], @"abc");
|
||||
XCTAssertNil([dict valueForKey:NO]);
|
||||
XCTAssertEqualObjects([dict objectForKey:YES], @"abc");
|
||||
XCTAssertNil([dict objectForKey:NO]);
|
||||
|
||||
// Remove again does nothing.
|
||||
[dict removeValueForKey:NO];
|
||||
[dict removeObjectForKey:NO];
|
||||
XCTAssertEqual(dict.count, 1U);
|
||||
XCTAssertEqualObjects([dict valueForKey:YES], @"abc");
|
||||
XCTAssertNil([dict valueForKey:NO]);
|
||||
XCTAssertEqualObjects([dict objectForKey:YES], @"abc");
|
||||
XCTAssertNil([dict objectForKey:NO]);
|
||||
|
||||
[dict removeAll];
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertNil([dict valueForKey:YES]);
|
||||
XCTAssertNil([dict valueForKey:NO]);
|
||||
XCTAssertNil([dict objectForKey:YES]);
|
||||
XCTAssertNil([dict objectForKey:NO]);
|
||||
[dict release];
|
||||
}
|
||||
|
||||
- (void)testInplaceMutation {
|
||||
const BOOL kKeys[] = { YES, NO };
|
||||
const id kValues[] = { @"abc", @"def" };
|
||||
const id kObjects[] = { @"abc", @"def" };
|
||||
GPBBoolObjectDictionary *dict =
|
||||
[[GPBBoolObjectDictionary alloc] initWithValues:kValues
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kObjects)];
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 2U);
|
||||
XCTAssertEqualObjects([dict valueForKey:YES], @"abc");
|
||||
XCTAssertEqualObjects([dict valueForKey:NO], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:YES], @"abc");
|
||||
XCTAssertEqualObjects([dict objectForKey:NO], @"def");
|
||||
|
||||
[dict setValue:@"def" forKey:YES];
|
||||
[dict setObject:@"def" forKey:YES];
|
||||
XCTAssertEqual(dict.count, 2U);
|
||||
XCTAssertEqualObjects([dict valueForKey:YES], @"def");
|
||||
XCTAssertEqualObjects([dict valueForKey:NO], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:YES], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:NO], @"def");
|
||||
|
||||
[dict setValue:@"abc" forKey:NO];
|
||||
[dict setObject:@"abc" forKey:NO];
|
||||
XCTAssertEqual(dict.count, 2U);
|
||||
XCTAssertEqualObjects([dict valueForKey:YES], @"def");
|
||||
XCTAssertEqualObjects([dict valueForKey:NO], @"abc");
|
||||
XCTAssertEqualObjects([dict objectForKey:YES], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:NO], @"abc");
|
||||
|
||||
const BOOL kKeys2[] = { NO, YES };
|
||||
const id kValues2[] = { @"def", @"abc" };
|
||||
const id kObjects2[] = { @"def", @"abc" };
|
||||
GPBBoolObjectDictionary *dict2 =
|
||||
[[GPBBoolObjectDictionary alloc] initWithValues:kValues2
|
||||
forKeys:kKeys2
|
||||
count:GPBARRAYSIZE(kValues2)];
|
||||
[[GPBBoolObjectDictionary alloc] initWithObjects:kObjects2
|
||||
forKeys:kKeys2
|
||||
count:GPBARRAYSIZE(kObjects2)];
|
||||
XCTAssertNotNil(dict2);
|
||||
[dict addEntriesFromDictionary:dict2];
|
||||
XCTAssertEqual(dict.count, 2U);
|
||||
XCTAssertEqualObjects([dict valueForKey:YES], @"abc");
|
||||
XCTAssertEqualObjects([dict valueForKey:NO], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:YES], @"abc");
|
||||
XCTAssertEqualObjects([dict objectForKey:NO], @"def");
|
||||
|
||||
[dict2 release];
|
||||
[dict release];
|
||||
|
|
|
@ -211,10 +211,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -568,10 +568,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -925,10 +925,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -1282,10 +1282,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -1639,10 +1639,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -1996,10 +1996,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -2353,10 +2353,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -2710,10 +2710,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -3071,10 +3071,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -3366,48 +3366,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
GPBInt32ObjectDictionary *dict = [[GPBInt32ObjectDictionary alloc] init];
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertNil([dict valueForKey:11]);
|
||||
[dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, id aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTAssertNil([dict objectForKey:11]);
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(int32_t aKey, id aObject, BOOL *stop) {
|
||||
#pragma unused(aKey, aObject, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
}
|
||||
|
||||
- (void)testOne {
|
||||
GPBInt32ObjectDictionary *dict = [GPBInt32ObjectDictionary dictionaryWithValue:@"abc" forKey:11];
|
||||
GPBInt32ObjectDictionary *dict = [GPBInt32ObjectDictionary dictionaryWithObject:@"abc" forKey:11];
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 1U);
|
||||
XCTAssertEqualObjects([dict valueForKey:11], @"abc");
|
||||
XCTAssertNil([dict valueForKey:12]);
|
||||
[dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, id aValue, BOOL *stop) {
|
||||
XCTAssertEqualObjects([dict objectForKey:11], @"abc");
|
||||
XCTAssertNil([dict objectForKey:12]);
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(int32_t aKey, id aObject, BOOL *stop) {
|
||||
XCTAssertEqual(aKey, 11);
|
||||
XCTAssertEqualObjects(aValue, @"abc");
|
||||
XCTAssertEqualObjects(aObject, @"abc");
|
||||
XCTAssertNotEqual(stop, NULL);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)testBasics {
|
||||
const int32_t kKeys[] = { 11, 12, 13 };
|
||||
const id kValues[] = { @"abc", @"def", @"ghi" };
|
||||
const id kObjects[] = { @"abc", @"def", @"ghi" };
|
||||
GPBInt32ObjectDictionary *dict =
|
||||
[[GPBInt32ObjectDictionary alloc] initWithValues:kValues
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kObjects)];
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 3U);
|
||||
XCTAssertEqualObjects([dict valueForKey:11], @"abc");
|
||||
XCTAssertEqualObjects([dict valueForKey:12], @"def");
|
||||
XCTAssertEqualObjects([dict valueForKey:13], @"ghi");
|
||||
XCTAssertNil([dict valueForKey:14]);
|
||||
XCTAssertEqualObjects([dict objectForKey:11], @"abc");
|
||||
XCTAssertEqualObjects([dict objectForKey:12], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:13], @"ghi");
|
||||
XCTAssertNil([dict objectForKey:14]);
|
||||
|
||||
__block NSUInteger idx = 0;
|
||||
int32_t *seenKeys = malloc(3 * sizeof(int32_t));
|
||||
id *seenValues = malloc(3 * sizeof(id));
|
||||
[dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, id aValue, BOOL *stop) {
|
||||
id *seenObjects = malloc(3 * sizeof(id));
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(int32_t aKey, id aObject, BOOL *stop) {
|
||||
XCTAssertLessThan(idx, 3U);
|
||||
seenKeys[idx] = aKey;
|
||||
seenValues[idx] = aValue;
|
||||
seenObjects[idx] = aObject;
|
||||
XCTAssertNotEqual(stop, NULL);
|
||||
++idx;
|
||||
}];
|
||||
|
@ -3416,18 +3416,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
for (int j = 0; (j < 3) && !foundKey; ++j) {
|
||||
if (kKeys[i] == seenKeys[j]) {
|
||||
foundKey = YES;
|
||||
XCTAssertEqualObjects(kValues[i], seenValues[j], @"i = %d, j = %d", i, j);
|
||||
XCTAssertEqualObjects(kObjects[i], seenObjects[j], @"i = %d, j = %d", i, j);
|
||||
}
|
||||
}
|
||||
XCTAssertTrue(foundKey, @"i = %d", i);
|
||||
}
|
||||
free(seenKeys);
|
||||
free(seenValues);
|
||||
free(seenObjects);
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, id aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(int32_t aKey, id aObject, BOOL *stop) {
|
||||
#pragma unused(aKey, aObject)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
|
@ -3438,33 +3438,33 @@ 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 kValues1[] = { @"abc", @"def", @"ghi" };
|
||||
const id kValues2[] = { @"abc", @"jkl", @"ghi" };
|
||||
const id kValues3[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
const id kObjects1[] = { @"abc", @"def", @"ghi" };
|
||||
const id kObjects2[] = { @"abc", @"jkl", @"ghi" };
|
||||
const id kObjects3[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
GPBInt32ObjectDictionary *dict1 =
|
||||
[[GPBInt32ObjectDictionary alloc] initWithValues:kValues1
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kValues1)];
|
||||
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects1
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kObjects1)];
|
||||
XCTAssertNotNil(dict1);
|
||||
GPBInt32ObjectDictionary *dict1prime =
|
||||
[[GPBInt32ObjectDictionary alloc] initWithValues:kValues1
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kValues1)];
|
||||
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects1
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kObjects1)];
|
||||
XCTAssertNotNil(dict1prime);
|
||||
GPBInt32ObjectDictionary *dict2 =
|
||||
[[GPBInt32ObjectDictionary alloc] initWithValues:kValues2
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kValues2)];
|
||||
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects2
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kObjects2)];
|
||||
XCTAssertNotNil(dict2);
|
||||
GPBInt32ObjectDictionary *dict3 =
|
||||
[[GPBInt32ObjectDictionary alloc] initWithValues:kValues1
|
||||
forKeys:kKeys2
|
||||
count:GPBARRAYSIZE(kValues1)];
|
||||
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects1
|
||||
forKeys:kKeys2
|
||||
count:GPBARRAYSIZE(kObjects1)];
|
||||
XCTAssertNotNil(dict3);
|
||||
GPBInt32ObjectDictionary *dict4 =
|
||||
[[GPBInt32ObjectDictionary alloc] initWithValues:kValues3
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kValues3)];
|
||||
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects3
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kObjects3)];
|
||||
XCTAssertNotNil(dict4);
|
||||
|
||||
// 1/1Prime should be different objects, but equal.
|
||||
|
@ -3473,10 +3473,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different objects; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same objects; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -3491,11 +3491,11 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
|
||||
- (void)testCopy {
|
||||
const int32_t kKeys[] = { 11, 12, 13, 14 };
|
||||
const id kValues[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
GPBInt32ObjectDictionary *dict =
|
||||
[[GPBInt32ObjectDictionary alloc] initWithValues:kValues
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kObjects)];
|
||||
XCTAssertNotNil(dict);
|
||||
|
||||
GPBInt32ObjectDictionary *dict2 = [dict copy];
|
||||
|
@ -3512,11 +3512,11 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
|
||||
- (void)testDictionaryFromDictionary {
|
||||
const int32_t kKeys[] = { 11, 12, 13, 14 };
|
||||
const id kValues[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
GPBInt32ObjectDictionary *dict =
|
||||
[[GPBInt32ObjectDictionary alloc] initWithValues:kValues
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kObjects)];
|
||||
XCTAssertNotNil(dict);
|
||||
|
||||
GPBInt32ObjectDictionary *dict2 =
|
||||
|
@ -3534,108 +3534,108 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
XCTAssertNotNil(dict);
|
||||
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
[dict setValue:@"abc" forKey:11];
|
||||
[dict setObject:@"abc" forKey:11];
|
||||
XCTAssertEqual(dict.count, 1U);
|
||||
|
||||
const int32_t kKeys[] = { 12, 13, 14 };
|
||||
const id kValues[] = { @"def", @"ghi", @"jkl" };
|
||||
const id kObjects[] = { @"def", @"ghi", @"jkl" };
|
||||
GPBInt32ObjectDictionary *dict2 =
|
||||
[[GPBInt32ObjectDictionary alloc] initWithValues:kValues
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kObjects)];
|
||||
XCTAssertNotNil(dict2);
|
||||
[dict addEntriesFromDictionary:dict2];
|
||||
XCTAssertEqual(dict.count, 4U);
|
||||
|
||||
XCTAssertEqualObjects([dict valueForKey:11], @"abc");
|
||||
XCTAssertEqualObjects([dict valueForKey:12], @"def");
|
||||
XCTAssertEqualObjects([dict valueForKey:13], @"ghi");
|
||||
XCTAssertEqualObjects([dict valueForKey:14], @"jkl");
|
||||
XCTAssertEqualObjects([dict objectForKey:11], @"abc");
|
||||
XCTAssertEqualObjects([dict objectForKey:12], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:13], @"ghi");
|
||||
XCTAssertEqualObjects([dict objectForKey:14], @"jkl");
|
||||
[dict2 release];
|
||||
}
|
||||
|
||||
- (void)testRemove {
|
||||
const int32_t kKeys[] = { 11, 12, 13, 14 };
|
||||
const id kValues[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
GPBInt32ObjectDictionary *dict =
|
||||
[[GPBInt32ObjectDictionary alloc] initWithValues:kValues
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kObjects)];
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 4U);
|
||||
|
||||
[dict removeValueForKey:12];
|
||||
[dict removeObjectForKey:12];
|
||||
XCTAssertEqual(dict.count, 3U);
|
||||
XCTAssertEqualObjects([dict valueForKey:11], @"abc");
|
||||
XCTAssertNil([dict valueForKey:12]);
|
||||
XCTAssertEqualObjects([dict valueForKey:13], @"ghi");
|
||||
XCTAssertEqualObjects([dict valueForKey:14], @"jkl");
|
||||
XCTAssertEqualObjects([dict objectForKey:11], @"abc");
|
||||
XCTAssertNil([dict objectForKey:12]);
|
||||
XCTAssertEqualObjects([dict objectForKey:13], @"ghi");
|
||||
XCTAssertEqualObjects([dict objectForKey:14], @"jkl");
|
||||
|
||||
// Remove again does nothing.
|
||||
[dict removeValueForKey:12];
|
||||
[dict removeObjectForKey:12];
|
||||
XCTAssertEqual(dict.count, 3U);
|
||||
XCTAssertEqualObjects([dict valueForKey:11], @"abc");
|
||||
XCTAssertNil([dict valueForKey:12]);
|
||||
XCTAssertEqualObjects([dict valueForKey:13], @"ghi");
|
||||
XCTAssertEqualObjects([dict valueForKey:14], @"jkl");
|
||||
XCTAssertEqualObjects([dict objectForKey:11], @"abc");
|
||||
XCTAssertNil([dict objectForKey:12]);
|
||||
XCTAssertEqualObjects([dict objectForKey:13], @"ghi");
|
||||
XCTAssertEqualObjects([dict objectForKey:14], @"jkl");
|
||||
|
||||
[dict removeValueForKey:14];
|
||||
[dict removeObjectForKey:14];
|
||||
XCTAssertEqual(dict.count, 2U);
|
||||
XCTAssertEqualObjects([dict valueForKey:11], @"abc");
|
||||
XCTAssertNil([dict valueForKey:12]);
|
||||
XCTAssertEqualObjects([dict valueForKey:13], @"ghi");
|
||||
XCTAssertNil([dict valueForKey:14]);
|
||||
XCTAssertEqualObjects([dict objectForKey:11], @"abc");
|
||||
XCTAssertNil([dict objectForKey:12]);
|
||||
XCTAssertEqualObjects([dict objectForKey:13], @"ghi");
|
||||
XCTAssertNil([dict objectForKey:14]);
|
||||
|
||||
[dict removeAll];
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertNil([dict valueForKey:11]);
|
||||
XCTAssertNil([dict valueForKey:12]);
|
||||
XCTAssertNil([dict valueForKey:13]);
|
||||
XCTAssertNil([dict valueForKey:14]);
|
||||
XCTAssertNil([dict objectForKey:11]);
|
||||
XCTAssertNil([dict objectForKey:12]);
|
||||
XCTAssertNil([dict objectForKey:13]);
|
||||
XCTAssertNil([dict objectForKey:14]);
|
||||
[dict release];
|
||||
}
|
||||
|
||||
- (void)testInplaceMutation {
|
||||
const int32_t kKeys[] = { 11, 12, 13, 14 };
|
||||
const id kValues[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
GPBInt32ObjectDictionary *dict =
|
||||
[[GPBInt32ObjectDictionary alloc] initWithValues:kValues
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kObjects)];
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 4U);
|
||||
XCTAssertEqualObjects([dict valueForKey:11], @"abc");
|
||||
XCTAssertEqualObjects([dict valueForKey:12], @"def");
|
||||
XCTAssertEqualObjects([dict valueForKey:13], @"ghi");
|
||||
XCTAssertEqualObjects([dict valueForKey:14], @"jkl");
|
||||
XCTAssertEqualObjects([dict objectForKey:11], @"abc");
|
||||
XCTAssertEqualObjects([dict objectForKey:12], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:13], @"ghi");
|
||||
XCTAssertEqualObjects([dict objectForKey:14], @"jkl");
|
||||
|
||||
[dict setValue:@"jkl" forKey:11];
|
||||
[dict setObject:@"jkl" forKey:11];
|
||||
XCTAssertEqual(dict.count, 4U);
|
||||
XCTAssertEqualObjects([dict valueForKey:11], @"jkl");
|
||||
XCTAssertEqualObjects([dict valueForKey:12], @"def");
|
||||
XCTAssertEqualObjects([dict valueForKey:13], @"ghi");
|
||||
XCTAssertEqualObjects([dict valueForKey:14], @"jkl");
|
||||
XCTAssertEqualObjects([dict objectForKey:11], @"jkl");
|
||||
XCTAssertEqualObjects([dict objectForKey:12], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:13], @"ghi");
|
||||
XCTAssertEqualObjects([dict objectForKey:14], @"jkl");
|
||||
|
||||
[dict setValue:@"def" forKey:14];
|
||||
[dict setObject:@"def" forKey:14];
|
||||
XCTAssertEqual(dict.count, 4U);
|
||||
XCTAssertEqualObjects([dict valueForKey:11], @"jkl");
|
||||
XCTAssertEqualObjects([dict valueForKey:12], @"def");
|
||||
XCTAssertEqualObjects([dict valueForKey:13], @"ghi");
|
||||
XCTAssertEqualObjects([dict valueForKey:14], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:11], @"jkl");
|
||||
XCTAssertEqualObjects([dict objectForKey:12], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:13], @"ghi");
|
||||
XCTAssertEqualObjects([dict objectForKey:14], @"def");
|
||||
|
||||
const int32_t kKeys2[] = { 12, 13 };
|
||||
const id kValues2[] = { @"ghi", @"abc" };
|
||||
const id kObjects2[] = { @"ghi", @"abc" };
|
||||
GPBInt32ObjectDictionary *dict2 =
|
||||
[[GPBInt32ObjectDictionary alloc] initWithValues:kValues2
|
||||
forKeys:kKeys2
|
||||
count:GPBARRAYSIZE(kValues2)];
|
||||
[[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects2
|
||||
forKeys:kKeys2
|
||||
count:GPBARRAYSIZE(kObjects2)];
|
||||
XCTAssertNotNil(dict2);
|
||||
[dict addEntriesFromDictionary:dict2];
|
||||
XCTAssertEqual(dict.count, 4U);
|
||||
XCTAssertEqualObjects([dict valueForKey:11], @"jkl");
|
||||
XCTAssertEqualObjects([dict valueForKey:12], @"ghi");
|
||||
XCTAssertEqualObjects([dict valueForKey:13], @"abc");
|
||||
XCTAssertEqualObjects([dict valueForKey:14], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:11], @"jkl");
|
||||
XCTAssertEqualObjects([dict objectForKey:12], @"ghi");
|
||||
XCTAssertEqualObjects([dict objectForKey:13], @"abc");
|
||||
XCTAssertEqualObjects([dict objectForKey:14], @"def");
|
||||
|
||||
[dict2 release];
|
||||
[dict release];
|
||||
|
|
|
@ -211,10 +211,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -568,10 +568,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -925,10 +925,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -1282,10 +1282,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -1639,10 +1639,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -1996,10 +1996,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -2353,10 +2353,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -2710,10 +2710,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -3071,10 +3071,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -3366,48 +3366,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
GPBInt64ObjectDictionary *dict = [[GPBInt64ObjectDictionary alloc] init];
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertNil([dict valueForKey:21LL]);
|
||||
[dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, id aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTAssertNil([dict objectForKey:21LL]);
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(int64_t aKey, id aObject, BOOL *stop) {
|
||||
#pragma unused(aKey, aObject, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
}
|
||||
|
||||
- (void)testOne {
|
||||
GPBInt64ObjectDictionary *dict = [GPBInt64ObjectDictionary dictionaryWithValue:@"abc" forKey:21LL];
|
||||
GPBInt64ObjectDictionary *dict = [GPBInt64ObjectDictionary dictionaryWithObject:@"abc" forKey:21LL];
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 1U);
|
||||
XCTAssertEqualObjects([dict valueForKey:21LL], @"abc");
|
||||
XCTAssertNil([dict valueForKey:22LL]);
|
||||
[dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, id aValue, BOOL *stop) {
|
||||
XCTAssertEqualObjects([dict objectForKey:21LL], @"abc");
|
||||
XCTAssertNil([dict objectForKey:22LL]);
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(int64_t aKey, id aObject, BOOL *stop) {
|
||||
XCTAssertEqual(aKey, 21LL);
|
||||
XCTAssertEqualObjects(aValue, @"abc");
|
||||
XCTAssertEqualObjects(aObject, @"abc");
|
||||
XCTAssertNotEqual(stop, NULL);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)testBasics {
|
||||
const int64_t kKeys[] = { 21LL, 22LL, 23LL };
|
||||
const id kValues[] = { @"abc", @"def", @"ghi" };
|
||||
const id kObjects[] = { @"abc", @"def", @"ghi" };
|
||||
GPBInt64ObjectDictionary *dict =
|
||||
[[GPBInt64ObjectDictionary alloc] initWithValues:kValues
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kObjects)];
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 3U);
|
||||
XCTAssertEqualObjects([dict valueForKey:21LL], @"abc");
|
||||
XCTAssertEqualObjects([dict valueForKey:22LL], @"def");
|
||||
XCTAssertEqualObjects([dict valueForKey:23LL], @"ghi");
|
||||
XCTAssertNil([dict valueForKey:24LL]);
|
||||
XCTAssertEqualObjects([dict objectForKey:21LL], @"abc");
|
||||
XCTAssertEqualObjects([dict objectForKey:22LL], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:23LL], @"ghi");
|
||||
XCTAssertNil([dict objectForKey:24LL]);
|
||||
|
||||
__block NSUInteger idx = 0;
|
||||
int64_t *seenKeys = malloc(3 * sizeof(int64_t));
|
||||
id *seenValues = malloc(3 * sizeof(id));
|
||||
[dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, id aValue, BOOL *stop) {
|
||||
id *seenObjects = malloc(3 * sizeof(id));
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(int64_t aKey, id aObject, BOOL *stop) {
|
||||
XCTAssertLessThan(idx, 3U);
|
||||
seenKeys[idx] = aKey;
|
||||
seenValues[idx] = aValue;
|
||||
seenObjects[idx] = aObject;
|
||||
XCTAssertNotEqual(stop, NULL);
|
||||
++idx;
|
||||
}];
|
||||
|
@ -3416,18 +3416,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
for (int j = 0; (j < 3) && !foundKey; ++j) {
|
||||
if (kKeys[i] == seenKeys[j]) {
|
||||
foundKey = YES;
|
||||
XCTAssertEqualObjects(kValues[i], seenValues[j], @"i = %d, j = %d", i, j);
|
||||
XCTAssertEqualObjects(kObjects[i], seenObjects[j], @"i = %d, j = %d", i, j);
|
||||
}
|
||||
}
|
||||
XCTAssertTrue(foundKey, @"i = %d", i);
|
||||
}
|
||||
free(seenKeys);
|
||||
free(seenValues);
|
||||
free(seenObjects);
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, id aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(int64_t aKey, id aObject, BOOL *stop) {
|
||||
#pragma unused(aKey, aObject)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
|
@ -3438,33 +3438,33 @@ 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 kValues1[] = { @"abc", @"def", @"ghi" };
|
||||
const id kValues2[] = { @"abc", @"jkl", @"ghi" };
|
||||
const id kValues3[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
const id kObjects1[] = { @"abc", @"def", @"ghi" };
|
||||
const id kObjects2[] = { @"abc", @"jkl", @"ghi" };
|
||||
const id kObjects3[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
GPBInt64ObjectDictionary *dict1 =
|
||||
[[GPBInt64ObjectDictionary alloc] initWithValues:kValues1
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kValues1)];
|
||||
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects1
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kObjects1)];
|
||||
XCTAssertNotNil(dict1);
|
||||
GPBInt64ObjectDictionary *dict1prime =
|
||||
[[GPBInt64ObjectDictionary alloc] initWithValues:kValues1
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kValues1)];
|
||||
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects1
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kObjects1)];
|
||||
XCTAssertNotNil(dict1prime);
|
||||
GPBInt64ObjectDictionary *dict2 =
|
||||
[[GPBInt64ObjectDictionary alloc] initWithValues:kValues2
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kValues2)];
|
||||
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects2
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kObjects2)];
|
||||
XCTAssertNotNil(dict2);
|
||||
GPBInt64ObjectDictionary *dict3 =
|
||||
[[GPBInt64ObjectDictionary alloc] initWithValues:kValues1
|
||||
forKeys:kKeys2
|
||||
count:GPBARRAYSIZE(kValues1)];
|
||||
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects1
|
||||
forKeys:kKeys2
|
||||
count:GPBARRAYSIZE(kObjects1)];
|
||||
XCTAssertNotNil(dict3);
|
||||
GPBInt64ObjectDictionary *dict4 =
|
||||
[[GPBInt64ObjectDictionary alloc] initWithValues:kValues3
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kValues3)];
|
||||
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects3
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kObjects3)];
|
||||
XCTAssertNotNil(dict4);
|
||||
|
||||
// 1/1Prime should be different objects, but equal.
|
||||
|
@ -3473,10 +3473,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different objects; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same objects; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -3491,11 +3491,11 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
|
||||
- (void)testCopy {
|
||||
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
|
||||
const id kValues[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
GPBInt64ObjectDictionary *dict =
|
||||
[[GPBInt64ObjectDictionary alloc] initWithValues:kValues
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kObjects)];
|
||||
XCTAssertNotNil(dict);
|
||||
|
||||
GPBInt64ObjectDictionary *dict2 = [dict copy];
|
||||
|
@ -3512,11 +3512,11 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
|
||||
- (void)testDictionaryFromDictionary {
|
||||
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
|
||||
const id kValues[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
GPBInt64ObjectDictionary *dict =
|
||||
[[GPBInt64ObjectDictionary alloc] initWithValues:kValues
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kObjects)];
|
||||
XCTAssertNotNil(dict);
|
||||
|
||||
GPBInt64ObjectDictionary *dict2 =
|
||||
|
@ -3534,108 +3534,108 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
XCTAssertNotNil(dict);
|
||||
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
[dict setValue:@"abc" forKey:21LL];
|
||||
[dict setObject:@"abc" forKey:21LL];
|
||||
XCTAssertEqual(dict.count, 1U);
|
||||
|
||||
const int64_t kKeys[] = { 22LL, 23LL, 24LL };
|
||||
const id kValues[] = { @"def", @"ghi", @"jkl" };
|
||||
const id kObjects[] = { @"def", @"ghi", @"jkl" };
|
||||
GPBInt64ObjectDictionary *dict2 =
|
||||
[[GPBInt64ObjectDictionary alloc] initWithValues:kValues
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kObjects)];
|
||||
XCTAssertNotNil(dict2);
|
||||
[dict addEntriesFromDictionary:dict2];
|
||||
XCTAssertEqual(dict.count, 4U);
|
||||
|
||||
XCTAssertEqualObjects([dict valueForKey:21LL], @"abc");
|
||||
XCTAssertEqualObjects([dict valueForKey:22LL], @"def");
|
||||
XCTAssertEqualObjects([dict valueForKey:23LL], @"ghi");
|
||||
XCTAssertEqualObjects([dict valueForKey:24LL], @"jkl");
|
||||
XCTAssertEqualObjects([dict objectForKey:21LL], @"abc");
|
||||
XCTAssertEqualObjects([dict objectForKey:22LL], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:23LL], @"ghi");
|
||||
XCTAssertEqualObjects([dict objectForKey:24LL], @"jkl");
|
||||
[dict2 release];
|
||||
}
|
||||
|
||||
- (void)testRemove {
|
||||
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
|
||||
const id kValues[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
GPBInt64ObjectDictionary *dict =
|
||||
[[GPBInt64ObjectDictionary alloc] initWithValues:kValues
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kObjects)];
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 4U);
|
||||
|
||||
[dict removeValueForKey:22LL];
|
||||
[dict removeObjectForKey:22LL];
|
||||
XCTAssertEqual(dict.count, 3U);
|
||||
XCTAssertEqualObjects([dict valueForKey:21LL], @"abc");
|
||||
XCTAssertNil([dict valueForKey:22LL]);
|
||||
XCTAssertEqualObjects([dict valueForKey:23LL], @"ghi");
|
||||
XCTAssertEqualObjects([dict valueForKey:24LL], @"jkl");
|
||||
XCTAssertEqualObjects([dict objectForKey:21LL], @"abc");
|
||||
XCTAssertNil([dict objectForKey:22LL]);
|
||||
XCTAssertEqualObjects([dict objectForKey:23LL], @"ghi");
|
||||
XCTAssertEqualObjects([dict objectForKey:24LL], @"jkl");
|
||||
|
||||
// Remove again does nothing.
|
||||
[dict removeValueForKey:22LL];
|
||||
[dict removeObjectForKey:22LL];
|
||||
XCTAssertEqual(dict.count, 3U);
|
||||
XCTAssertEqualObjects([dict valueForKey:21LL], @"abc");
|
||||
XCTAssertNil([dict valueForKey:22LL]);
|
||||
XCTAssertEqualObjects([dict valueForKey:23LL], @"ghi");
|
||||
XCTAssertEqualObjects([dict valueForKey:24LL], @"jkl");
|
||||
XCTAssertEqualObjects([dict objectForKey:21LL], @"abc");
|
||||
XCTAssertNil([dict objectForKey:22LL]);
|
||||
XCTAssertEqualObjects([dict objectForKey:23LL], @"ghi");
|
||||
XCTAssertEqualObjects([dict objectForKey:24LL], @"jkl");
|
||||
|
||||
[dict removeValueForKey:24LL];
|
||||
[dict removeObjectForKey:24LL];
|
||||
XCTAssertEqual(dict.count, 2U);
|
||||
XCTAssertEqualObjects([dict valueForKey:21LL], @"abc");
|
||||
XCTAssertNil([dict valueForKey:22LL]);
|
||||
XCTAssertEqualObjects([dict valueForKey:23LL], @"ghi");
|
||||
XCTAssertNil([dict valueForKey:24LL]);
|
||||
XCTAssertEqualObjects([dict objectForKey:21LL], @"abc");
|
||||
XCTAssertNil([dict objectForKey:22LL]);
|
||||
XCTAssertEqualObjects([dict objectForKey:23LL], @"ghi");
|
||||
XCTAssertNil([dict objectForKey:24LL]);
|
||||
|
||||
[dict removeAll];
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertNil([dict valueForKey:21LL]);
|
||||
XCTAssertNil([dict valueForKey:22LL]);
|
||||
XCTAssertNil([dict valueForKey:23LL]);
|
||||
XCTAssertNil([dict valueForKey:24LL]);
|
||||
XCTAssertNil([dict objectForKey:21LL]);
|
||||
XCTAssertNil([dict objectForKey:22LL]);
|
||||
XCTAssertNil([dict objectForKey:23LL]);
|
||||
XCTAssertNil([dict objectForKey:24LL]);
|
||||
[dict release];
|
||||
}
|
||||
|
||||
- (void)testInplaceMutation {
|
||||
const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL };
|
||||
const id kValues[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
GPBInt64ObjectDictionary *dict =
|
||||
[[GPBInt64ObjectDictionary alloc] initWithValues:kValues
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kObjects)];
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 4U);
|
||||
XCTAssertEqualObjects([dict valueForKey:21LL], @"abc");
|
||||
XCTAssertEqualObjects([dict valueForKey:22LL], @"def");
|
||||
XCTAssertEqualObjects([dict valueForKey:23LL], @"ghi");
|
||||
XCTAssertEqualObjects([dict valueForKey:24LL], @"jkl");
|
||||
XCTAssertEqualObjects([dict objectForKey:21LL], @"abc");
|
||||
XCTAssertEqualObjects([dict objectForKey:22LL], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:23LL], @"ghi");
|
||||
XCTAssertEqualObjects([dict objectForKey:24LL], @"jkl");
|
||||
|
||||
[dict setValue:@"jkl" forKey:21LL];
|
||||
[dict setObject:@"jkl" forKey:21LL];
|
||||
XCTAssertEqual(dict.count, 4U);
|
||||
XCTAssertEqualObjects([dict valueForKey:21LL], @"jkl");
|
||||
XCTAssertEqualObjects([dict valueForKey:22LL], @"def");
|
||||
XCTAssertEqualObjects([dict valueForKey:23LL], @"ghi");
|
||||
XCTAssertEqualObjects([dict valueForKey:24LL], @"jkl");
|
||||
XCTAssertEqualObjects([dict objectForKey:21LL], @"jkl");
|
||||
XCTAssertEqualObjects([dict objectForKey:22LL], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:23LL], @"ghi");
|
||||
XCTAssertEqualObjects([dict objectForKey:24LL], @"jkl");
|
||||
|
||||
[dict setValue:@"def" forKey:24LL];
|
||||
[dict setObject:@"def" forKey:24LL];
|
||||
XCTAssertEqual(dict.count, 4U);
|
||||
XCTAssertEqualObjects([dict valueForKey:21LL], @"jkl");
|
||||
XCTAssertEqualObjects([dict valueForKey:22LL], @"def");
|
||||
XCTAssertEqualObjects([dict valueForKey:23LL], @"ghi");
|
||||
XCTAssertEqualObjects([dict valueForKey:24LL], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:21LL], @"jkl");
|
||||
XCTAssertEqualObjects([dict objectForKey:22LL], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:23LL], @"ghi");
|
||||
XCTAssertEqualObjects([dict objectForKey:24LL], @"def");
|
||||
|
||||
const int64_t kKeys2[] = { 22LL, 23LL };
|
||||
const id kValues2[] = { @"ghi", @"abc" };
|
||||
const id kObjects2[] = { @"ghi", @"abc" };
|
||||
GPBInt64ObjectDictionary *dict2 =
|
||||
[[GPBInt64ObjectDictionary alloc] initWithValues:kValues2
|
||||
forKeys:kKeys2
|
||||
count:GPBARRAYSIZE(kValues2)];
|
||||
[[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects2
|
||||
forKeys:kKeys2
|
||||
count:GPBARRAYSIZE(kObjects2)];
|
||||
XCTAssertNotNil(dict2);
|
||||
[dict addEntriesFromDictionary:dict2];
|
||||
XCTAssertEqual(dict.count, 4U);
|
||||
XCTAssertEqualObjects([dict valueForKey:21LL], @"jkl");
|
||||
XCTAssertEqualObjects([dict valueForKey:22LL], @"ghi");
|
||||
XCTAssertEqualObjects([dict valueForKey:23LL], @"abc");
|
||||
XCTAssertEqualObjects([dict valueForKey:24LL], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:21LL], @"jkl");
|
||||
XCTAssertEqualObjects([dict objectForKey:22LL], @"ghi");
|
||||
XCTAssertEqualObjects([dict objectForKey:23LL], @"abc");
|
||||
XCTAssertEqualObjects([dict objectForKey:24LL], @"def");
|
||||
|
||||
[dict2 release];
|
||||
[dict release];
|
||||
|
|
|
@ -211,10 +211,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -568,10 +568,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -925,10 +925,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -1282,10 +1282,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -1639,10 +1639,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -1996,10 +1996,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -2353,10 +2353,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -2710,10 +2710,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -3071,10 +3071,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
|
|
@ -211,10 +211,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -568,10 +568,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -925,10 +925,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -1282,10 +1282,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -1639,10 +1639,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -1996,10 +1996,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -2353,10 +2353,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -2710,10 +2710,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -3071,10 +3071,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -3366,48 +3366,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
GPBUInt32ObjectDictionary *dict = [[GPBUInt32ObjectDictionary alloc] init];
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertNil([dict valueForKey:1U]);
|
||||
[dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, id aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTAssertNil([dict objectForKey:1U]);
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(uint32_t aKey, id aObject, BOOL *stop) {
|
||||
#pragma unused(aKey, aObject, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
}
|
||||
|
||||
- (void)testOne {
|
||||
GPBUInt32ObjectDictionary *dict = [GPBUInt32ObjectDictionary dictionaryWithValue:@"abc" forKey:1U];
|
||||
GPBUInt32ObjectDictionary *dict = [GPBUInt32ObjectDictionary dictionaryWithObject:@"abc" forKey:1U];
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 1U);
|
||||
XCTAssertEqualObjects([dict valueForKey:1U], @"abc");
|
||||
XCTAssertNil([dict valueForKey:2U]);
|
||||
[dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, id aValue, BOOL *stop) {
|
||||
XCTAssertEqualObjects([dict objectForKey:1U], @"abc");
|
||||
XCTAssertNil([dict objectForKey:2U]);
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(uint32_t aKey, id aObject, BOOL *stop) {
|
||||
XCTAssertEqual(aKey, 1U);
|
||||
XCTAssertEqualObjects(aValue, @"abc");
|
||||
XCTAssertEqualObjects(aObject, @"abc");
|
||||
XCTAssertNotEqual(stop, NULL);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)testBasics {
|
||||
const uint32_t kKeys[] = { 1U, 2U, 3U };
|
||||
const id kValues[] = { @"abc", @"def", @"ghi" };
|
||||
const id kObjects[] = { @"abc", @"def", @"ghi" };
|
||||
GPBUInt32ObjectDictionary *dict =
|
||||
[[GPBUInt32ObjectDictionary alloc] initWithValues:kValues
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kObjects)];
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 3U);
|
||||
XCTAssertEqualObjects([dict valueForKey:1U], @"abc");
|
||||
XCTAssertEqualObjects([dict valueForKey:2U], @"def");
|
||||
XCTAssertEqualObjects([dict valueForKey:3U], @"ghi");
|
||||
XCTAssertNil([dict valueForKey:4U]);
|
||||
XCTAssertEqualObjects([dict objectForKey:1U], @"abc");
|
||||
XCTAssertEqualObjects([dict objectForKey:2U], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:3U], @"ghi");
|
||||
XCTAssertNil([dict objectForKey:4U]);
|
||||
|
||||
__block NSUInteger idx = 0;
|
||||
uint32_t *seenKeys = malloc(3 * sizeof(uint32_t));
|
||||
id *seenValues = malloc(3 * sizeof(id));
|
||||
[dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, id aValue, BOOL *stop) {
|
||||
id *seenObjects = malloc(3 * sizeof(id));
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(uint32_t aKey, id aObject, BOOL *stop) {
|
||||
XCTAssertLessThan(idx, 3U);
|
||||
seenKeys[idx] = aKey;
|
||||
seenValues[idx] = aValue;
|
||||
seenObjects[idx] = aObject;
|
||||
XCTAssertNotEqual(stop, NULL);
|
||||
++idx;
|
||||
}];
|
||||
|
@ -3416,18 +3416,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
for (int j = 0; (j < 3) && !foundKey; ++j) {
|
||||
if (kKeys[i] == seenKeys[j]) {
|
||||
foundKey = YES;
|
||||
XCTAssertEqualObjects(kValues[i], seenValues[j], @"i = %d, j = %d", i, j);
|
||||
XCTAssertEqualObjects(kObjects[i], seenObjects[j], @"i = %d, j = %d", i, j);
|
||||
}
|
||||
}
|
||||
XCTAssertTrue(foundKey, @"i = %d", i);
|
||||
}
|
||||
free(seenKeys);
|
||||
free(seenValues);
|
||||
free(seenObjects);
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, id aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(uint32_t aKey, id aObject, BOOL *stop) {
|
||||
#pragma unused(aKey, aObject)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
|
@ -3438,33 +3438,33 @@ 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 kValues1[] = { @"abc", @"def", @"ghi" };
|
||||
const id kValues2[] = { @"abc", @"jkl", @"ghi" };
|
||||
const id kValues3[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
const id kObjects1[] = { @"abc", @"def", @"ghi" };
|
||||
const id kObjects2[] = { @"abc", @"jkl", @"ghi" };
|
||||
const id kObjects3[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
GPBUInt32ObjectDictionary *dict1 =
|
||||
[[GPBUInt32ObjectDictionary alloc] initWithValues:kValues1
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kValues1)];
|
||||
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects1
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kObjects1)];
|
||||
XCTAssertNotNil(dict1);
|
||||
GPBUInt32ObjectDictionary *dict1prime =
|
||||
[[GPBUInt32ObjectDictionary alloc] initWithValues:kValues1
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kValues1)];
|
||||
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects1
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kObjects1)];
|
||||
XCTAssertNotNil(dict1prime);
|
||||
GPBUInt32ObjectDictionary *dict2 =
|
||||
[[GPBUInt32ObjectDictionary alloc] initWithValues:kValues2
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kValues2)];
|
||||
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects2
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kObjects2)];
|
||||
XCTAssertNotNil(dict2);
|
||||
GPBUInt32ObjectDictionary *dict3 =
|
||||
[[GPBUInt32ObjectDictionary alloc] initWithValues:kValues1
|
||||
forKeys:kKeys2
|
||||
count:GPBARRAYSIZE(kValues1)];
|
||||
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects1
|
||||
forKeys:kKeys2
|
||||
count:GPBARRAYSIZE(kObjects1)];
|
||||
XCTAssertNotNil(dict3);
|
||||
GPBUInt32ObjectDictionary *dict4 =
|
||||
[[GPBUInt32ObjectDictionary alloc] initWithValues:kValues3
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kValues3)];
|
||||
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects3
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kObjects3)];
|
||||
XCTAssertNotNil(dict4);
|
||||
|
||||
// 1/1Prime should be different objects, but equal.
|
||||
|
@ -3473,10 +3473,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different objects; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same objects; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -3491,11 +3491,11 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
|
||||
- (void)testCopy {
|
||||
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
|
||||
const id kValues[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
GPBUInt32ObjectDictionary *dict =
|
||||
[[GPBUInt32ObjectDictionary alloc] initWithValues:kValues
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kObjects)];
|
||||
XCTAssertNotNil(dict);
|
||||
|
||||
GPBUInt32ObjectDictionary *dict2 = [dict copy];
|
||||
|
@ -3512,11 +3512,11 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
|
||||
- (void)testDictionaryFromDictionary {
|
||||
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
|
||||
const id kValues[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
GPBUInt32ObjectDictionary *dict =
|
||||
[[GPBUInt32ObjectDictionary alloc] initWithValues:kValues
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kObjects)];
|
||||
XCTAssertNotNil(dict);
|
||||
|
||||
GPBUInt32ObjectDictionary *dict2 =
|
||||
|
@ -3534,108 +3534,108 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
XCTAssertNotNil(dict);
|
||||
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
[dict setValue:@"abc" forKey:1U];
|
||||
[dict setObject:@"abc" forKey:1U];
|
||||
XCTAssertEqual(dict.count, 1U);
|
||||
|
||||
const uint32_t kKeys[] = { 2U, 3U, 4U };
|
||||
const id kValues[] = { @"def", @"ghi", @"jkl" };
|
||||
const id kObjects[] = { @"def", @"ghi", @"jkl" };
|
||||
GPBUInt32ObjectDictionary *dict2 =
|
||||
[[GPBUInt32ObjectDictionary alloc] initWithValues:kValues
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kObjects)];
|
||||
XCTAssertNotNil(dict2);
|
||||
[dict addEntriesFromDictionary:dict2];
|
||||
XCTAssertEqual(dict.count, 4U);
|
||||
|
||||
XCTAssertEqualObjects([dict valueForKey:1U], @"abc");
|
||||
XCTAssertEqualObjects([dict valueForKey:2U], @"def");
|
||||
XCTAssertEqualObjects([dict valueForKey:3U], @"ghi");
|
||||
XCTAssertEqualObjects([dict valueForKey:4U], @"jkl");
|
||||
XCTAssertEqualObjects([dict objectForKey:1U], @"abc");
|
||||
XCTAssertEqualObjects([dict objectForKey:2U], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:3U], @"ghi");
|
||||
XCTAssertEqualObjects([dict objectForKey:4U], @"jkl");
|
||||
[dict2 release];
|
||||
}
|
||||
|
||||
- (void)testRemove {
|
||||
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
|
||||
const id kValues[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
GPBUInt32ObjectDictionary *dict =
|
||||
[[GPBUInt32ObjectDictionary alloc] initWithValues:kValues
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kObjects)];
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 4U);
|
||||
|
||||
[dict removeValueForKey:2U];
|
||||
[dict removeObjectForKey:2U];
|
||||
XCTAssertEqual(dict.count, 3U);
|
||||
XCTAssertEqualObjects([dict valueForKey:1U], @"abc");
|
||||
XCTAssertNil([dict valueForKey:2U]);
|
||||
XCTAssertEqualObjects([dict valueForKey:3U], @"ghi");
|
||||
XCTAssertEqualObjects([dict valueForKey:4U], @"jkl");
|
||||
XCTAssertEqualObjects([dict objectForKey:1U], @"abc");
|
||||
XCTAssertNil([dict objectForKey:2U]);
|
||||
XCTAssertEqualObjects([dict objectForKey:3U], @"ghi");
|
||||
XCTAssertEqualObjects([dict objectForKey:4U], @"jkl");
|
||||
|
||||
// Remove again does nothing.
|
||||
[dict removeValueForKey:2U];
|
||||
[dict removeObjectForKey:2U];
|
||||
XCTAssertEqual(dict.count, 3U);
|
||||
XCTAssertEqualObjects([dict valueForKey:1U], @"abc");
|
||||
XCTAssertNil([dict valueForKey:2U]);
|
||||
XCTAssertEqualObjects([dict valueForKey:3U], @"ghi");
|
||||
XCTAssertEqualObjects([dict valueForKey:4U], @"jkl");
|
||||
XCTAssertEqualObjects([dict objectForKey:1U], @"abc");
|
||||
XCTAssertNil([dict objectForKey:2U]);
|
||||
XCTAssertEqualObjects([dict objectForKey:3U], @"ghi");
|
||||
XCTAssertEqualObjects([dict objectForKey:4U], @"jkl");
|
||||
|
||||
[dict removeValueForKey:4U];
|
||||
[dict removeObjectForKey:4U];
|
||||
XCTAssertEqual(dict.count, 2U);
|
||||
XCTAssertEqualObjects([dict valueForKey:1U], @"abc");
|
||||
XCTAssertNil([dict valueForKey:2U]);
|
||||
XCTAssertEqualObjects([dict valueForKey:3U], @"ghi");
|
||||
XCTAssertNil([dict valueForKey:4U]);
|
||||
XCTAssertEqualObjects([dict objectForKey:1U], @"abc");
|
||||
XCTAssertNil([dict objectForKey:2U]);
|
||||
XCTAssertEqualObjects([dict objectForKey:3U], @"ghi");
|
||||
XCTAssertNil([dict objectForKey:4U]);
|
||||
|
||||
[dict removeAll];
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertNil([dict valueForKey:1U]);
|
||||
XCTAssertNil([dict valueForKey:2U]);
|
||||
XCTAssertNil([dict valueForKey:3U]);
|
||||
XCTAssertNil([dict valueForKey:4U]);
|
||||
XCTAssertNil([dict objectForKey:1U]);
|
||||
XCTAssertNil([dict objectForKey:2U]);
|
||||
XCTAssertNil([dict objectForKey:3U]);
|
||||
XCTAssertNil([dict objectForKey:4U]);
|
||||
[dict release];
|
||||
}
|
||||
|
||||
- (void)testInplaceMutation {
|
||||
const uint32_t kKeys[] = { 1U, 2U, 3U, 4U };
|
||||
const id kValues[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
GPBUInt32ObjectDictionary *dict =
|
||||
[[GPBUInt32ObjectDictionary alloc] initWithValues:kValues
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kObjects)];
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 4U);
|
||||
XCTAssertEqualObjects([dict valueForKey:1U], @"abc");
|
||||
XCTAssertEqualObjects([dict valueForKey:2U], @"def");
|
||||
XCTAssertEqualObjects([dict valueForKey:3U], @"ghi");
|
||||
XCTAssertEqualObjects([dict valueForKey:4U], @"jkl");
|
||||
XCTAssertEqualObjects([dict objectForKey:1U], @"abc");
|
||||
XCTAssertEqualObjects([dict objectForKey:2U], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:3U], @"ghi");
|
||||
XCTAssertEqualObjects([dict objectForKey:4U], @"jkl");
|
||||
|
||||
[dict setValue:@"jkl" forKey:1U];
|
||||
[dict setObject:@"jkl" forKey:1U];
|
||||
XCTAssertEqual(dict.count, 4U);
|
||||
XCTAssertEqualObjects([dict valueForKey:1U], @"jkl");
|
||||
XCTAssertEqualObjects([dict valueForKey:2U], @"def");
|
||||
XCTAssertEqualObjects([dict valueForKey:3U], @"ghi");
|
||||
XCTAssertEqualObjects([dict valueForKey:4U], @"jkl");
|
||||
XCTAssertEqualObjects([dict objectForKey:1U], @"jkl");
|
||||
XCTAssertEqualObjects([dict objectForKey:2U], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:3U], @"ghi");
|
||||
XCTAssertEqualObjects([dict objectForKey:4U], @"jkl");
|
||||
|
||||
[dict setValue:@"def" forKey:4U];
|
||||
[dict setObject:@"def" forKey:4U];
|
||||
XCTAssertEqual(dict.count, 4U);
|
||||
XCTAssertEqualObjects([dict valueForKey:1U], @"jkl");
|
||||
XCTAssertEqualObjects([dict valueForKey:2U], @"def");
|
||||
XCTAssertEqualObjects([dict valueForKey:3U], @"ghi");
|
||||
XCTAssertEqualObjects([dict valueForKey:4U], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:1U], @"jkl");
|
||||
XCTAssertEqualObjects([dict objectForKey:2U], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:3U], @"ghi");
|
||||
XCTAssertEqualObjects([dict objectForKey:4U], @"def");
|
||||
|
||||
const uint32_t kKeys2[] = { 2U, 3U };
|
||||
const id kValues2[] = { @"ghi", @"abc" };
|
||||
const id kObjects2[] = { @"ghi", @"abc" };
|
||||
GPBUInt32ObjectDictionary *dict2 =
|
||||
[[GPBUInt32ObjectDictionary alloc] initWithValues:kValues2
|
||||
forKeys:kKeys2
|
||||
count:GPBARRAYSIZE(kValues2)];
|
||||
[[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects2
|
||||
forKeys:kKeys2
|
||||
count:GPBARRAYSIZE(kObjects2)];
|
||||
XCTAssertNotNil(dict2);
|
||||
[dict addEntriesFromDictionary:dict2];
|
||||
XCTAssertEqual(dict.count, 4U);
|
||||
XCTAssertEqualObjects([dict valueForKey:1U], @"jkl");
|
||||
XCTAssertEqualObjects([dict valueForKey:2U], @"ghi");
|
||||
XCTAssertEqualObjects([dict valueForKey:3U], @"abc");
|
||||
XCTAssertEqualObjects([dict valueForKey:4U], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:1U], @"jkl");
|
||||
XCTAssertEqualObjects([dict objectForKey:2U], @"ghi");
|
||||
XCTAssertEqualObjects([dict objectForKey:3U], @"abc");
|
||||
XCTAssertEqualObjects([dict objectForKey:4U], @"def");
|
||||
|
||||
[dict2 release];
|
||||
[dict release];
|
||||
|
|
|
@ -211,10 +211,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -568,10 +568,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -925,10 +925,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -1282,10 +1282,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -1639,10 +1639,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -1996,10 +1996,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -2353,10 +2353,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -2710,10 +2710,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -3071,10 +3071,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same values; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -3366,48 +3366,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
GPBUInt64ObjectDictionary *dict = [[GPBUInt64ObjectDictionary alloc] init];
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertNil([dict valueForKey:31ULL]);
|
||||
[dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, id aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTAssertNil([dict objectForKey:31ULL]);
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, id aObject, BOOL *stop) {
|
||||
#pragma unused(aKey, aObject, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
}
|
||||
|
||||
- (void)testOne {
|
||||
GPBUInt64ObjectDictionary *dict = [GPBUInt64ObjectDictionary dictionaryWithValue:@"abc" forKey:31ULL];
|
||||
GPBUInt64ObjectDictionary *dict = [GPBUInt64ObjectDictionary dictionaryWithObject:@"abc" forKey:31ULL];
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 1U);
|
||||
XCTAssertEqualObjects([dict valueForKey:31ULL], @"abc");
|
||||
XCTAssertNil([dict valueForKey:32ULL]);
|
||||
[dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, id aValue, BOOL *stop) {
|
||||
XCTAssertEqualObjects([dict objectForKey:31ULL], @"abc");
|
||||
XCTAssertNil([dict objectForKey:32ULL]);
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, id aObject, BOOL *stop) {
|
||||
XCTAssertEqual(aKey, 31ULL);
|
||||
XCTAssertEqualObjects(aValue, @"abc");
|
||||
XCTAssertEqualObjects(aObject, @"abc");
|
||||
XCTAssertNotEqual(stop, NULL);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)testBasics {
|
||||
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL };
|
||||
const id kValues[] = { @"abc", @"def", @"ghi" };
|
||||
const id kObjects[] = { @"abc", @"def", @"ghi" };
|
||||
GPBUInt64ObjectDictionary *dict =
|
||||
[[GPBUInt64ObjectDictionary alloc] initWithValues:kValues
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kObjects)];
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 3U);
|
||||
XCTAssertEqualObjects([dict valueForKey:31ULL], @"abc");
|
||||
XCTAssertEqualObjects([dict valueForKey:32ULL], @"def");
|
||||
XCTAssertEqualObjects([dict valueForKey:33ULL], @"ghi");
|
||||
XCTAssertNil([dict valueForKey:34ULL]);
|
||||
XCTAssertEqualObjects([dict objectForKey:31ULL], @"abc");
|
||||
XCTAssertEqualObjects([dict objectForKey:32ULL], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:33ULL], @"ghi");
|
||||
XCTAssertNil([dict objectForKey:34ULL]);
|
||||
|
||||
__block NSUInteger idx = 0;
|
||||
uint64_t *seenKeys = malloc(3 * sizeof(uint64_t));
|
||||
id *seenValues = malloc(3 * sizeof(id));
|
||||
[dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, id aValue, BOOL *stop) {
|
||||
id *seenObjects = malloc(3 * sizeof(id));
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, id aObject, BOOL *stop) {
|
||||
XCTAssertLessThan(idx, 3U);
|
||||
seenKeys[idx] = aKey;
|
||||
seenValues[idx] = aValue;
|
||||
seenObjects[idx] = aObject;
|
||||
XCTAssertNotEqual(stop, NULL);
|
||||
++idx;
|
||||
}];
|
||||
|
@ -3416,18 +3416,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
for (int j = 0; (j < 3) && !foundKey; ++j) {
|
||||
if (kKeys[i] == seenKeys[j]) {
|
||||
foundKey = YES;
|
||||
XCTAssertEqualObjects(kValues[i], seenValues[j], @"i = %d, j = %d", i, j);
|
||||
XCTAssertEqualObjects(kObjects[i], seenObjects[j], @"i = %d, j = %d", i, j);
|
||||
}
|
||||
}
|
||||
XCTAssertTrue(foundKey, @"i = %d", i);
|
||||
}
|
||||
free(seenKeys);
|
||||
free(seenValues);
|
||||
free(seenObjects);
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, id aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, id aObject, BOOL *stop) {
|
||||
#pragma unused(aKey, aObject)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
|
@ -3438,33 +3438,33 @@ 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 kValues1[] = { @"abc", @"def", @"ghi" };
|
||||
const id kValues2[] = { @"abc", @"jkl", @"ghi" };
|
||||
const id kValues3[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
const id kObjects1[] = { @"abc", @"def", @"ghi" };
|
||||
const id kObjects2[] = { @"abc", @"jkl", @"ghi" };
|
||||
const id kObjects3[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
GPBUInt64ObjectDictionary *dict1 =
|
||||
[[GPBUInt64ObjectDictionary alloc] initWithValues:kValues1
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kValues1)];
|
||||
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects1
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kObjects1)];
|
||||
XCTAssertNotNil(dict1);
|
||||
GPBUInt64ObjectDictionary *dict1prime =
|
||||
[[GPBUInt64ObjectDictionary alloc] initWithValues:kValues1
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kValues1)];
|
||||
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects1
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kObjects1)];
|
||||
XCTAssertNotNil(dict1prime);
|
||||
GPBUInt64ObjectDictionary *dict2 =
|
||||
[[GPBUInt64ObjectDictionary alloc] initWithValues:kValues2
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kValues2)];
|
||||
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects2
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kObjects2)];
|
||||
XCTAssertNotNil(dict2);
|
||||
GPBUInt64ObjectDictionary *dict3 =
|
||||
[[GPBUInt64ObjectDictionary alloc] initWithValues:kValues1
|
||||
forKeys:kKeys2
|
||||
count:GPBARRAYSIZE(kValues1)];
|
||||
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects1
|
||||
forKeys:kKeys2
|
||||
count:GPBARRAYSIZE(kObjects1)];
|
||||
XCTAssertNotNil(dict3);
|
||||
GPBUInt64ObjectDictionary *dict4 =
|
||||
[[GPBUInt64ObjectDictionary alloc] initWithValues:kValues3
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kValues3)];
|
||||
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects3
|
||||
forKeys:kKeys1
|
||||
count:GPBARRAYSIZE(kObjects3)];
|
||||
XCTAssertNotNil(dict4);
|
||||
|
||||
// 1/1Prime should be different objects, but equal.
|
||||
|
@ -3473,10 +3473,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
// Equal, so they must have same hash.
|
||||
XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
|
||||
// 2 is save keys, different values; not equal.
|
||||
// 2 is same keys, different objects; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict2);
|
||||
|
||||
// 3 is different keys, samae values; not equal.
|
||||
// 3 is different keys, same objects; not equal.
|
||||
XCTAssertNotEqualObjects(dict1, dict3);
|
||||
|
||||
// 4 extra pair; not equal
|
||||
|
@ -3491,11 +3491,11 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
|
||||
- (void)testCopy {
|
||||
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
|
||||
const id kValues[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
GPBUInt64ObjectDictionary *dict =
|
||||
[[GPBUInt64ObjectDictionary alloc] initWithValues:kValues
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kObjects)];
|
||||
XCTAssertNotNil(dict);
|
||||
|
||||
GPBUInt64ObjectDictionary *dict2 = [dict copy];
|
||||
|
@ -3512,11 +3512,11 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
|
||||
- (void)testDictionaryFromDictionary {
|
||||
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
|
||||
const id kValues[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
GPBUInt64ObjectDictionary *dict =
|
||||
[[GPBUInt64ObjectDictionary alloc] initWithValues:kValues
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kObjects)];
|
||||
XCTAssertNotNil(dict);
|
||||
|
||||
GPBUInt64ObjectDictionary *dict2 =
|
||||
|
@ -3534,108 +3534,108 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
|||
XCTAssertNotNil(dict);
|
||||
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
[dict setValue:@"abc" forKey:31ULL];
|
||||
[dict setObject:@"abc" forKey:31ULL];
|
||||
XCTAssertEqual(dict.count, 1U);
|
||||
|
||||
const uint64_t kKeys[] = { 32ULL, 33ULL, 34ULL };
|
||||
const id kValues[] = { @"def", @"ghi", @"jkl" };
|
||||
const id kObjects[] = { @"def", @"ghi", @"jkl" };
|
||||
GPBUInt64ObjectDictionary *dict2 =
|
||||
[[GPBUInt64ObjectDictionary alloc] initWithValues:kValues
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kObjects)];
|
||||
XCTAssertNotNil(dict2);
|
||||
[dict addEntriesFromDictionary:dict2];
|
||||
XCTAssertEqual(dict.count, 4U);
|
||||
|
||||
XCTAssertEqualObjects([dict valueForKey:31ULL], @"abc");
|
||||
XCTAssertEqualObjects([dict valueForKey:32ULL], @"def");
|
||||
XCTAssertEqualObjects([dict valueForKey:33ULL], @"ghi");
|
||||
XCTAssertEqualObjects([dict valueForKey:34ULL], @"jkl");
|
||||
XCTAssertEqualObjects([dict objectForKey:31ULL], @"abc");
|
||||
XCTAssertEqualObjects([dict objectForKey:32ULL], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:33ULL], @"ghi");
|
||||
XCTAssertEqualObjects([dict objectForKey:34ULL], @"jkl");
|
||||
[dict2 release];
|
||||
}
|
||||
|
||||
- (void)testRemove {
|
||||
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
|
||||
const id kValues[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
GPBUInt64ObjectDictionary *dict =
|
||||
[[GPBUInt64ObjectDictionary alloc] initWithValues:kValues
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kObjects)];
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 4U);
|
||||
|
||||
[dict removeValueForKey:32ULL];
|
||||
[dict removeObjectForKey:32ULL];
|
||||
XCTAssertEqual(dict.count, 3U);
|
||||
XCTAssertEqualObjects([dict valueForKey:31ULL], @"abc");
|
||||
XCTAssertNil([dict valueForKey:32ULL]);
|
||||
XCTAssertEqualObjects([dict valueForKey:33ULL], @"ghi");
|
||||
XCTAssertEqualObjects([dict valueForKey:34ULL], @"jkl");
|
||||
XCTAssertEqualObjects([dict objectForKey:31ULL], @"abc");
|
||||
XCTAssertNil([dict objectForKey:32ULL]);
|
||||
XCTAssertEqualObjects([dict objectForKey:33ULL], @"ghi");
|
||||
XCTAssertEqualObjects([dict objectForKey:34ULL], @"jkl");
|
||||
|
||||
// Remove again does nothing.
|
||||
[dict removeValueForKey:32ULL];
|
||||
[dict removeObjectForKey:32ULL];
|
||||
XCTAssertEqual(dict.count, 3U);
|
||||
XCTAssertEqualObjects([dict valueForKey:31ULL], @"abc");
|
||||
XCTAssertNil([dict valueForKey:32ULL]);
|
||||
XCTAssertEqualObjects([dict valueForKey:33ULL], @"ghi");
|
||||
XCTAssertEqualObjects([dict valueForKey:34ULL], @"jkl");
|
||||
XCTAssertEqualObjects([dict objectForKey:31ULL], @"abc");
|
||||
XCTAssertNil([dict objectForKey:32ULL]);
|
||||
XCTAssertEqualObjects([dict objectForKey:33ULL], @"ghi");
|
||||
XCTAssertEqualObjects([dict objectForKey:34ULL], @"jkl");
|
||||
|
||||
[dict removeValueForKey:34ULL];
|
||||
[dict removeObjectForKey:34ULL];
|
||||
XCTAssertEqual(dict.count, 2U);
|
||||
XCTAssertEqualObjects([dict valueForKey:31ULL], @"abc");
|
||||
XCTAssertNil([dict valueForKey:32ULL]);
|
||||
XCTAssertEqualObjects([dict valueForKey:33ULL], @"ghi");
|
||||
XCTAssertNil([dict valueForKey:34ULL]);
|
||||
XCTAssertEqualObjects([dict objectForKey:31ULL], @"abc");
|
||||
XCTAssertNil([dict objectForKey:32ULL]);
|
||||
XCTAssertEqualObjects([dict objectForKey:33ULL], @"ghi");
|
||||
XCTAssertNil([dict objectForKey:34ULL]);
|
||||
|
||||
[dict removeAll];
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertNil([dict valueForKey:31ULL]);
|
||||
XCTAssertNil([dict valueForKey:32ULL]);
|
||||
XCTAssertNil([dict valueForKey:33ULL]);
|
||||
XCTAssertNil([dict valueForKey:34ULL]);
|
||||
XCTAssertNil([dict objectForKey:31ULL]);
|
||||
XCTAssertNil([dict objectForKey:32ULL]);
|
||||
XCTAssertNil([dict objectForKey:33ULL]);
|
||||
XCTAssertNil([dict objectForKey:34ULL]);
|
||||
[dict release];
|
||||
}
|
||||
|
||||
- (void)testInplaceMutation {
|
||||
const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
|
||||
const id kValues[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
|
||||
GPBUInt64ObjectDictionary *dict =
|
||||
[[GPBUInt64ObjectDictionary alloc] initWithValues:kValues
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects
|
||||
forKeys:kKeys
|
||||
count:GPBARRAYSIZE(kObjects)];
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 4U);
|
||||
XCTAssertEqualObjects([dict valueForKey:31ULL], @"abc");
|
||||
XCTAssertEqualObjects([dict valueForKey:32ULL], @"def");
|
||||
XCTAssertEqualObjects([dict valueForKey:33ULL], @"ghi");
|
||||
XCTAssertEqualObjects([dict valueForKey:34ULL], @"jkl");
|
||||
XCTAssertEqualObjects([dict objectForKey:31ULL], @"abc");
|
||||
XCTAssertEqualObjects([dict objectForKey:32ULL], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:33ULL], @"ghi");
|
||||
XCTAssertEqualObjects([dict objectForKey:34ULL], @"jkl");
|
||||
|
||||
[dict setValue:@"jkl" forKey:31ULL];
|
||||
[dict setObject:@"jkl" forKey:31ULL];
|
||||
XCTAssertEqual(dict.count, 4U);
|
||||
XCTAssertEqualObjects([dict valueForKey:31ULL], @"jkl");
|
||||
XCTAssertEqualObjects([dict valueForKey:32ULL], @"def");
|
||||
XCTAssertEqualObjects([dict valueForKey:33ULL], @"ghi");
|
||||
XCTAssertEqualObjects([dict valueForKey:34ULL], @"jkl");
|
||||
XCTAssertEqualObjects([dict objectForKey:31ULL], @"jkl");
|
||||
XCTAssertEqualObjects([dict objectForKey:32ULL], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:33ULL], @"ghi");
|
||||
XCTAssertEqualObjects([dict objectForKey:34ULL], @"jkl");
|
||||
|
||||
[dict setValue:@"def" forKey:34ULL];
|
||||
[dict setObject:@"def" forKey:34ULL];
|
||||
XCTAssertEqual(dict.count, 4U);
|
||||
XCTAssertEqualObjects([dict valueForKey:31ULL], @"jkl");
|
||||
XCTAssertEqualObjects([dict valueForKey:32ULL], @"def");
|
||||
XCTAssertEqualObjects([dict valueForKey:33ULL], @"ghi");
|
||||
XCTAssertEqualObjects([dict valueForKey:34ULL], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:31ULL], @"jkl");
|
||||
XCTAssertEqualObjects([dict objectForKey:32ULL], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:33ULL], @"ghi");
|
||||
XCTAssertEqualObjects([dict objectForKey:34ULL], @"def");
|
||||
|
||||
const uint64_t kKeys2[] = { 32ULL, 33ULL };
|
||||
const id kValues2[] = { @"ghi", @"abc" };
|
||||
const id kObjects2[] = { @"ghi", @"abc" };
|
||||
GPBUInt64ObjectDictionary *dict2 =
|
||||
[[GPBUInt64ObjectDictionary alloc] initWithValues:kValues2
|
||||
forKeys:kKeys2
|
||||
count:GPBARRAYSIZE(kValues2)];
|
||||
[[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects2
|
||||
forKeys:kKeys2
|
||||
count:GPBARRAYSIZE(kObjects2)];
|
||||
XCTAssertNotNil(dict2);
|
||||
[dict addEntriesFromDictionary:dict2];
|
||||
XCTAssertEqual(dict.count, 4U);
|
||||
XCTAssertEqualObjects([dict valueForKey:31ULL], @"jkl");
|
||||
XCTAssertEqualObjects([dict valueForKey:32ULL], @"ghi");
|
||||
XCTAssertEqualObjects([dict valueForKey:33ULL], @"abc");
|
||||
XCTAssertEqualObjects([dict valueForKey:34ULL], @"def");
|
||||
XCTAssertEqualObjects([dict objectForKey:31ULL], @"jkl");
|
||||
XCTAssertEqualObjects([dict objectForKey:32ULL], @"ghi");
|
||||
XCTAssertEqualObjects([dict objectForKey:33ULL], @"abc");
|
||||
XCTAssertEqualObjects([dict objectForKey:34ULL], @"def");
|
||||
|
||||
[dict2 release];
|
||||
[dict release];
|
||||
|
|
|
@ -45,12 +45,12 @@
|
|||
//%TESTS_FOR_ENUM_VALUE_RAW_ADDITIONS(KEY_NAME, KEY_TYPE, KisP, KSUFFIX, KEY1, KEY2, KEY3, KEY4)
|
||||
|
||||
//%PDDM-DEFINE TESTS_FOR_POD_VALUE(KEY_NAME, KEY_TYPE, KisP, KSUFFIX, KEY1, KEY2, KEY3, KEY4, VALUE_NAME, VALUE_TYPE, VACCESSOR, VAL1, VAL2, VAL3, VAL4)
|
||||
//%TESTS_COMMON(KEY_NAME, KEY_TYPE, KisP, KSUFFIX, KEY1, KEY2, KEY3, KEY4, VALUE_NAME, VALUE_TYPE, , POD, VACCESSOR, VAL1, VAL2, VAL3, VAL4)
|
||||
//%TESTS_COMMON(KEY_NAME, KEY_TYPE, KisP, KSUFFIX, KEY1, KEY2, KEY3, KEY4, VALUE_NAME, VALUE_TYPE, , value, POD, VACCESSOR, VAL1, VAL2, VAL3, VAL4)
|
||||
|
||||
//%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, , 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 TESTS_COMMON(KEY_NAME, KEY_TYPE, KisP, KSUFFIX, KEY1, KEY2, KEY3, KEY4, VALUE_NAME, VALUE_TYPE, VSUFFIX, VHELPER, VACCESSOR, VAL1, VAL2, VAL3, VAL4)
|
||||
//%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
|
||||
//%
|
||||
//%@interface GPB##KEY_NAME##VALUE_NAME##DictionaryTests : XCTestCase
|
||||
|
@ -63,47 +63,47 @@
|
|||
//% XCTAssertNotNil(dict);
|
||||
//% XCTAssertEqual(dict.count, 0U);
|
||||
//%VALUE_NOT_FOUND##VHELPER(dict, KEY1)
|
||||
//% [dict enumerateKeysAndValuesUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE aValue, BOOL *stop) {
|
||||
//% #pragma unused(aKey, aValue, stop)
|
||||
//% [dict enumerateKeysAnd##VNAME$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!");
|
||||
//% }];
|
||||
//% [dict release];
|
||||
//%}
|
||||
//%
|
||||
//%- (void)testOne {
|
||||
//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict = [GPB##KEY_NAME##VALUE_NAME##Dictionary dictionaryWithValue:VAL1 forKey:KEY1];
|
||||
//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict = [GPB##KEY_NAME##VALUE_NAME##Dictionary dictionaryWith##VNAME$u##:VAL1 forKey:KEY1];
|
||||
//% XCTAssertNotNil(dict);
|
||||
//% XCTAssertEqual(dict.count, 1U);
|
||||
//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_VALUE##VHELPER(dict, value, KEY1, VAL1)
|
||||
//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
|
||||
//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
|
||||
//% [dict enumerateKeysAndValuesUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE aValue, BOOL *stop) {
|
||||
//% [dict enumerateKeysAnd##VNAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u, BOOL *stop) {
|
||||
//% XCTAssertEqual##KSUFFIX(aKey, KEY1);
|
||||
//% XCTAssertEqual##VSUFFIX(aValue, VAL1);
|
||||
//% XCTAssertEqual##VSUFFIX(a##VNAME$u, VAL1);
|
||||
//% XCTAssertNotEqual(stop, NULL);
|
||||
//% }];
|
||||
//%}
|
||||
//%
|
||||
//%- (void)testBasics {
|
||||
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2, KEY3 };
|
||||
//% const VALUE_TYPE kValues[] = { VAL1, VAL2, VAL3 };
|
||||
//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2, VAL3 };
|
||||
//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
|
||||
//% [[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)];
|
||||
//% [[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)];
|
||||
//% XCTAssertNotNil(dict);
|
||||
//% XCTAssertEqual(dict.count, 3U);
|
||||
//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_VALUE##VHELPER(dict, value, KEY1, VAL1)
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY2, VAL2)
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL3)
|
||||
//%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)
|
||||
//%
|
||||
//% __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) {
|
||||
//% 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) {
|
||||
//% XCTAssertLessThan(idx, 3U);
|
||||
//% seenKeys[idx] = aKey;
|
||||
//% seenValues[idx] = aValue;
|
||||
//% seen##VNAME$u##s[idx] = a##VNAME$u##;
|
||||
//% XCTAssertNotEqual(stop, NULL);
|
||||
//% ++idx;
|
||||
//% }];
|
||||
|
@ -112,18 +112,18 @@
|
|||
//% for (int j = 0; (j < 3) && !foundKey; ++j) {
|
||||
//% if (COMPARE_KEYS##KSUFFIX(kKeys[i], seenKeys[j])) {
|
||||
//% foundKey = YES;
|
||||
//% XCTAssertEqual##VSUFFIX(kValues[i], seenValues[j], @"i = %d, j = %d", i, j);
|
||||
//% XCTAssertEqual##VSUFFIX(k##VNAME$u##s[i], seen##VNAME$u##s[j], @"i = %d, j = %d", i, j);
|
||||
//% }
|
||||
//% }
|
||||
//% XCTAssertTrue(foundKey, @"i = %d", i);
|
||||
//% }
|
||||
//% free(seenKeys);
|
||||
//% free(seenValues);
|
||||
//% free(seen##VNAME$u##s);
|
||||
//%
|
||||
//% // Stopping the enumeration.
|
||||
//% idx = 0;
|
||||
//% [dict enumerateKeysAndValuesUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE aValue, BOOL *stop) {
|
||||
//% #pragma unused(aKey, aValue)
|
||||
//% [dict enumerateKeysAnd##VNAME$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);
|
||||
//% ++idx;
|
||||
|
@ -134,33 +134,33 @@
|
|||
//%- (void)testEquality {
|
||||
//% const KEY_TYPE KisP##kKeys1[] = { KEY1, KEY2, KEY3, KEY4 };
|
||||
//% const KEY_TYPE KisP##kKeys2[] = { KEY2, KEY1, KEY4 };
|
||||
//% const VALUE_TYPE kValues1[] = { VAL1, VAL2, VAL3 };
|
||||
//% const VALUE_TYPE kValues2[] = { VAL1, VAL4, VAL3 };
|
||||
//% const VALUE_TYPE kValues3[] = { VAL1, VAL2, VAL3, VAL4 };
|
||||
//% 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] initWithValues:kValues1
|
||||
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys1
|
||||
//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues1)];
|
||||
//% [[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)];
|
||||
//% XCTAssertNotNil(dict1);
|
||||
//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict1prime =
|
||||
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues1
|
||||
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys1
|
||||
//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues1)];
|
||||
//% [[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)];
|
||||
//% XCTAssertNotNil(dict1prime);
|
||||
//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 =
|
||||
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues2
|
||||
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys1
|
||||
//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues2)];
|
||||
//% [[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)];
|
||||
//% XCTAssertNotNil(dict2);
|
||||
//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict3 =
|
||||
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues1
|
||||
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys2
|
||||
//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues1)];
|
||||
//% [[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)];
|
||||
//% XCTAssertNotNil(dict3);
|
||||
//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict4 =
|
||||
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues3
|
||||
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys1
|
||||
//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues3)];
|
||||
//% [[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)];
|
||||
//% XCTAssertNotNil(dict4);
|
||||
//%
|
||||
//% // 1/1Prime should be different objects, but equal.
|
||||
|
@ -169,10 +169,10 @@
|
|||
//% // Equal, so they must have same hash.
|
||||
//% XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
//%
|
||||
//% // 2 is save keys, different values; not equal.
|
||||
//% // 2 is same keys, different ##VNAME##s; not equal.
|
||||
//% XCTAssertNotEqualObjects(dict1, dict2);
|
||||
//%
|
||||
//% // 3 is different keys, samae values; not equal.
|
||||
//% // 3 is different keys, same ##VNAME##s; not equal.
|
||||
//% XCTAssertNotEqualObjects(dict1, dict3);
|
||||
//%
|
||||
//% // 4 extra pair; not equal
|
||||
|
@ -187,11 +187,11 @@
|
|||
//%
|
||||
//%- (void)testCopy {
|
||||
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2, KEY3, KEY4 };
|
||||
//% const VALUE_TYPE kValues[] = { VAL1, VAL2, VAL3, VAL4 };
|
||||
//% 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] initWithValues:kValues
|
||||
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys
|
||||
//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues)];
|
||||
//% [[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)];
|
||||
//% XCTAssertNotNil(dict);
|
||||
//%
|
||||
//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 = [dict copy];
|
||||
|
@ -208,11 +208,11 @@
|
|||
//%
|
||||
//%- (void)testDictionaryFromDictionary {
|
||||
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2, KEY3, KEY4 };
|
||||
//% const VALUE_TYPE kValues[] = { VAL1, VAL2, VAL3, VAL4 };
|
||||
//% 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] initWithValues:kValues
|
||||
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys
|
||||
//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues)];
|
||||
//% [[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)];
|
||||
//% XCTAssertNotNil(dict);
|
||||
//%
|
||||
//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 =
|
||||
|
@ -230,56 +230,56 @@
|
|||
//% XCTAssertNotNil(dict);
|
||||
//%
|
||||
//% XCTAssertEqual(dict.count, 0U);
|
||||
//% [dict setValue:VAL1 forKey:KEY1];
|
||||
//% [dict set##VNAME$u##:VAL1 forKey:KEY1];
|
||||
//% XCTAssertEqual(dict.count, 1U);
|
||||
//%
|
||||
//% const KEY_TYPE KisP##kKeys[] = { KEY2, KEY3, KEY4 };
|
||||
//% const VALUE_TYPE kValues[] = { VAL2, VAL3, VAL4 };
|
||||
//% const VALUE_TYPE k##VNAME$u##s[] = { VAL2, VAL3, VAL4 };
|
||||
//% 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)];
|
||||
//% [[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)];
|
||||
//% XCTAssertNotNil(dict2);
|
||||
//% [dict add##VACCESSOR##EntriesFromDictionary: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, VAL2)
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL3)
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY4, VAL4)
|
||||
//%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)
|
||||
//% [dict2 release];
|
||||
//%}
|
||||
//%
|
||||
//%- (void)testRemove {
|
||||
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2, KEY3, KEY4 };
|
||||
//% const VALUE_TYPE kValues[] = { VAL1, VAL2, VAL3, VAL4 };
|
||||
//% 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] initWithValues:kValues
|
||||
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys
|
||||
//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues)];
|
||||
//% [[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)];
|
||||
//% XCTAssertNotNil(dict);
|
||||
//% XCTAssertEqual(dict.count, 4U);
|
||||
//%
|
||||
//% [dict removeValueForKey:KEY2];
|
||||
//% [dict remove##VNAME$u##ForKey:KEY2];
|
||||
//% XCTAssertEqual(dict.count, 3U);
|
||||
//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_VALUE##VHELPER(dict, value, KEY1, VAL1)
|
||||
//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
|
||||
//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL3)
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY4, VAL4)
|
||||
//%TEST_VALUE##VHELPER(dict, VNAME, KEY3, VAL3)
|
||||
//%TEST_VALUE##VHELPER(dict, VNAME, KEY4, VAL4)
|
||||
//%
|
||||
//% // Remove again does nothing.
|
||||
//% [dict removeValueForKey:KEY2];
|
||||
//% [dict remove##VNAME$u##ForKey:KEY2];
|
||||
//% XCTAssertEqual(dict.count, 3U);
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY1, VAL1)
|
||||
//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
|
||||
//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL3)
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY4, VAL4)
|
||||
//%TEST_VALUE##VHELPER(dict, VNAME, KEY3, VAL3)
|
||||
//%TEST_VALUE##VHELPER(dict, VNAME, KEY4, VAL4)
|
||||
//%
|
||||
//% [dict removeValueForKey:KEY4];
|
||||
//% [dict remove##VNAME$u##ForKey:KEY4];
|
||||
//% XCTAssertEqual(dict.count, 2U);
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY1, VAL1)
|
||||
//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
|
||||
//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL3)
|
||||
//%TEST_VALUE##VHELPER(dict, VNAME, KEY3, VAL3)
|
||||
//%VALUE_NOT_FOUND##VHELPER(dict, KEY4)
|
||||
//%
|
||||
//% [dict removeAll];
|
||||
|
@ -293,45 +293,45 @@
|
|||
//%
|
||||
//%- (void)testInplaceMutation {
|
||||
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2, KEY3, KEY4 };
|
||||
//% const VALUE_TYPE kValues[] = { VAL1, VAL2, VAL3, VAL4 };
|
||||
//% 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] initWithValues:kValues
|
||||
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys
|
||||
//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues)];
|
||||
//% [[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)];
|
||||
//% XCTAssertNotNil(dict);
|
||||
//% XCTAssertEqual(dict.count, 4U);
|
||||
//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_VALUE##VHELPER(dict, value, KEY1, VAL1)
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY2, VAL2)
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL3)
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY4, VAL4)
|
||||
//%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)
|
||||
//%
|
||||
//% [dict setValue:VAL4 forKey:KEY1];
|
||||
//% [dict set##VNAME$u##:VAL4 forKey:KEY1];
|
||||
//% XCTAssertEqual(dict.count, 4U);
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY1, VAL4)
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY2, VAL2)
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL3)
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY4, VAL4)
|
||||
//%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)
|
||||
//%
|
||||
//% [dict setValue:VAL2 forKey:KEY4];
|
||||
//% [dict set##VNAME$u##:VAL2 forKey:KEY4];
|
||||
//% XCTAssertEqual(dict.count, 4U);
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY1, VAL4)
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY2, VAL2)
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL3)
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY4, VAL2)
|
||||
//%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)
|
||||
//%
|
||||
//% const KEY_TYPE KisP##kKeys2[] = { KEY2, KEY3 };
|
||||
//% const VALUE_TYPE kValues2[] = { VAL3, VAL1 };
|
||||
//% const VALUE_TYPE k##VNAME$u##s2[] = { VAL3, VAL1 };
|
||||
//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 =
|
||||
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues2
|
||||
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys2
|
||||
//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues2)];
|
||||
//% [[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)];
|
||||
//% XCTAssertNotNil(dict2);
|
||||
//% [dict add##VACCESSOR##EntriesFromDictionary:dict2];
|
||||
//% XCTAssertEqual(dict.count, 4U);
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY1, VAL4)
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY2, VAL3)
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL1)
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY4, VAL2)
|
||||
//%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)
|
||||
//%
|
||||
//% [dict2 release];
|
||||
//% [dict release];
|
||||
|
@ -466,10 +466,10 @@
|
|||
//% // Equal, so they must have same hash.
|
||||
//% XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
//%
|
||||
//% // 2 is save keys, different values; not equal.
|
||||
//% // 2 is same keys, different values; not equal.
|
||||
//% XCTAssertNotEqualObjects(dict1, dict2);
|
||||
//%
|
||||
//% // 3 is different keys, samae values; not equal.
|
||||
//% // 3 is different keys, same values; not equal.
|
||||
//% XCTAssertNotEqualObjects(dict1, dict3);
|
||||
//%
|
||||
//% // 4 extra pair; not equal
|
||||
|
@ -709,9 +709,9 @@
|
|||
//%PDDM-DEFINE DECLARE_VALUE_STORAGEOBJECT(VALUE_TYPE, NAME)
|
||||
// Empty
|
||||
//%PDDM-DEFINE VALUE_NOT_FOUNDOBJECT(DICT, KEY)
|
||||
//% XCTAssertNil([DICT valueForKey:KEY]);
|
||||
//% XCTAssertNil([DICT objectForKey:KEY]);
|
||||
//%PDDM-DEFINE TEST_VALUEOBJECT(DICT, STORAGE, KEY, VALUE)
|
||||
//% XCTAssertEqualObjects([DICT valueForKey:KEY], VALUE);
|
||||
//% XCTAssertEqualObjects([DICT objectForKey:KEY], VALUE);
|
||||
//%PDDM-DEFINE COMPARE_KEYSObjects(KEY1, KEY2)
|
||||
//%[KEY1 isEqual:KEY2]
|
||||
|
||||
|
@ -768,12 +768,12 @@
|
|||
//TODO(thomasvl): enum tests
|
||||
|
||||
//%PDDM-DEFINE BOOL_TESTS_FOR_POD_VALUE(VALUE_NAME, VALUE_TYPE, VAL1, VAL2)
|
||||
//%BOOL_TESTS_COMMON(Bool, BOOL, , , YES, NO, VALUE_NAME, VALUE_TYPE, , POD, VAL1, VAL2)
|
||||
//%BOOL_TESTS_COMMON(Bool, BOOL, , , YES, NO, VALUE_NAME, VALUE_TYPE, , value, POD, VAL1, VAL2)
|
||||
|
||||
//%PDDM-DEFINE TESTS_FOR_BOOL_KEY_OBJECT_VALUE(VALUE_NAME, VALUE_TYPE, VAL1, VAL2)
|
||||
//%BOOL_TESTS_COMMON(Bool, BOOL, , , YES, NO, VALUE_NAME, VALUE_TYPE, Objects, OBJECT, VAL1, VAL2)
|
||||
//%BOOL_TESTS_COMMON(Bool, BOOL, , , YES, NO, VALUE_NAME, VALUE_TYPE, Objects, object, OBJECT, VAL1, VAL2)
|
||||
|
||||
//%PDDM-DEFINE BOOL_TESTS_COMMON(KEY_NAME, KEY_TYPE, KisP, KSUFFIX, KEY1, KEY2, VALUE_NAME, VALUE_TYPE, VSUFFIX, VHELPER, VAL1, VAL2)
|
||||
//%PDDM-DEFINE BOOL_TESTS_COMMON(KEY_NAME, KEY_TYPE, KisP, KSUFFIX, KEY1, KEY2, VALUE_NAME, VALUE_TYPE, VSUFFIX, VNAME, VHELPER, VAL1, VAL2)
|
||||
//%#pragma mark - KEY_NAME -> VALUE_NAME
|
||||
//%
|
||||
//%@interface GPB##KEY_NAME##VALUE_NAME##DictionaryTests : XCTestCase
|
||||
|
@ -786,45 +786,45 @@
|
|||
//% XCTAssertNotNil(dict);
|
||||
//% XCTAssertEqual(dict.count, 0U);
|
||||
//%VALUE_NOT_FOUND##VHELPER(dict, KEY1)
|
||||
//% [dict enumerateKeysAndValuesUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE aValue, BOOL *stop) {
|
||||
//% #pragma unused(aKey, aValue, stop)
|
||||
//% [dict enumerateKeysAnd##VNAME$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!");
|
||||
//% }];
|
||||
//% [dict release];
|
||||
//%}
|
||||
//%
|
||||
//%- (void)testOne {
|
||||
//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict = [GPB##KEY_NAME##VALUE_NAME##Dictionary dictionaryWithValue:VAL1 forKey:KEY1];
|
||||
//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict = [GPB##KEY_NAME##VALUE_NAME##Dictionary dictionaryWith##VNAME$u##:VAL1 forKey:KEY1];
|
||||
//% XCTAssertNotNil(dict);
|
||||
//% XCTAssertEqual(dict.count, 1U);
|
||||
//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_VALUE##VHELPER(dict, value, KEY1, VAL1)
|
||||
//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
|
||||
//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
|
||||
//% [dict enumerateKeysAndValuesUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE aValue, BOOL *stop) {
|
||||
//% [dict enumerateKeysAnd##VNAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u, BOOL *stop) {
|
||||
//% XCTAssertEqual##KSUFFIX(aKey, KEY1);
|
||||
//% XCTAssertEqual##VSUFFIX(aValue, VAL1);
|
||||
//% XCTAssertEqual##VSUFFIX(a##VNAME$u, VAL1);
|
||||
//% XCTAssertNotEqual(stop, NULL);
|
||||
//% }];
|
||||
//%}
|
||||
//%
|
||||
//%- (void)testBasics {
|
||||
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2 };
|
||||
//% const VALUE_TYPE kValues[] = { VAL1, VAL2 };
|
||||
//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2 };
|
||||
//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
|
||||
//% [[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)];
|
||||
//% [[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)];
|
||||
//% XCTAssertNotNil(dict);
|
||||
//% XCTAssertEqual(dict.count, 2U);
|
||||
//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_VALUE##VHELPER(dict, value, KEY1, VAL1)
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY2, VAL2)
|
||||
//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
|
||||
//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2)
|
||||
//%
|
||||
//% __block NSUInteger idx = 0;
|
||||
//% KEY_TYPE KisP##*seenKeys = malloc(2 * sizeof(KEY_TYPE##KisP));
|
||||
//% VALUE_TYPE *seenValues = malloc(2 * sizeof(VALUE_TYPE));
|
||||
//% [dict enumerateKeysAndValuesUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE aValue, BOOL *stop) {
|
||||
//% 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) {
|
||||
//% XCTAssertLessThan(idx, 2U);
|
||||
//% seenKeys[idx] = aKey;
|
||||
//% seenValues[idx] = aValue;
|
||||
//% seen##VNAME$u##s[idx] = a##VNAME$u;
|
||||
//% XCTAssertNotEqual(stop, NULL);
|
||||
//% ++idx;
|
||||
//% }];
|
||||
|
@ -833,18 +833,18 @@
|
|||
//% for (int j = 0; (j < 2) && !foundKey; ++j) {
|
||||
//% if (COMPARE_KEYS##KSUFFIX(kKeys[i], seenKeys[j])) {
|
||||
//% foundKey = YES;
|
||||
//% XCTAssertEqual##VSUFFIX(kValues[i], seenValues[j], @"i = %d, j = %d", i, j);
|
||||
//% XCTAssertEqual##VSUFFIX(k##VNAME$u##s[i], seen##VNAME$u##s[j], @"i = %d, j = %d", i, j);
|
||||
//% }
|
||||
//% }
|
||||
//% XCTAssertTrue(foundKey, @"i = %d", i);
|
||||
//% }
|
||||
//% free(seenKeys);
|
||||
//% free(seenValues);
|
||||
//% free(seen##VNAME$u##s);
|
||||
//%
|
||||
//% // Stopping the enumeration.
|
||||
//% idx = 0;
|
||||
//% [dict enumerateKeysAndValuesUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE aValue, BOOL *stop) {
|
||||
//% #pragma unused(aKey, aValue)
|
||||
//% [dict enumerateKeysAnd##VNAME$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);
|
||||
//% ++idx;
|
||||
|
@ -855,33 +855,33 @@
|
|||
//%- (void)testEquality {
|
||||
//% const KEY_TYPE KisP##kKeys1[] = { KEY1, KEY2 };
|
||||
//% const KEY_TYPE KisP##kKeys2[] = { KEY2, KEY1 };
|
||||
//% const VALUE_TYPE kValues1[] = { VAL1, VAL2 };
|
||||
//% const VALUE_TYPE kValues2[] = { VAL2, VAL1 };
|
||||
//% const VALUE_TYPE kValues3[] = { VAL2 };
|
||||
//% 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] initWithValues:kValues1
|
||||
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys1
|
||||
//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues1)];
|
||||
//% [[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)];
|
||||
//% XCTAssertNotNil(dict1);
|
||||
//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict1prime =
|
||||
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues1
|
||||
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys1
|
||||
//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues1)];
|
||||
//% [[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)];
|
||||
//% XCTAssertNotNil(dict1prime);
|
||||
//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 =
|
||||
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues2
|
||||
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys1
|
||||
//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues2)];
|
||||
//% [[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)];
|
||||
//% XCTAssertNotNil(dict2);
|
||||
//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict3 =
|
||||
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues1
|
||||
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys2
|
||||
//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues1)];
|
||||
//% [[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)];
|
||||
//% XCTAssertNotNil(dict3);
|
||||
//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict4 =
|
||||
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues3
|
||||
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys1
|
||||
//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues3)];
|
||||
//% [[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)];
|
||||
//% XCTAssertNotNil(dict4);
|
||||
//%
|
||||
//% // 1/1Prime should be different objects, but equal.
|
||||
|
@ -890,10 +890,10 @@
|
|||
//% // Equal, so they must have same hash.
|
||||
//% XCTAssertEqual([dict1 hash], [dict1prime hash]);
|
||||
//%
|
||||
//% // 2 is save keys, different values; not equal.
|
||||
//% // 2 is same keys, different ##VNAME##s; not equal.
|
||||
//% XCTAssertNotEqualObjects(dict1, dict2);
|
||||
//%
|
||||
//% // 3 is different keys, samae values; not equal.
|
||||
//% // 3 is different keys, same ##VNAME##s; not equal.
|
||||
//% XCTAssertNotEqualObjects(dict1, dict3);
|
||||
//%
|
||||
//% // 4 Fewer pairs; not equal
|
||||
|
@ -908,11 +908,11 @@
|
|||
//%
|
||||
//%- (void)testCopy {
|
||||
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2 };
|
||||
//% const VALUE_TYPE kValues[] = { VAL1, VAL2 };
|
||||
//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2 };
|
||||
//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
|
||||
//% [[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)];
|
||||
//% [[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)];
|
||||
//% XCTAssertNotNil(dict);
|
||||
//%
|
||||
//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 = [dict copy];
|
||||
|
@ -929,11 +929,11 @@
|
|||
//%
|
||||
//%- (void)testDictionaryFromDictionary {
|
||||
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2 };
|
||||
//% const VALUE_TYPE kValues[] = { VAL1, VAL2 };
|
||||
//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2 };
|
||||
//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
|
||||
//% [[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)];
|
||||
//% [[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)];
|
||||
//% XCTAssertNotNil(dict);
|
||||
//%
|
||||
//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 =
|
||||
|
@ -951,43 +951,43 @@
|
|||
//% XCTAssertNotNil(dict);
|
||||
//%
|
||||
//% XCTAssertEqual(dict.count, 0U);
|
||||
//% [dict setValue:VAL1 forKey:KEY1];
|
||||
//% [dict set##VNAME$u:VAL1 forKey:KEY1];
|
||||
//% XCTAssertEqual(dict.count, 1U);
|
||||
//%
|
||||
//% const KEY_TYPE KisP##kKeys[] = { KEY2 };
|
||||
//% const VALUE_TYPE kValues[] = { VAL2 };
|
||||
//% const VALUE_TYPE k##VNAME$u##s[] = { VAL2 };
|
||||
//% 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)];
|
||||
//% [[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)];
|
||||
//% XCTAssertNotNil(dict2);
|
||||
//% [dict addEntriesFromDictionary:dict2];
|
||||
//% XCTAssertEqual(dict.count, 2U);
|
||||
//%
|
||||
//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_VALUE##VHELPER(dict, value, KEY1, VAL1)
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY2, VAL2)
|
||||
//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
|
||||
//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2)
|
||||
//% [dict2 release];
|
||||
//%}
|
||||
//%
|
||||
//%- (void)testRemove {
|
||||
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2};
|
||||
//% const VALUE_TYPE kValues[] = { VAL1, VAL2 };
|
||||
//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2 };
|
||||
//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
|
||||
//% [[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)];
|
||||
//% [[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)];
|
||||
//% XCTAssertNotNil(dict);
|
||||
//% XCTAssertEqual(dict.count, 2U);
|
||||
//%
|
||||
//% [dict removeValueForKey:KEY2];
|
||||
//% [dict remove##VNAME$u##ForKey:KEY2];
|
||||
//% XCTAssertEqual(dict.count, 1U);
|
||||
//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_VALUE##VHELPER(dict, value, KEY1, VAL1)
|
||||
//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
|
||||
//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
|
||||
//%
|
||||
//% // Remove again does nothing.
|
||||
//% [dict removeValueForKey:KEY2];
|
||||
//% [dict remove##VNAME$u##ForKey:KEY2];
|
||||
//% XCTAssertEqual(dict.count, 1U);
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY1, VAL1)
|
||||
//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
|
||||
//%VALUE_NOT_FOUND##VHELPER(dict, KEY2)
|
||||
//%
|
||||
//% [dict removeAll];
|
||||
|
@ -999,37 +999,37 @@
|
|||
//%
|
||||
//%- (void)testInplaceMutation {
|
||||
//% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2 };
|
||||
//% const VALUE_TYPE kValues[] = { VAL1, VAL2 };
|
||||
//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2 };
|
||||
//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict =
|
||||
//% [[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)];
|
||||
//% [[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)];
|
||||
//% XCTAssertNotNil(dict);
|
||||
//% XCTAssertEqual(dict.count, 2U);
|
||||
//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_VALUE##VHELPER(dict, value, KEY1, VAL1)
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY2, VAL2)
|
||||
//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
|
||||
//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2)
|
||||
//%
|
||||
//% [dict setValue:VAL2 forKey:KEY1];
|
||||
//% [dict set##VNAME$u##:VAL2 forKey:KEY1];
|
||||
//% XCTAssertEqual(dict.count, 2U);
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY1, VAL2)
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY2, VAL2)
|
||||
//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL2)
|
||||
//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2)
|
||||
//%
|
||||
//% [dict setValue:VAL1 forKey:KEY2];
|
||||
//% [dict set##VNAME$u##:VAL1 forKey:KEY2];
|
||||
//% XCTAssertEqual(dict.count, 2U);
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY1, VAL2)
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY2, VAL1)
|
||||
//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL2)
|
||||
//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL1)
|
||||
//%
|
||||
//% const KEY_TYPE KisP##kKeys2[] = { KEY2, KEY1 };
|
||||
//% const VALUE_TYPE kValues2[] = { VAL2, VAL1 };
|
||||
//% const VALUE_TYPE k##VNAME$u##s2[] = { VAL2, VAL1 };
|
||||
//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 =
|
||||
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues2
|
||||
//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys2
|
||||
//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues2)];
|
||||
//% [[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)];
|
||||
//% XCTAssertNotNil(dict2);
|
||||
//% [dict addEntriesFromDictionary:dict2];
|
||||
//% XCTAssertEqual(dict.count, 2U);
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY1, VAL1)
|
||||
//%TEST_VALUE##VHELPER(dict, value, KEY2, VAL2)
|
||||
//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1)
|
||||
//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2)
|
||||
//%
|
||||
//% [dict2 release];
|
||||
//% [dict release];
|
||||
|
|
|
@ -676,20 +676,21 @@
|
|||
TestAllTypes *subMsg = [TestAllTypes message];
|
||||
subMsg.repeatedInt32Array = [GPBInt32Array arrayWithValue:100];
|
||||
msg1.mapInt32Message = [GPBInt32ObjectDictionary dictionary];
|
||||
[msg1.mapInt32Message setValue:subMsg forKey:0];
|
||||
[msg1.mapInt32Message setObject:subMsg forKey:0];
|
||||
subMsg = nil;
|
||||
|
||||
subMsg = [TestAllTypes message];
|
||||
subMsg.repeatedInt32Array = [GPBInt32Array arrayWithValue:101];
|
||||
msg2.mapInt32Message = [GPBInt32ObjectDictionary dictionary];
|
||||
[msg2.mapInt32Message setValue:subMsg forKey:0];
|
||||
|
||||
[msg2.mapInt32Message setObject:subMsg forKey:0];
|
||||
subMsg = nil;
|
||||
|
||||
[msg1 mergeFrom:msg2];
|
||||
|
||||
// Checks repeated field is overwritten.
|
||||
XCTAssertEqual(msg1.mapInt32Message.count, 1U);
|
||||
subMsg = [msg1.mapInt32Message valueForKey:0];
|
||||
subMsg = [msg1.mapInt32Message objectForKey:0];
|
||||
XCTAssertNotNil(subMsg);
|
||||
XCTAssertEqual(subMsg.repeatedInt32Array.count, 1U);
|
||||
XCTAssertEqual([subMsg.repeatedInt32Array valueAtIndex:0], 101);
|
||||
|
|
|
@ -2059,9 +2059,9 @@
|
|||
|
||||
// Ensure the messages are unique per map.
|
||||
[msg1.mapInt32ForeignMessage
|
||||
enumerateKeysAndValuesUsingBlock:^(int32_t key, id value, BOOL *stop) {
|
||||
enumerateKeysAndObjectsUsingBlock:^(int32_t key, id value, BOOL *stop) {
|
||||
#pragma unused(stop)
|
||||
ForeignMessage *subMsg2 = [msg2.mapInt32ForeignMessage valueForKey:key];
|
||||
ForeignMessage *subMsg2 = [msg2.mapInt32ForeignMessage objectForKey:key];
|
||||
XCTAssertNotEqual(value, subMsg2); // Ptr compare, new object.
|
||||
}];
|
||||
}
|
||||
|
@ -2075,7 +2075,7 @@
|
|||
// Add an uninitialized message.
|
||||
TestRequired *subMsg = [[TestRequired alloc] init];
|
||||
msg.mapField = [GPBInt32ObjectDictionary dictionary];
|
||||
[msg.mapField setValue:subMsg forKey:0];
|
||||
[msg.mapField setObject:subMsg forKey:0];
|
||||
XCTAssertFalse(msg.initialized);
|
||||
|
||||
// Initialize uninitialized message
|
||||
|
|
|
@ -994,16 +994,16 @@ static NSData *DataFromCStr(const char *str) {
|
|||
val2.optionalInt32 = 129;
|
||||
[msg.mapStringMessage setValue:val1 forKey:@"228"];
|
||||
[msg.mapStringMessage setValue:val2 forKey:@"2029"];
|
||||
[msg.mapInt32Bytes setValue:DataFromCStr("1030 bytes") forKey:230];
|
||||
[msg.mapInt32Bytes setValue:DataFromCStr("131") forKey:2031];
|
||||
[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];
|
||||
Message2 *val3 = [[Message2 alloc] init];
|
||||
val3.optionalInt32 = 1034;
|
||||
Message2 *val4 = [[Message2 alloc] init];
|
||||
val4.optionalInt32 = 135;
|
||||
[msg.mapInt32Message setValue:val3 forKey:234];
|
||||
[msg.mapInt32Message setValue:val4 forKey:2035];
|
||||
[msg.mapInt32Message setObject:val3 forKey:234];
|
||||
[msg.mapInt32Message setObject:val4 forKey:2035];
|
||||
|
||||
NSData *data = [msg data];
|
||||
Message2 *msg2 = [[Message2 alloc] initWithData:data error:NULL];
|
||||
|
|
|
@ -1110,7 +1110,7 @@ const uint32_t kGPBDefaultRepeatCount = 2;
|
|||
[dataStr release];
|
||||
|
||||
NSData *data = [[NSData alloc] initWithUint32_gpbtu:i + 1];
|
||||
[message.mapInt32Bytes setValue:data forKey:113 + i * 100];
|
||||
[message.mapInt32Bytes setObject:data forKey:113 + i * 100];
|
||||
[data release];
|
||||
|
||||
[message.mapInt32Enum
|
||||
|
@ -1119,7 +1119,7 @@ const uint32_t kGPBDefaultRepeatCount = 2;
|
|||
|
||||
ForeignMessage *subMsg = [[ForeignMessage alloc] init];
|
||||
subMsg.c = i + 1;
|
||||
[message.mapInt32ForeignMessage setValue:subMsg forKey:115 + i * 100];
|
||||
[message.mapInt32ForeignMessage setObject:subMsg forKey:115 + i * 100];
|
||||
[subMsg release];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -167,12 +167,12 @@ const int kUnknownTypeId = 1550055;
|
|||
XCTAssertEqual([raw.itemArray[2] typeId], kUnknownTypeId);
|
||||
|
||||
TestMessageSetExtension1* message1 =
|
||||
[TestMessageSetExtension1 parseFromData:[raw.itemArray[0] message]
|
||||
[TestMessageSetExtension1 parseFromData:[((RawMessageSet_Item*)raw.itemArray[0]) message]
|
||||
error:NULL];
|
||||
XCTAssertEqual(message1.i, 123);
|
||||
|
||||
TestMessageSetExtension2* message2 =
|
||||
[TestMessageSetExtension2 parseFromData:[raw.itemArray[1] message]
|
||||
[TestMessageSetExtension2 parseFromData:[((RawMessageSet_Item*)raw.itemArray[1]) message]
|
||||
error:NULL];
|
||||
XCTAssertEqualObjects(message2.str, @"foo");
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue