Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Side by Side Diff: third_party/protobuf/objectivec/Tests/GPBDictionaryTests+Bool.m

Issue 2495533002: third_party/protobuf: Update to HEAD (83d681ee2c) (Closed)
Patch Set: Make chrome settings proto generated file a component Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Protocol Buffers - Google's data interchange format 1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2015 Google Inc. All rights reserved. 2 // Copyright 2015 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/ 3 // https://developers.google.com/protocol-buffers/
4 // 4 //
5 // Redistribution and use in source and binary forms, with or without 5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are 6 // modification, are permitted provided that the following conditions are
7 // met: 7 // met:
8 // 8 //
9 // * Redistributions of source code must retain the above copyright 9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer. 10 // notice, this list of conditions and the following disclaimer.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 @interface GPBBoolUInt32DictionaryTests : XCTestCase 48 @interface GPBBoolUInt32DictionaryTests : XCTestCase
49 @end 49 @end
50 50
51 @implementation GPBBoolUInt32DictionaryTests 51 @implementation GPBBoolUInt32DictionaryTests
52 52
53 - (void)testEmpty { 53 - (void)testEmpty {
54 GPBBoolUInt32Dictionary *dict = [[GPBBoolUInt32Dictionary alloc] init]; 54 GPBBoolUInt32Dictionary *dict = [[GPBBoolUInt32Dictionary alloc] init];
55 XCTAssertNotNil(dict); 55 XCTAssertNotNil(dict);
56 XCTAssertEqual(dict.count, 0U); 56 XCTAssertEqual(dict.count, 0U);
57 XCTAssertFalse([dict valueForKey:YES value:NULL]); 57 XCTAssertFalse([dict getUInt32:NULL forKey:YES]);
58 [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, uint32_t aValue, BOOL *sto p) { 58 [dict enumerateKeysAndUInt32sUsingBlock:^(BOOL aKey, uint32_t aValue, BOOL *st op) {
59 #pragma unused(aKey, aValue, stop) 59 #pragma unused(aKey, aValue, stop)
60 XCTFail(@"Shouldn't get here!"); 60 XCTFail(@"Shouldn't get here!");
61 }]; 61 }];
62 [dict release]; 62 [dict release];
63 } 63 }
64 64
65 - (void)testOne { 65 - (void)testOne {
66 GPBBoolUInt32Dictionary *dict = [GPBBoolUInt32Dictionary dictionaryWithValue:1 00U forKey:YES]; 66 GPBBoolUInt32Dictionary *dict = [GPBBoolUInt32Dictionary dictionaryWithUInt32: 100U forKey:YES];
67 XCTAssertNotNil(dict); 67 XCTAssertNotNil(dict);
68 XCTAssertEqual(dict.count, 1U); 68 XCTAssertEqual(dict.count, 1U);
69 uint32_t value; 69 uint32_t value;
70 XCTAssertTrue([dict valueForKey:YES value:NULL]); 70 XCTAssertTrue([dict getUInt32:NULL forKey:YES]);
71 XCTAssertTrue([dict valueForKey:YES value:&value]); 71 XCTAssertTrue([dict getUInt32:&value forKey:YES]);
72 XCTAssertEqual(value, 100U); 72 XCTAssertEqual(value, 100U);
73 XCTAssertFalse([dict valueForKey:NO value:NULL]); 73 XCTAssertFalse([dict getUInt32:NULL forKey:NO]);
74 [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, uint32_t aValue, BOOL *sto p) { 74 [dict enumerateKeysAndUInt32sUsingBlock:^(BOOL aKey, uint32_t aValue, BOOL *st op) {
75 XCTAssertEqual(aKey, YES); 75 XCTAssertEqual(aKey, YES);
76 XCTAssertEqual(aValue, 100U); 76 XCTAssertEqual(aValue, 100U);
77 XCTAssertNotEqual(stop, NULL); 77 XCTAssertNotEqual(stop, NULL);
78 }]; 78 }];
79 } 79 }
80 80
81 - (void)testBasics { 81 - (void)testBasics {
82 const BOOL kKeys[] = { YES, NO }; 82 const BOOL kKeys[] = { YES, NO };
83 const uint32_t kValues[] = { 100U, 101U }; 83 const uint32_t kValues[] = { 100U, 101U };
84 GPBBoolUInt32Dictionary *dict = 84 GPBBoolUInt32Dictionary *dict =
85 [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues 85 [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues
86 forKeys:kKeys 86 forKeys:kKeys
87 count:GPBARRAYSIZE(kValues)]; 87 count:GPBARRAYSIZE(kValues)];
88 XCTAssertNotNil(dict); 88 XCTAssertNotNil(dict);
89 XCTAssertEqual(dict.count, 2U); 89 XCTAssertEqual(dict.count, 2U);
90 uint32_t value; 90 uint32_t value;
91 XCTAssertTrue([dict valueForKey:YES value:NULL]); 91 XCTAssertTrue([dict getUInt32:NULL forKey:YES]);
92 XCTAssertTrue([dict valueForKey:YES value:&value]); 92 XCTAssertTrue([dict getUInt32:&value forKey:YES]);
93 XCTAssertEqual(value, 100U); 93 XCTAssertEqual(value, 100U);
94 XCTAssertTrue([dict valueForKey:NO value:NULL]); 94 XCTAssertTrue([dict getUInt32:NULL forKey:NO]);
95 XCTAssertTrue([dict valueForKey:NO value:&value]); 95 XCTAssertTrue([dict getUInt32:&value forKey:NO]);
96 XCTAssertEqual(value, 101U); 96 XCTAssertEqual(value, 101U);
97 97
98 __block NSUInteger idx = 0; 98 __block NSUInteger idx = 0;
99 BOOL *seenKeys = malloc(2 * sizeof(BOOL)); 99 BOOL *seenKeys = malloc(2 * sizeof(BOOL));
100 uint32_t *seenValues = malloc(2 * sizeof(uint32_t)); 100 uint32_t *seenValues = malloc(2 * sizeof(uint32_t));
101 [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, uint32_t aValue, BOOL *sto p) { 101 [dict enumerateKeysAndUInt32sUsingBlock:^(BOOL aKey, uint32_t aValue, BOOL *st op) {
102 XCTAssertLessThan(idx, 2U); 102 XCTAssertLessThan(idx, 2U);
103 seenKeys[idx] = aKey; 103 seenKeys[idx] = aKey;
104 seenValues[idx] = aValue; 104 seenValues[idx] = aValue;
105 XCTAssertNotEqual(stop, NULL); 105 XCTAssertNotEqual(stop, NULL);
106 ++idx; 106 ++idx;
107 }]; 107 }];
108 for (int i = 0; i < 2; ++i) { 108 for (int i = 0; i < 2; ++i) {
109 BOOL foundKey = NO; 109 BOOL foundKey = NO;
110 for (int j = 0; (j < 2) && !foundKey; ++j) { 110 for (int j = 0; (j < 2) && !foundKey; ++j) {
111 if (kKeys[i] == seenKeys[j]) { 111 if (kKeys[i] == seenKeys[j]) {
112 foundKey = YES; 112 foundKey = YES;
113 XCTAssertEqual(kValues[i], seenValues[j], @"i = %d, j = %d", i, j); 113 XCTAssertEqual(kValues[i], seenValues[j], @"i = %d, j = %d", i, j);
114 } 114 }
115 } 115 }
116 XCTAssertTrue(foundKey, @"i = %d", i); 116 XCTAssertTrue(foundKey, @"i = %d", i);
117 } 117 }
118 free(seenKeys); 118 free(seenKeys);
119 free(seenValues); 119 free(seenValues);
120 120
121 // Stopping the enumeration. 121 // Stopping the enumeration.
122 idx = 0; 122 idx = 0;
123 [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, uint32_t aValue, BOOL *sto p) { 123 [dict enumerateKeysAndUInt32sUsingBlock:^(BOOL aKey, uint32_t aValue, BOOL *st op) {
124 #pragma unused(aKey, aValue) 124 #pragma unused(aKey, aValue)
125 if (idx == 0) *stop = YES; 125 if (idx == 0) *stop = YES;
126 XCTAssertNotEqual(idx, 2U); 126 XCTAssertNotEqual(idx, 2U);
127 ++idx; 127 ++idx;
128 }]; 128 }];
129 [dict release]; 129 [dict release];
130 } 130 }
131 131
132 - (void)testEquality { 132 - (void)testEquality {
133 const BOOL kKeys1[] = { YES, NO }; 133 const BOOL kKeys1[] = { YES, NO };
134 const BOOL kKeys2[] = { NO, YES }; 134 const BOOL kKeys2[] = { NO, YES };
135 const uint32_t kValues1[] = { 100U, 101U }; 135 const uint32_t kValues1[] = { 100U, 101U };
136 const uint32_t kValues2[] = { 101U, 100U }; 136 const uint32_t kValues2[] = { 101U, 100U };
137 const uint32_t kValues3[] = { 101U }; 137 const uint32_t kValues3[] = { 101U };
138 GPBBoolUInt32Dictionary *dict1 = 138 GPBBoolUInt32Dictionary *dict1 =
139 [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues1 139 [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues1
140 forKeys:kKeys1 140 forKeys:kKeys1
141 count:GPBARRAYSIZE(kValues1)]; 141 count:GPBARRAYSIZE(kValues1)];
142 XCTAssertNotNil(dict1); 142 XCTAssertNotNil(dict1);
143 GPBBoolUInt32Dictionary *dict1prime = 143 GPBBoolUInt32Dictionary *dict1prime =
144 [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues1 144 [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues1
145 forKeys:kKeys1 145 forKeys:kKeys1
146 count:GPBARRAYSIZE(kValues1)]; 146 count:GPBARRAYSIZE(kValues1)];
147 XCTAssertNotNil(dict1prime); 147 XCTAssertNotNil(dict1prime);
148 GPBBoolUInt32Dictionary *dict2 = 148 GPBBoolUInt32Dictionary *dict2 =
149 [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues2 149 [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues2
150 forKeys:kKeys1 150 forKeys:kKeys1
151 count:GPBARRAYSIZE(kValues2)]; 151 count:GPBARRAYSIZE(kValues2)];
152 XCTAssertNotNil(dict2); 152 XCTAssertNotNil(dict2);
153 GPBBoolUInt32Dictionary *dict3 = 153 GPBBoolUInt32Dictionary *dict3 =
154 [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues1 154 [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues1
155 forKeys:kKeys2 155 forKeys:kKeys2
156 count:GPBARRAYSIZE(kValues1)]; 156 count:GPBARRAYSIZE(kValues1)];
157 XCTAssertNotNil(dict3); 157 XCTAssertNotNil(dict3);
158 GPBBoolUInt32Dictionary *dict4 = 158 GPBBoolUInt32Dictionary *dict4 =
159 [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues3 159 [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues3
160 forKeys:kKeys1 160 forKeys:kKeys1
161 count:GPBARRAYSIZE(kValues3)]; 161 count:GPBARRAYSIZE(kValues3)];
162 XCTAssertNotNil(dict4); 162 XCTAssertNotNil(dict4);
163 163
164 // 1/1Prime should be different objects, but equal. 164 // 1/1Prime should be different objects, but equal.
165 XCTAssertNotEqual(dict1, dict1prime); 165 XCTAssertNotEqual(dict1, dict1prime);
166 XCTAssertEqualObjects(dict1, dict1prime); 166 XCTAssertEqualObjects(dict1, dict1prime);
167 // Equal, so they must have same hash. 167 // Equal, so they must have same hash.
168 XCTAssertEqual([dict1 hash], [dict1prime hash]); 168 XCTAssertEqual([dict1 hash], [dict1prime hash]);
169 169
170 // 2 is same keys, different values; not equal. 170 // 2 is same keys, different values; not equal.
171 XCTAssertNotEqualObjects(dict1, dict2); 171 XCTAssertNotEqualObjects(dict1, dict2);
172 172
173 // 3 is different keys, same values; not equal. 173 // 3 is different keys, same values; not equal.
174 XCTAssertNotEqualObjects(dict1, dict3); 174 XCTAssertNotEqualObjects(dict1, dict3);
175 175
176 // 4 Fewer pairs; not equal 176 // 4 Fewer pairs; not equal
177 XCTAssertNotEqualObjects(dict1, dict4); 177 XCTAssertNotEqualObjects(dict1, dict4);
178 178
179 [dict1 release]; 179 [dict1 release];
180 [dict1prime release]; 180 [dict1prime release];
181 [dict2 release]; 181 [dict2 release];
182 [dict3 release]; 182 [dict3 release];
183 [dict4 release]; 183 [dict4 release];
184 } 184 }
185 185
186 - (void)testCopy { 186 - (void)testCopy {
187 const BOOL kKeys[] = { YES, NO }; 187 const BOOL kKeys[] = { YES, NO };
188 const uint32_t kValues[] = { 100U, 101U }; 188 const uint32_t kValues[] = { 100U, 101U };
189 GPBBoolUInt32Dictionary *dict = 189 GPBBoolUInt32Dictionary *dict =
190 [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues 190 [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues
191 forKeys:kKeys 191 forKeys:kKeys
192 count:GPBARRAYSIZE(kValues)]; 192 count:GPBARRAYSIZE(kValues)];
193 XCTAssertNotNil(dict); 193 XCTAssertNotNil(dict);
194 194
195 GPBBoolUInt32Dictionary *dict2 = [dict copy]; 195 GPBBoolUInt32Dictionary *dict2 = [dict copy];
196 XCTAssertNotNil(dict2); 196 XCTAssertNotNil(dict2);
197 197
198 // Should be new object but equal. 198 // Should be new object but equal.
199 XCTAssertNotEqual(dict, dict2); 199 XCTAssertNotEqual(dict, dict2);
200 XCTAssertEqualObjects(dict, dict2); 200 XCTAssertEqualObjects(dict, dict2);
201 XCTAssertTrue([dict2 isKindOfClass:[GPBBoolUInt32Dictionary class]]); 201 XCTAssertTrue([dict2 isKindOfClass:[GPBBoolUInt32Dictionary class]]);
202 202
203 [dict2 release]; 203 [dict2 release];
204 [dict release]; 204 [dict release];
205 } 205 }
206 206
207 - (void)testDictionaryFromDictionary { 207 - (void)testDictionaryFromDictionary {
208 const BOOL kKeys[] = { YES, NO }; 208 const BOOL kKeys[] = { YES, NO };
209 const uint32_t kValues[] = { 100U, 101U }; 209 const uint32_t kValues[] = { 100U, 101U };
210 GPBBoolUInt32Dictionary *dict = 210 GPBBoolUInt32Dictionary *dict =
211 [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues 211 [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues
212 forKeys:kKeys 212 forKeys:kKeys
213 count:GPBARRAYSIZE(kValues)]; 213 count:GPBARRAYSIZE(kValues)];
214 XCTAssertNotNil(dict); 214 XCTAssertNotNil(dict);
215 215
216 GPBBoolUInt32Dictionary *dict2 = 216 GPBBoolUInt32Dictionary *dict2 =
217 [GPBBoolUInt32Dictionary dictionaryWithDictionary:dict]; 217 [GPBBoolUInt32Dictionary dictionaryWithDictionary:dict];
218 XCTAssertNotNil(dict2); 218 XCTAssertNotNil(dict2);
219 219
220 // Should be new pointer, but equal objects. 220 // Should be new pointer, but equal objects.
221 XCTAssertNotEqual(dict, dict2); 221 XCTAssertNotEqual(dict, dict2);
222 XCTAssertEqualObjects(dict, dict2); 222 XCTAssertEqualObjects(dict, dict2);
223 [dict release]; 223 [dict release];
224 } 224 }
225 225
226 - (void)testAdds { 226 - (void)testAdds {
227 GPBBoolUInt32Dictionary *dict = [GPBBoolUInt32Dictionary dictionary]; 227 GPBBoolUInt32Dictionary *dict = [GPBBoolUInt32Dictionary dictionary];
228 XCTAssertNotNil(dict); 228 XCTAssertNotNil(dict);
229 229
230 XCTAssertEqual(dict.count, 0U); 230 XCTAssertEqual(dict.count, 0U);
231 [dict setValue:100U forKey:YES]; 231 [dict setUInt32:100U forKey:YES];
232 XCTAssertEqual(dict.count, 1U); 232 XCTAssertEqual(dict.count, 1U);
233 233
234 const BOOL kKeys[] = { NO }; 234 const BOOL kKeys[] = { NO };
235 const uint32_t kValues[] = { 101U }; 235 const uint32_t kValues[] = { 101U };
236 GPBBoolUInt32Dictionary *dict2 = 236 GPBBoolUInt32Dictionary *dict2 =
237 [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues 237 [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues
238 forKeys:kKeys 238 forKeys:kKeys
239 count:GPBARRAYSIZE(kValues)]; 239 count:GPBARRAYSIZE(kValues)];
240 XCTAssertNotNil(dict2); 240 XCTAssertNotNil(dict2);
241 [dict addEntriesFromDictionary:dict2]; 241 [dict addEntriesFromDictionary:dict2];
242 XCTAssertEqual(dict.count, 2U); 242 XCTAssertEqual(dict.count, 2U);
243 243
244 uint32_t value; 244 uint32_t value;
245 XCTAssertTrue([dict valueForKey:YES value:NULL]); 245 XCTAssertTrue([dict getUInt32:NULL forKey:YES]);
246 XCTAssertTrue([dict valueForKey:YES value:&value]); 246 XCTAssertTrue([dict getUInt32:&value forKey:YES]);
247 XCTAssertEqual(value, 100U); 247 XCTAssertEqual(value, 100U);
248 XCTAssertTrue([dict valueForKey:NO value:NULL]); 248 XCTAssertTrue([dict getUInt32:NULL forKey:NO]);
249 XCTAssertTrue([dict valueForKey:NO value:&value]); 249 XCTAssertTrue([dict getUInt32:&value forKey:NO]);
250 XCTAssertEqual(value, 101U); 250 XCTAssertEqual(value, 101U);
251 [dict2 release]; 251 [dict2 release];
252 } 252 }
253 253
254 - (void)testRemove { 254 - (void)testRemove {
255 const BOOL kKeys[] = { YES, NO}; 255 const BOOL kKeys[] = { YES, NO};
256 const uint32_t kValues[] = { 100U, 101U }; 256 const uint32_t kValues[] = { 100U, 101U };
257 GPBBoolUInt32Dictionary *dict = 257 GPBBoolUInt32Dictionary *dict =
258 [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues 258 [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues
259 forKeys:kKeys 259 forKeys:kKeys
260 count:GPBARRAYSIZE(kValues)]; 260 count:GPBARRAYSIZE(kValues)];
261 XCTAssertNotNil(dict); 261 XCTAssertNotNil(dict);
262 XCTAssertEqual(dict.count, 2U); 262 XCTAssertEqual(dict.count, 2U);
263 263
264 [dict removeValueForKey:NO]; 264 [dict removeUInt32ForKey:NO];
265 XCTAssertEqual(dict.count, 1U); 265 XCTAssertEqual(dict.count, 1U);
266 uint32_t value; 266 uint32_t value;
267 XCTAssertTrue([dict valueForKey:YES value:NULL]); 267 XCTAssertTrue([dict getUInt32:NULL forKey:YES]);
268 XCTAssertTrue([dict valueForKey:YES value:&value]); 268 XCTAssertTrue([dict getUInt32:&value forKey:YES]);
269 XCTAssertEqual(value, 100U); 269 XCTAssertEqual(value, 100U);
270 XCTAssertFalse([dict valueForKey:NO value:NULL]); 270 XCTAssertFalse([dict getUInt32:NULL forKey:NO]);
271 271
272 // Remove again does nothing. 272 // Remove again does nothing.
273 [dict removeValueForKey:NO]; 273 [dict removeUInt32ForKey:NO];
274 XCTAssertEqual(dict.count, 1U); 274 XCTAssertEqual(dict.count, 1U);
275 XCTAssertTrue([dict valueForKey:YES value:NULL]); 275 XCTAssertTrue([dict getUInt32:NULL forKey:YES]);
276 XCTAssertTrue([dict valueForKey:YES value:&value]); 276 XCTAssertTrue([dict getUInt32:&value forKey:YES]);
277 XCTAssertEqual(value, 100U); 277 XCTAssertEqual(value, 100U);
278 XCTAssertFalse([dict valueForKey:NO value:NULL]); 278 XCTAssertFalse([dict getUInt32:NULL forKey:NO]);
279 279
280 [dict removeAll]; 280 [dict removeAll];
281 XCTAssertEqual(dict.count, 0U); 281 XCTAssertEqual(dict.count, 0U);
282 XCTAssertFalse([dict valueForKey:YES value:NULL]); 282 XCTAssertFalse([dict getUInt32:NULL forKey:YES]);
283 XCTAssertFalse([dict valueForKey:NO value:NULL]); 283 XCTAssertFalse([dict getUInt32:NULL forKey:NO]);
284 [dict release]; 284 [dict release];
285 } 285 }
286 286
287 - (void)testInplaceMutation { 287 - (void)testInplaceMutation {
288 const BOOL kKeys[] = { YES, NO }; 288 const BOOL kKeys[] = { YES, NO };
289 const uint32_t kValues[] = { 100U, 101U }; 289 const uint32_t kValues[] = { 100U, 101U };
290 GPBBoolUInt32Dictionary *dict = 290 GPBBoolUInt32Dictionary *dict =
291 [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues 291 [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues
292 forKeys:kKeys 292 forKeys:kKeys
293 count:GPBARRAYSIZE(kValues)]; 293 count:GPBARRAYSIZE(kValues)];
294 XCTAssertNotNil(dict); 294 XCTAssertNotNil(dict);
295 XCTAssertEqual(dict.count, 2U); 295 XCTAssertEqual(dict.count, 2U);
296 uint32_t value; 296 uint32_t value;
297 XCTAssertTrue([dict valueForKey:YES value:NULL]); 297 XCTAssertTrue([dict getUInt32:NULL forKey:YES]);
298 XCTAssertTrue([dict valueForKey:YES value:&value]); 298 XCTAssertTrue([dict getUInt32:&value forKey:YES]);
299 XCTAssertEqual(value, 100U); 299 XCTAssertEqual(value, 100U);
300 XCTAssertTrue([dict valueForKey:NO value:NULL]); 300 XCTAssertTrue([dict getUInt32:NULL forKey:NO]);
301 XCTAssertTrue([dict valueForKey:NO value:&value]); 301 XCTAssertTrue([dict getUInt32:&value forKey:NO]);
302 XCTAssertEqual(value, 101U); 302 XCTAssertEqual(value, 101U);
303 303
304 [dict setValue:101U forKey:YES]; 304 [dict setUInt32:101U forKey:YES];
305 XCTAssertEqual(dict.count, 2U); 305 XCTAssertEqual(dict.count, 2U);
306 XCTAssertTrue([dict valueForKey:YES value:NULL]); 306 XCTAssertTrue([dict getUInt32:NULL forKey:YES]);
307 XCTAssertTrue([dict valueForKey:YES value:&value]); 307 XCTAssertTrue([dict getUInt32:&value forKey:YES]);
308 XCTAssertEqual(value, 101U); 308 XCTAssertEqual(value, 101U);
309 XCTAssertTrue([dict valueForKey:NO value:NULL]); 309 XCTAssertTrue([dict getUInt32:NULL forKey:NO]);
310 XCTAssertTrue([dict valueForKey:NO value:&value]); 310 XCTAssertTrue([dict getUInt32:&value forKey:NO]);
311 XCTAssertEqual(value, 101U); 311 XCTAssertEqual(value, 101U);
312 312
313 [dict setValue:100U forKey:NO]; 313 [dict setUInt32:100U forKey:NO];
314 XCTAssertEqual(dict.count, 2U); 314 XCTAssertEqual(dict.count, 2U);
315 XCTAssertTrue([dict valueForKey:YES value:NULL]); 315 XCTAssertTrue([dict getUInt32:NULL forKey:YES]);
316 XCTAssertTrue([dict valueForKey:YES value:&value]); 316 XCTAssertTrue([dict getUInt32:&value forKey:YES]);
317 XCTAssertEqual(value, 101U); 317 XCTAssertEqual(value, 101U);
318 XCTAssertTrue([dict valueForKey:NO value:NULL]); 318 XCTAssertTrue([dict getUInt32:NULL forKey:NO]);
319 XCTAssertTrue([dict valueForKey:NO value:&value]); 319 XCTAssertTrue([dict getUInt32:&value forKey:NO]);
320 XCTAssertEqual(value, 100U); 320 XCTAssertEqual(value, 100U);
321 321
322 const BOOL kKeys2[] = { NO, YES }; 322 const BOOL kKeys2[] = { NO, YES };
323 const uint32_t kValues2[] = { 101U, 100U }; 323 const uint32_t kValues2[] = { 101U, 100U };
324 GPBBoolUInt32Dictionary *dict2 = 324 GPBBoolUInt32Dictionary *dict2 =
325 [[GPBBoolUInt32Dictionary alloc] initWithValues:kValues2 325 [[GPBBoolUInt32Dictionary alloc] initWithUInt32s:kValues2
326 forKeys:kKeys2 326 forKeys:kKeys2
327 count:GPBARRAYSIZE(kValues2)]; 327 count:GPBARRAYSIZE(kValues2)];
328 XCTAssertNotNil(dict2); 328 XCTAssertNotNil(dict2);
329 [dict addEntriesFromDictionary:dict2]; 329 [dict addEntriesFromDictionary:dict2];
330 XCTAssertEqual(dict.count, 2U); 330 XCTAssertEqual(dict.count, 2U);
331 XCTAssertTrue([dict valueForKey:YES value:NULL]); 331 XCTAssertTrue([dict getUInt32:NULL forKey:YES]);
332 XCTAssertTrue([dict valueForKey:YES value:&value]); 332 XCTAssertTrue([dict getUInt32:&value forKey:YES]);
333 XCTAssertEqual(value, 100U); 333 XCTAssertEqual(value, 100U);
334 XCTAssertTrue([dict valueForKey:NO value:NULL]); 334 XCTAssertTrue([dict getUInt32:NULL forKey:NO]);
335 XCTAssertTrue([dict valueForKey:NO value:&value]); 335 XCTAssertTrue([dict getUInt32:&value forKey:NO]);
336 XCTAssertEqual(value, 101U); 336 XCTAssertEqual(value, 101U);
337 337
338 [dict2 release]; 338 [dict2 release];
339 [dict release]; 339 [dict release];
340 } 340 }
341 341
342 @end 342 @end
343 343
344 //%PDDM-EXPAND BOOL_TESTS_FOR_POD_VALUE(Int32, int32_t, 200, 201) 344 //%PDDM-EXPAND BOOL_TESTS_FOR_POD_VALUE(Int32, int32_t, 200, 201)
345 // This block of code is generated, do not edit it directly. 345 // This block of code is generated, do not edit it directly.
346 346
347 #pragma mark - Bool -> Int32 347 #pragma mark - Bool -> Int32
348 348
349 @interface GPBBoolInt32DictionaryTests : XCTestCase 349 @interface GPBBoolInt32DictionaryTests : XCTestCase
350 @end 350 @end
351 351
352 @implementation GPBBoolInt32DictionaryTests 352 @implementation GPBBoolInt32DictionaryTests
353 353
354 - (void)testEmpty { 354 - (void)testEmpty {
355 GPBBoolInt32Dictionary *dict = [[GPBBoolInt32Dictionary alloc] init]; 355 GPBBoolInt32Dictionary *dict = [[GPBBoolInt32Dictionary alloc] init];
356 XCTAssertNotNil(dict); 356 XCTAssertNotNil(dict);
357 XCTAssertEqual(dict.count, 0U); 357 XCTAssertEqual(dict.count, 0U);
358 XCTAssertFalse([dict valueForKey:YES value:NULL]); 358 XCTAssertFalse([dict getInt32:NULL forKey:YES]);
359 [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, int32_t aValue, BOOL *stop ) { 359 [dict enumerateKeysAndInt32sUsingBlock:^(BOOL aKey, int32_t aValue, BOOL *stop ) {
360 #pragma unused(aKey, aValue, stop) 360 #pragma unused(aKey, aValue, stop)
361 XCTFail(@"Shouldn't get here!"); 361 XCTFail(@"Shouldn't get here!");
362 }]; 362 }];
363 [dict release]; 363 [dict release];
364 } 364 }
365 365
366 - (void)testOne { 366 - (void)testOne {
367 GPBBoolInt32Dictionary *dict = [GPBBoolInt32Dictionary dictionaryWithValue:200 forKey:YES]; 367 GPBBoolInt32Dictionary *dict = [GPBBoolInt32Dictionary dictionaryWithInt32:200 forKey:YES];
368 XCTAssertNotNil(dict); 368 XCTAssertNotNil(dict);
369 XCTAssertEqual(dict.count, 1U); 369 XCTAssertEqual(dict.count, 1U);
370 int32_t value; 370 int32_t value;
371 XCTAssertTrue([dict valueForKey:YES value:NULL]); 371 XCTAssertTrue([dict getInt32:NULL forKey:YES]);
372 XCTAssertTrue([dict valueForKey:YES value:&value]); 372 XCTAssertTrue([dict getInt32:&value forKey:YES]);
373 XCTAssertEqual(value, 200); 373 XCTAssertEqual(value, 200);
374 XCTAssertFalse([dict valueForKey:NO value:NULL]); 374 XCTAssertFalse([dict getInt32:NULL forKey:NO]);
375 [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, int32_t aValue, BOOL *stop ) { 375 [dict enumerateKeysAndInt32sUsingBlock:^(BOOL aKey, int32_t aValue, BOOL *stop ) {
376 XCTAssertEqual(aKey, YES); 376 XCTAssertEqual(aKey, YES);
377 XCTAssertEqual(aValue, 200); 377 XCTAssertEqual(aValue, 200);
378 XCTAssertNotEqual(stop, NULL); 378 XCTAssertNotEqual(stop, NULL);
379 }]; 379 }];
380 } 380 }
381 381
382 - (void)testBasics { 382 - (void)testBasics {
383 const BOOL kKeys[] = { YES, NO }; 383 const BOOL kKeys[] = { YES, NO };
384 const int32_t kValues[] = { 200, 201 }; 384 const int32_t kValues[] = { 200, 201 };
385 GPBBoolInt32Dictionary *dict = 385 GPBBoolInt32Dictionary *dict =
386 [[GPBBoolInt32Dictionary alloc] initWithValues:kValues 386 [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues
387 forKeys:kKeys 387 forKeys:kKeys
388 count:GPBARRAYSIZE(kValues)]; 388 count:GPBARRAYSIZE(kValues)];
389 XCTAssertNotNil(dict); 389 XCTAssertNotNil(dict);
390 XCTAssertEqual(dict.count, 2U); 390 XCTAssertEqual(dict.count, 2U);
391 int32_t value; 391 int32_t value;
392 XCTAssertTrue([dict valueForKey:YES value:NULL]); 392 XCTAssertTrue([dict getInt32:NULL forKey:YES]);
393 XCTAssertTrue([dict valueForKey:YES value:&value]); 393 XCTAssertTrue([dict getInt32:&value forKey:YES]);
394 XCTAssertEqual(value, 200); 394 XCTAssertEqual(value, 200);
395 XCTAssertTrue([dict valueForKey:NO value:NULL]); 395 XCTAssertTrue([dict getInt32:NULL forKey:NO]);
396 XCTAssertTrue([dict valueForKey:NO value:&value]); 396 XCTAssertTrue([dict getInt32:&value forKey:NO]);
397 XCTAssertEqual(value, 201); 397 XCTAssertEqual(value, 201);
398 398
399 __block NSUInteger idx = 0; 399 __block NSUInteger idx = 0;
400 BOOL *seenKeys = malloc(2 * sizeof(BOOL)); 400 BOOL *seenKeys = malloc(2 * sizeof(BOOL));
401 int32_t *seenValues = malloc(2 * sizeof(int32_t)); 401 int32_t *seenValues = malloc(2 * sizeof(int32_t));
402 [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, int32_t aValue, BOOL *stop ) { 402 [dict enumerateKeysAndInt32sUsingBlock:^(BOOL aKey, int32_t aValue, BOOL *stop ) {
403 XCTAssertLessThan(idx, 2U); 403 XCTAssertLessThan(idx, 2U);
404 seenKeys[idx] = aKey; 404 seenKeys[idx] = aKey;
405 seenValues[idx] = aValue; 405 seenValues[idx] = aValue;
406 XCTAssertNotEqual(stop, NULL); 406 XCTAssertNotEqual(stop, NULL);
407 ++idx; 407 ++idx;
408 }]; 408 }];
409 for (int i = 0; i < 2; ++i) { 409 for (int i = 0; i < 2; ++i) {
410 BOOL foundKey = NO; 410 BOOL foundKey = NO;
411 for (int j = 0; (j < 2) && !foundKey; ++j) { 411 for (int j = 0; (j < 2) && !foundKey; ++j) {
412 if (kKeys[i] == seenKeys[j]) { 412 if (kKeys[i] == seenKeys[j]) {
413 foundKey = YES; 413 foundKey = YES;
414 XCTAssertEqual(kValues[i], seenValues[j], @"i = %d, j = %d", i, j); 414 XCTAssertEqual(kValues[i], seenValues[j], @"i = %d, j = %d", i, j);
415 } 415 }
416 } 416 }
417 XCTAssertTrue(foundKey, @"i = %d", i); 417 XCTAssertTrue(foundKey, @"i = %d", i);
418 } 418 }
419 free(seenKeys); 419 free(seenKeys);
420 free(seenValues); 420 free(seenValues);
421 421
422 // Stopping the enumeration. 422 // Stopping the enumeration.
423 idx = 0; 423 idx = 0;
424 [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, int32_t aValue, BOOL *stop ) { 424 [dict enumerateKeysAndInt32sUsingBlock:^(BOOL aKey, int32_t aValue, BOOL *stop ) {
425 #pragma unused(aKey, aValue) 425 #pragma unused(aKey, aValue)
426 if (idx == 0) *stop = YES; 426 if (idx == 0) *stop = YES;
427 XCTAssertNotEqual(idx, 2U); 427 XCTAssertNotEqual(idx, 2U);
428 ++idx; 428 ++idx;
429 }]; 429 }];
430 [dict release]; 430 [dict release];
431 } 431 }
432 432
433 - (void)testEquality { 433 - (void)testEquality {
434 const BOOL kKeys1[] = { YES, NO }; 434 const BOOL kKeys1[] = { YES, NO };
435 const BOOL kKeys2[] = { NO, YES }; 435 const BOOL kKeys2[] = { NO, YES };
436 const int32_t kValues1[] = { 200, 201 }; 436 const int32_t kValues1[] = { 200, 201 };
437 const int32_t kValues2[] = { 201, 200 }; 437 const int32_t kValues2[] = { 201, 200 };
438 const int32_t kValues3[] = { 201 }; 438 const int32_t kValues3[] = { 201 };
439 GPBBoolInt32Dictionary *dict1 = 439 GPBBoolInt32Dictionary *dict1 =
440 [[GPBBoolInt32Dictionary alloc] initWithValues:kValues1 440 [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues1
441 forKeys:kKeys1 441 forKeys:kKeys1
442 count:GPBARRAYSIZE(kValues1)]; 442 count:GPBARRAYSIZE(kValues1)];
443 XCTAssertNotNil(dict1); 443 XCTAssertNotNil(dict1);
444 GPBBoolInt32Dictionary *dict1prime = 444 GPBBoolInt32Dictionary *dict1prime =
445 [[GPBBoolInt32Dictionary alloc] initWithValues:kValues1 445 [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues1
446 forKeys:kKeys1 446 forKeys:kKeys1
447 count:GPBARRAYSIZE(kValues1)]; 447 count:GPBARRAYSIZE(kValues1)];
448 XCTAssertNotNil(dict1prime); 448 XCTAssertNotNil(dict1prime);
449 GPBBoolInt32Dictionary *dict2 = 449 GPBBoolInt32Dictionary *dict2 =
450 [[GPBBoolInt32Dictionary alloc] initWithValues:kValues2 450 [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues2
451 forKeys:kKeys1 451 forKeys:kKeys1
452 count:GPBARRAYSIZE(kValues2)]; 452 count:GPBARRAYSIZE(kValues2)];
453 XCTAssertNotNil(dict2); 453 XCTAssertNotNil(dict2);
454 GPBBoolInt32Dictionary *dict3 = 454 GPBBoolInt32Dictionary *dict3 =
455 [[GPBBoolInt32Dictionary alloc] initWithValues:kValues1 455 [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues1
456 forKeys:kKeys2 456 forKeys:kKeys2
457 count:GPBARRAYSIZE(kValues1)]; 457 count:GPBARRAYSIZE(kValues1)];
458 XCTAssertNotNil(dict3); 458 XCTAssertNotNil(dict3);
459 GPBBoolInt32Dictionary *dict4 = 459 GPBBoolInt32Dictionary *dict4 =
460 [[GPBBoolInt32Dictionary alloc] initWithValues:kValues3 460 [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues3
461 forKeys:kKeys1 461 forKeys:kKeys1
462 count:GPBARRAYSIZE(kValues3)]; 462 count:GPBARRAYSIZE(kValues3)];
463 XCTAssertNotNil(dict4); 463 XCTAssertNotNil(dict4);
464 464
465 // 1/1Prime should be different objects, but equal. 465 // 1/1Prime should be different objects, but equal.
466 XCTAssertNotEqual(dict1, dict1prime); 466 XCTAssertNotEqual(dict1, dict1prime);
467 XCTAssertEqualObjects(dict1, dict1prime); 467 XCTAssertEqualObjects(dict1, dict1prime);
468 // Equal, so they must have same hash. 468 // Equal, so they must have same hash.
469 XCTAssertEqual([dict1 hash], [dict1prime hash]); 469 XCTAssertEqual([dict1 hash], [dict1prime hash]);
470 470
(...skipping 10 matching lines...) Expand all
481 [dict1prime release]; 481 [dict1prime release];
482 [dict2 release]; 482 [dict2 release];
483 [dict3 release]; 483 [dict3 release];
484 [dict4 release]; 484 [dict4 release];
485 } 485 }
486 486
487 - (void)testCopy { 487 - (void)testCopy {
488 const BOOL kKeys[] = { YES, NO }; 488 const BOOL kKeys[] = { YES, NO };
489 const int32_t kValues[] = { 200, 201 }; 489 const int32_t kValues[] = { 200, 201 };
490 GPBBoolInt32Dictionary *dict = 490 GPBBoolInt32Dictionary *dict =
491 [[GPBBoolInt32Dictionary alloc] initWithValues:kValues 491 [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues
492 forKeys:kKeys 492 forKeys:kKeys
493 count:GPBARRAYSIZE(kValues)]; 493 count:GPBARRAYSIZE(kValues)];
494 XCTAssertNotNil(dict); 494 XCTAssertNotNil(dict);
495 495
496 GPBBoolInt32Dictionary *dict2 = [dict copy]; 496 GPBBoolInt32Dictionary *dict2 = [dict copy];
497 XCTAssertNotNil(dict2); 497 XCTAssertNotNil(dict2);
498 498
499 // Should be new object but equal. 499 // Should be new object but equal.
500 XCTAssertNotEqual(dict, dict2); 500 XCTAssertNotEqual(dict, dict2);
501 XCTAssertEqualObjects(dict, dict2); 501 XCTAssertEqualObjects(dict, dict2);
502 XCTAssertTrue([dict2 isKindOfClass:[GPBBoolInt32Dictionary class]]); 502 XCTAssertTrue([dict2 isKindOfClass:[GPBBoolInt32Dictionary class]]);
503 503
504 [dict2 release]; 504 [dict2 release];
505 [dict release]; 505 [dict release];
506 } 506 }
507 507
508 - (void)testDictionaryFromDictionary { 508 - (void)testDictionaryFromDictionary {
509 const BOOL kKeys[] = { YES, NO }; 509 const BOOL kKeys[] = { YES, NO };
510 const int32_t kValues[] = { 200, 201 }; 510 const int32_t kValues[] = { 200, 201 };
511 GPBBoolInt32Dictionary *dict = 511 GPBBoolInt32Dictionary *dict =
512 [[GPBBoolInt32Dictionary alloc] initWithValues:kValues 512 [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues
513 forKeys:kKeys 513 forKeys:kKeys
514 count:GPBARRAYSIZE(kValues)]; 514 count:GPBARRAYSIZE(kValues)];
515 XCTAssertNotNil(dict); 515 XCTAssertNotNil(dict);
516 516
517 GPBBoolInt32Dictionary *dict2 = 517 GPBBoolInt32Dictionary *dict2 =
518 [GPBBoolInt32Dictionary dictionaryWithDictionary:dict]; 518 [GPBBoolInt32Dictionary dictionaryWithDictionary:dict];
519 XCTAssertNotNil(dict2); 519 XCTAssertNotNil(dict2);
520 520
521 // Should be new pointer, but equal objects. 521 // Should be new pointer, but equal objects.
522 XCTAssertNotEqual(dict, dict2); 522 XCTAssertNotEqual(dict, dict2);
523 XCTAssertEqualObjects(dict, dict2); 523 XCTAssertEqualObjects(dict, dict2);
524 [dict release]; 524 [dict release];
525 } 525 }
526 526
527 - (void)testAdds { 527 - (void)testAdds {
528 GPBBoolInt32Dictionary *dict = [GPBBoolInt32Dictionary dictionary]; 528 GPBBoolInt32Dictionary *dict = [GPBBoolInt32Dictionary dictionary];
529 XCTAssertNotNil(dict); 529 XCTAssertNotNil(dict);
530 530
531 XCTAssertEqual(dict.count, 0U); 531 XCTAssertEqual(dict.count, 0U);
532 [dict setValue:200 forKey:YES]; 532 [dict setInt32:200 forKey:YES];
533 XCTAssertEqual(dict.count, 1U); 533 XCTAssertEqual(dict.count, 1U);
534 534
535 const BOOL kKeys[] = { NO }; 535 const BOOL kKeys[] = { NO };
536 const int32_t kValues[] = { 201 }; 536 const int32_t kValues[] = { 201 };
537 GPBBoolInt32Dictionary *dict2 = 537 GPBBoolInt32Dictionary *dict2 =
538 [[GPBBoolInt32Dictionary alloc] initWithValues:kValues 538 [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues
539 forKeys:kKeys 539 forKeys:kKeys
540 count:GPBARRAYSIZE(kValues)]; 540 count:GPBARRAYSIZE(kValues)];
541 XCTAssertNotNil(dict2); 541 XCTAssertNotNil(dict2);
542 [dict addEntriesFromDictionary:dict2]; 542 [dict addEntriesFromDictionary:dict2];
543 XCTAssertEqual(dict.count, 2U); 543 XCTAssertEqual(dict.count, 2U);
544 544
545 int32_t value; 545 int32_t value;
546 XCTAssertTrue([dict valueForKey:YES value:NULL]); 546 XCTAssertTrue([dict getInt32:NULL forKey:YES]);
547 XCTAssertTrue([dict valueForKey:YES value:&value]); 547 XCTAssertTrue([dict getInt32:&value forKey:YES]);
548 XCTAssertEqual(value, 200); 548 XCTAssertEqual(value, 200);
549 XCTAssertTrue([dict valueForKey:NO value:NULL]); 549 XCTAssertTrue([dict getInt32:NULL forKey:NO]);
550 XCTAssertTrue([dict valueForKey:NO value:&value]); 550 XCTAssertTrue([dict getInt32:&value forKey:NO]);
551 XCTAssertEqual(value, 201); 551 XCTAssertEqual(value, 201);
552 [dict2 release]; 552 [dict2 release];
553 } 553 }
554 554
555 - (void)testRemove { 555 - (void)testRemove {
556 const BOOL kKeys[] = { YES, NO}; 556 const BOOL kKeys[] = { YES, NO};
557 const int32_t kValues[] = { 200, 201 }; 557 const int32_t kValues[] = { 200, 201 };
558 GPBBoolInt32Dictionary *dict = 558 GPBBoolInt32Dictionary *dict =
559 [[GPBBoolInt32Dictionary alloc] initWithValues:kValues 559 [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues
560 forKeys:kKeys 560 forKeys:kKeys
561 count:GPBARRAYSIZE(kValues)]; 561 count:GPBARRAYSIZE(kValues)];
562 XCTAssertNotNil(dict); 562 XCTAssertNotNil(dict);
563 XCTAssertEqual(dict.count, 2U); 563 XCTAssertEqual(dict.count, 2U);
564 564
565 [dict removeValueForKey:NO]; 565 [dict removeInt32ForKey:NO];
566 XCTAssertEqual(dict.count, 1U); 566 XCTAssertEqual(dict.count, 1U);
567 int32_t value; 567 int32_t value;
568 XCTAssertTrue([dict valueForKey:YES value:NULL]); 568 XCTAssertTrue([dict getInt32:NULL forKey:YES]);
569 XCTAssertTrue([dict valueForKey:YES value:&value]); 569 XCTAssertTrue([dict getInt32:&value forKey:YES]);
570 XCTAssertEqual(value, 200); 570 XCTAssertEqual(value, 200);
571 XCTAssertFalse([dict valueForKey:NO value:NULL]); 571 XCTAssertFalse([dict getInt32:NULL forKey:NO]);
572 572
573 // Remove again does nothing. 573 // Remove again does nothing.
574 [dict removeValueForKey:NO]; 574 [dict removeInt32ForKey:NO];
575 XCTAssertEqual(dict.count, 1U); 575 XCTAssertEqual(dict.count, 1U);
576 XCTAssertTrue([dict valueForKey:YES value:NULL]); 576 XCTAssertTrue([dict getInt32:NULL forKey:YES]);
577 XCTAssertTrue([dict valueForKey:YES value:&value]); 577 XCTAssertTrue([dict getInt32:&value forKey:YES]);
578 XCTAssertEqual(value, 200); 578 XCTAssertEqual(value, 200);
579 XCTAssertFalse([dict valueForKey:NO value:NULL]); 579 XCTAssertFalse([dict getInt32:NULL forKey:NO]);
580 580
581 [dict removeAll]; 581 [dict removeAll];
582 XCTAssertEqual(dict.count, 0U); 582 XCTAssertEqual(dict.count, 0U);
583 XCTAssertFalse([dict valueForKey:YES value:NULL]); 583 XCTAssertFalse([dict getInt32:NULL forKey:YES]);
584 XCTAssertFalse([dict valueForKey:NO value:NULL]); 584 XCTAssertFalse([dict getInt32:NULL forKey:NO]);
585 [dict release]; 585 [dict release];
586 } 586 }
587 587
588 - (void)testInplaceMutation { 588 - (void)testInplaceMutation {
589 const BOOL kKeys[] = { YES, NO }; 589 const BOOL kKeys[] = { YES, NO };
590 const int32_t kValues[] = { 200, 201 }; 590 const int32_t kValues[] = { 200, 201 };
591 GPBBoolInt32Dictionary *dict = 591 GPBBoolInt32Dictionary *dict =
592 [[GPBBoolInt32Dictionary alloc] initWithValues:kValues 592 [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues
593 forKeys:kKeys 593 forKeys:kKeys
594 count:GPBARRAYSIZE(kValues)]; 594 count:GPBARRAYSIZE(kValues)];
595 XCTAssertNotNil(dict); 595 XCTAssertNotNil(dict);
596 XCTAssertEqual(dict.count, 2U); 596 XCTAssertEqual(dict.count, 2U);
597 int32_t value; 597 int32_t value;
598 XCTAssertTrue([dict valueForKey:YES value:NULL]); 598 XCTAssertTrue([dict getInt32:NULL forKey:YES]);
599 XCTAssertTrue([dict valueForKey:YES value:&value]); 599 XCTAssertTrue([dict getInt32:&value forKey:YES]);
600 XCTAssertEqual(value, 200); 600 XCTAssertEqual(value, 200);
601 XCTAssertTrue([dict valueForKey:NO value:NULL]); 601 XCTAssertTrue([dict getInt32:NULL forKey:NO]);
602 XCTAssertTrue([dict valueForKey:NO value:&value]); 602 XCTAssertTrue([dict getInt32:&value forKey:NO]);
603 XCTAssertEqual(value, 201); 603 XCTAssertEqual(value, 201);
604 604
605 [dict setValue:201 forKey:YES]; 605 [dict setInt32:201 forKey:YES];
606 XCTAssertEqual(dict.count, 2U); 606 XCTAssertEqual(dict.count, 2U);
607 XCTAssertTrue([dict valueForKey:YES value:NULL]); 607 XCTAssertTrue([dict getInt32:NULL forKey:YES]);
608 XCTAssertTrue([dict valueForKey:YES value:&value]); 608 XCTAssertTrue([dict getInt32:&value forKey:YES]);
609 XCTAssertEqual(value, 201); 609 XCTAssertEqual(value, 201);
610 XCTAssertTrue([dict valueForKey:NO value:NULL]); 610 XCTAssertTrue([dict getInt32:NULL forKey:NO]);
611 XCTAssertTrue([dict valueForKey:NO value:&value]); 611 XCTAssertTrue([dict getInt32:&value forKey:NO]);
612 XCTAssertEqual(value, 201); 612 XCTAssertEqual(value, 201);
613 613
614 [dict setValue:200 forKey:NO]; 614 [dict setInt32:200 forKey:NO];
615 XCTAssertEqual(dict.count, 2U); 615 XCTAssertEqual(dict.count, 2U);
616 XCTAssertTrue([dict valueForKey:YES value:NULL]); 616 XCTAssertTrue([dict getInt32:NULL forKey:YES]);
617 XCTAssertTrue([dict valueForKey:YES value:&value]); 617 XCTAssertTrue([dict getInt32:&value forKey:YES]);
618 XCTAssertEqual(value, 201); 618 XCTAssertEqual(value, 201);
619 XCTAssertTrue([dict valueForKey:NO value:NULL]); 619 XCTAssertTrue([dict getInt32:NULL forKey:NO]);
620 XCTAssertTrue([dict valueForKey:NO value:&value]); 620 XCTAssertTrue([dict getInt32:&value forKey:NO]);
621 XCTAssertEqual(value, 200); 621 XCTAssertEqual(value, 200);
622 622
623 const BOOL kKeys2[] = { NO, YES }; 623 const BOOL kKeys2[] = { NO, YES };
624 const int32_t kValues2[] = { 201, 200 }; 624 const int32_t kValues2[] = { 201, 200 };
625 GPBBoolInt32Dictionary *dict2 = 625 GPBBoolInt32Dictionary *dict2 =
626 [[GPBBoolInt32Dictionary alloc] initWithValues:kValues2 626 [[GPBBoolInt32Dictionary alloc] initWithInt32s:kValues2
627 forKeys:kKeys2 627 forKeys:kKeys2
628 count:GPBARRAYSIZE(kValues2)]; 628 count:GPBARRAYSIZE(kValues2)];
629 XCTAssertNotNil(dict2); 629 XCTAssertNotNil(dict2);
630 [dict addEntriesFromDictionary:dict2]; 630 [dict addEntriesFromDictionary:dict2];
631 XCTAssertEqual(dict.count, 2U); 631 XCTAssertEqual(dict.count, 2U);
632 XCTAssertTrue([dict valueForKey:YES value:NULL]); 632 XCTAssertTrue([dict getInt32:NULL forKey:YES]);
633 XCTAssertTrue([dict valueForKey:YES value:&value]); 633 XCTAssertTrue([dict getInt32:&value forKey:YES]);
634 XCTAssertEqual(value, 200); 634 XCTAssertEqual(value, 200);
635 XCTAssertTrue([dict valueForKey:NO value:NULL]); 635 XCTAssertTrue([dict getInt32:NULL forKey:NO]);
636 XCTAssertTrue([dict valueForKey:NO value:&value]); 636 XCTAssertTrue([dict getInt32:&value forKey:NO]);
637 XCTAssertEqual(value, 201); 637 XCTAssertEqual(value, 201);
638 638
639 [dict2 release]; 639 [dict2 release];
640 [dict release]; 640 [dict release];
641 } 641 }
642 642
643 @end 643 @end
644 644
645 //%PDDM-EXPAND BOOL_TESTS_FOR_POD_VALUE(UInt64, uint64_t, 300U, 301U) 645 //%PDDM-EXPAND BOOL_TESTS_FOR_POD_VALUE(UInt64, uint64_t, 300U, 301U)
646 // This block of code is generated, do not edit it directly. 646 // This block of code is generated, do not edit it directly.
647 647
648 #pragma mark - Bool -> UInt64 648 #pragma mark - Bool -> UInt64
649 649
650 @interface GPBBoolUInt64DictionaryTests : XCTestCase 650 @interface GPBBoolUInt64DictionaryTests : XCTestCase
651 @end 651 @end
652 652
653 @implementation GPBBoolUInt64DictionaryTests 653 @implementation GPBBoolUInt64DictionaryTests
654 654
655 - (void)testEmpty { 655 - (void)testEmpty {
656 GPBBoolUInt64Dictionary *dict = [[GPBBoolUInt64Dictionary alloc] init]; 656 GPBBoolUInt64Dictionary *dict = [[GPBBoolUInt64Dictionary alloc] init];
657 XCTAssertNotNil(dict); 657 XCTAssertNotNil(dict);
658 XCTAssertEqual(dict.count, 0U); 658 XCTAssertEqual(dict.count, 0U);
659 XCTAssertFalse([dict valueForKey:YES value:NULL]); 659 XCTAssertFalse([dict getUInt64:NULL forKey:YES]);
660 [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, uint64_t aValue, BOOL *sto p) { 660 [dict enumerateKeysAndUInt64sUsingBlock:^(BOOL aKey, uint64_t aValue, BOOL *st op) {
661 #pragma unused(aKey, aValue, stop) 661 #pragma unused(aKey, aValue, stop)
662 XCTFail(@"Shouldn't get here!"); 662 XCTFail(@"Shouldn't get here!");
663 }]; 663 }];
664 [dict release]; 664 [dict release];
665 } 665 }
666 666
667 - (void)testOne { 667 - (void)testOne {
668 GPBBoolUInt64Dictionary *dict = [GPBBoolUInt64Dictionary dictionaryWithValue:3 00U forKey:YES]; 668 GPBBoolUInt64Dictionary *dict = [GPBBoolUInt64Dictionary dictionaryWithUInt64: 300U forKey:YES];
669 XCTAssertNotNil(dict); 669 XCTAssertNotNil(dict);
670 XCTAssertEqual(dict.count, 1U); 670 XCTAssertEqual(dict.count, 1U);
671 uint64_t value; 671 uint64_t value;
672 XCTAssertTrue([dict valueForKey:YES value:NULL]); 672 XCTAssertTrue([dict getUInt64:NULL forKey:YES]);
673 XCTAssertTrue([dict valueForKey:YES value:&value]); 673 XCTAssertTrue([dict getUInt64:&value forKey:YES]);
674 XCTAssertEqual(value, 300U); 674 XCTAssertEqual(value, 300U);
675 XCTAssertFalse([dict valueForKey:NO value:NULL]); 675 XCTAssertFalse([dict getUInt64:NULL forKey:NO]);
676 [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, uint64_t aValue, BOOL *sto p) { 676 [dict enumerateKeysAndUInt64sUsingBlock:^(BOOL aKey, uint64_t aValue, BOOL *st op) {
677 XCTAssertEqual(aKey, YES); 677 XCTAssertEqual(aKey, YES);
678 XCTAssertEqual(aValue, 300U); 678 XCTAssertEqual(aValue, 300U);
679 XCTAssertNotEqual(stop, NULL); 679 XCTAssertNotEqual(stop, NULL);
680 }]; 680 }];
681 } 681 }
682 682
683 - (void)testBasics { 683 - (void)testBasics {
684 const BOOL kKeys[] = { YES, NO }; 684 const BOOL kKeys[] = { YES, NO };
685 const uint64_t kValues[] = { 300U, 301U }; 685 const uint64_t kValues[] = { 300U, 301U };
686 GPBBoolUInt64Dictionary *dict = 686 GPBBoolUInt64Dictionary *dict =
687 [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues 687 [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues
688 forKeys:kKeys 688 forKeys:kKeys
689 count:GPBARRAYSIZE(kValues)]; 689 count:GPBARRAYSIZE(kValues)];
690 XCTAssertNotNil(dict); 690 XCTAssertNotNil(dict);
691 XCTAssertEqual(dict.count, 2U); 691 XCTAssertEqual(dict.count, 2U);
692 uint64_t value; 692 uint64_t value;
693 XCTAssertTrue([dict valueForKey:YES value:NULL]); 693 XCTAssertTrue([dict getUInt64:NULL forKey:YES]);
694 XCTAssertTrue([dict valueForKey:YES value:&value]); 694 XCTAssertTrue([dict getUInt64:&value forKey:YES]);
695 XCTAssertEqual(value, 300U); 695 XCTAssertEqual(value, 300U);
696 XCTAssertTrue([dict valueForKey:NO value:NULL]); 696 XCTAssertTrue([dict getUInt64:NULL forKey:NO]);
697 XCTAssertTrue([dict valueForKey:NO value:&value]); 697 XCTAssertTrue([dict getUInt64:&value forKey:NO]);
698 XCTAssertEqual(value, 301U); 698 XCTAssertEqual(value, 301U);
699 699
700 __block NSUInteger idx = 0; 700 __block NSUInteger idx = 0;
701 BOOL *seenKeys = malloc(2 * sizeof(BOOL)); 701 BOOL *seenKeys = malloc(2 * sizeof(BOOL));
702 uint64_t *seenValues = malloc(2 * sizeof(uint64_t)); 702 uint64_t *seenValues = malloc(2 * sizeof(uint64_t));
703 [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, uint64_t aValue, BOOL *sto p) { 703 [dict enumerateKeysAndUInt64sUsingBlock:^(BOOL aKey, uint64_t aValue, BOOL *st op) {
704 XCTAssertLessThan(idx, 2U); 704 XCTAssertLessThan(idx, 2U);
705 seenKeys[idx] = aKey; 705 seenKeys[idx] = aKey;
706 seenValues[idx] = aValue; 706 seenValues[idx] = aValue;
707 XCTAssertNotEqual(stop, NULL); 707 XCTAssertNotEqual(stop, NULL);
708 ++idx; 708 ++idx;
709 }]; 709 }];
710 for (int i = 0; i < 2; ++i) { 710 for (int i = 0; i < 2; ++i) {
711 BOOL foundKey = NO; 711 BOOL foundKey = NO;
712 for (int j = 0; (j < 2) && !foundKey; ++j) { 712 for (int j = 0; (j < 2) && !foundKey; ++j) {
713 if (kKeys[i] == seenKeys[j]) { 713 if (kKeys[i] == seenKeys[j]) {
714 foundKey = YES; 714 foundKey = YES;
715 XCTAssertEqual(kValues[i], seenValues[j], @"i = %d, j = %d", i, j); 715 XCTAssertEqual(kValues[i], seenValues[j], @"i = %d, j = %d", i, j);
716 } 716 }
717 } 717 }
718 XCTAssertTrue(foundKey, @"i = %d", i); 718 XCTAssertTrue(foundKey, @"i = %d", i);
719 } 719 }
720 free(seenKeys); 720 free(seenKeys);
721 free(seenValues); 721 free(seenValues);
722 722
723 // Stopping the enumeration. 723 // Stopping the enumeration.
724 idx = 0; 724 idx = 0;
725 [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, uint64_t aValue, BOOL *sto p) { 725 [dict enumerateKeysAndUInt64sUsingBlock:^(BOOL aKey, uint64_t aValue, BOOL *st op) {
726 #pragma unused(aKey, aValue) 726 #pragma unused(aKey, aValue)
727 if (idx == 0) *stop = YES; 727 if (idx == 0) *stop = YES;
728 XCTAssertNotEqual(idx, 2U); 728 XCTAssertNotEqual(idx, 2U);
729 ++idx; 729 ++idx;
730 }]; 730 }];
731 [dict release]; 731 [dict release];
732 } 732 }
733 733
734 - (void)testEquality { 734 - (void)testEquality {
735 const BOOL kKeys1[] = { YES, NO }; 735 const BOOL kKeys1[] = { YES, NO };
736 const BOOL kKeys2[] = { NO, YES }; 736 const BOOL kKeys2[] = { NO, YES };
737 const uint64_t kValues1[] = { 300U, 301U }; 737 const uint64_t kValues1[] = { 300U, 301U };
738 const uint64_t kValues2[] = { 301U, 300U }; 738 const uint64_t kValues2[] = { 301U, 300U };
739 const uint64_t kValues3[] = { 301U }; 739 const uint64_t kValues3[] = { 301U };
740 GPBBoolUInt64Dictionary *dict1 = 740 GPBBoolUInt64Dictionary *dict1 =
741 [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues1 741 [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues1
742 forKeys:kKeys1 742 forKeys:kKeys1
743 count:GPBARRAYSIZE(kValues1)]; 743 count:GPBARRAYSIZE(kValues1)];
744 XCTAssertNotNil(dict1); 744 XCTAssertNotNil(dict1);
745 GPBBoolUInt64Dictionary *dict1prime = 745 GPBBoolUInt64Dictionary *dict1prime =
746 [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues1 746 [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues1
747 forKeys:kKeys1 747 forKeys:kKeys1
748 count:GPBARRAYSIZE(kValues1)]; 748 count:GPBARRAYSIZE(kValues1)];
749 XCTAssertNotNil(dict1prime); 749 XCTAssertNotNil(dict1prime);
750 GPBBoolUInt64Dictionary *dict2 = 750 GPBBoolUInt64Dictionary *dict2 =
751 [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues2 751 [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues2
752 forKeys:kKeys1 752 forKeys:kKeys1
753 count:GPBARRAYSIZE(kValues2)]; 753 count:GPBARRAYSIZE(kValues2)];
754 XCTAssertNotNil(dict2); 754 XCTAssertNotNil(dict2);
755 GPBBoolUInt64Dictionary *dict3 = 755 GPBBoolUInt64Dictionary *dict3 =
756 [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues1 756 [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues1
757 forKeys:kKeys2 757 forKeys:kKeys2
758 count:GPBARRAYSIZE(kValues1)]; 758 count:GPBARRAYSIZE(kValues1)];
759 XCTAssertNotNil(dict3); 759 XCTAssertNotNil(dict3);
760 GPBBoolUInt64Dictionary *dict4 = 760 GPBBoolUInt64Dictionary *dict4 =
761 [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues3 761 [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues3
762 forKeys:kKeys1 762 forKeys:kKeys1
763 count:GPBARRAYSIZE(kValues3)]; 763 count:GPBARRAYSIZE(kValues3)];
764 XCTAssertNotNil(dict4); 764 XCTAssertNotNil(dict4);
765 765
766 // 1/1Prime should be different objects, but equal. 766 // 1/1Prime should be different objects, but equal.
767 XCTAssertNotEqual(dict1, dict1prime); 767 XCTAssertNotEqual(dict1, dict1prime);
768 XCTAssertEqualObjects(dict1, dict1prime); 768 XCTAssertEqualObjects(dict1, dict1prime);
769 // Equal, so they must have same hash. 769 // Equal, so they must have same hash.
770 XCTAssertEqual([dict1 hash], [dict1prime hash]); 770 XCTAssertEqual([dict1 hash], [dict1prime hash]);
771 771
772 // 2 is same keys, different values; not equal. 772 // 2 is same keys, different values; not equal.
773 XCTAssertNotEqualObjects(dict1, dict2); 773 XCTAssertNotEqualObjects(dict1, dict2);
774 774
775 // 3 is different keys, same values; not equal. 775 // 3 is different keys, same values; not equal.
776 XCTAssertNotEqualObjects(dict1, dict3); 776 XCTAssertNotEqualObjects(dict1, dict3);
777 777
778 // 4 Fewer pairs; not equal 778 // 4 Fewer pairs; not equal
779 XCTAssertNotEqualObjects(dict1, dict4); 779 XCTAssertNotEqualObjects(dict1, dict4);
780 780
781 [dict1 release]; 781 [dict1 release];
782 [dict1prime release]; 782 [dict1prime release];
783 [dict2 release]; 783 [dict2 release];
784 [dict3 release]; 784 [dict3 release];
785 [dict4 release]; 785 [dict4 release];
786 } 786 }
787 787
788 - (void)testCopy { 788 - (void)testCopy {
789 const BOOL kKeys[] = { YES, NO }; 789 const BOOL kKeys[] = { YES, NO };
790 const uint64_t kValues[] = { 300U, 301U }; 790 const uint64_t kValues[] = { 300U, 301U };
791 GPBBoolUInt64Dictionary *dict = 791 GPBBoolUInt64Dictionary *dict =
792 [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues 792 [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues
793 forKeys:kKeys 793 forKeys:kKeys
794 count:GPBARRAYSIZE(kValues)]; 794 count:GPBARRAYSIZE(kValues)];
795 XCTAssertNotNil(dict); 795 XCTAssertNotNil(dict);
796 796
797 GPBBoolUInt64Dictionary *dict2 = [dict copy]; 797 GPBBoolUInt64Dictionary *dict2 = [dict copy];
798 XCTAssertNotNil(dict2); 798 XCTAssertNotNil(dict2);
799 799
800 // Should be new object but equal. 800 // Should be new object but equal.
801 XCTAssertNotEqual(dict, dict2); 801 XCTAssertNotEqual(dict, dict2);
802 XCTAssertEqualObjects(dict, dict2); 802 XCTAssertEqualObjects(dict, dict2);
803 XCTAssertTrue([dict2 isKindOfClass:[GPBBoolUInt64Dictionary class]]); 803 XCTAssertTrue([dict2 isKindOfClass:[GPBBoolUInt64Dictionary class]]);
804 804
805 [dict2 release]; 805 [dict2 release];
806 [dict release]; 806 [dict release];
807 } 807 }
808 808
809 - (void)testDictionaryFromDictionary { 809 - (void)testDictionaryFromDictionary {
810 const BOOL kKeys[] = { YES, NO }; 810 const BOOL kKeys[] = { YES, NO };
811 const uint64_t kValues[] = { 300U, 301U }; 811 const uint64_t kValues[] = { 300U, 301U };
812 GPBBoolUInt64Dictionary *dict = 812 GPBBoolUInt64Dictionary *dict =
813 [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues 813 [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues
814 forKeys:kKeys 814 forKeys:kKeys
815 count:GPBARRAYSIZE(kValues)]; 815 count:GPBARRAYSIZE(kValues)];
816 XCTAssertNotNil(dict); 816 XCTAssertNotNil(dict);
817 817
818 GPBBoolUInt64Dictionary *dict2 = 818 GPBBoolUInt64Dictionary *dict2 =
819 [GPBBoolUInt64Dictionary dictionaryWithDictionary:dict]; 819 [GPBBoolUInt64Dictionary dictionaryWithDictionary:dict];
820 XCTAssertNotNil(dict2); 820 XCTAssertNotNil(dict2);
821 821
822 // Should be new pointer, but equal objects. 822 // Should be new pointer, but equal objects.
823 XCTAssertNotEqual(dict, dict2); 823 XCTAssertNotEqual(dict, dict2);
824 XCTAssertEqualObjects(dict, dict2); 824 XCTAssertEqualObjects(dict, dict2);
825 [dict release]; 825 [dict release];
826 } 826 }
827 827
828 - (void)testAdds { 828 - (void)testAdds {
829 GPBBoolUInt64Dictionary *dict = [GPBBoolUInt64Dictionary dictionary]; 829 GPBBoolUInt64Dictionary *dict = [GPBBoolUInt64Dictionary dictionary];
830 XCTAssertNotNil(dict); 830 XCTAssertNotNil(dict);
831 831
832 XCTAssertEqual(dict.count, 0U); 832 XCTAssertEqual(dict.count, 0U);
833 [dict setValue:300U forKey:YES]; 833 [dict setUInt64:300U forKey:YES];
834 XCTAssertEqual(dict.count, 1U); 834 XCTAssertEqual(dict.count, 1U);
835 835
836 const BOOL kKeys[] = { NO }; 836 const BOOL kKeys[] = { NO };
837 const uint64_t kValues[] = { 301U }; 837 const uint64_t kValues[] = { 301U };
838 GPBBoolUInt64Dictionary *dict2 = 838 GPBBoolUInt64Dictionary *dict2 =
839 [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues 839 [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues
840 forKeys:kKeys 840 forKeys:kKeys
841 count:GPBARRAYSIZE(kValues)]; 841 count:GPBARRAYSIZE(kValues)];
842 XCTAssertNotNil(dict2); 842 XCTAssertNotNil(dict2);
843 [dict addEntriesFromDictionary:dict2]; 843 [dict addEntriesFromDictionary:dict2];
844 XCTAssertEqual(dict.count, 2U); 844 XCTAssertEqual(dict.count, 2U);
845 845
846 uint64_t value; 846 uint64_t value;
847 XCTAssertTrue([dict valueForKey:YES value:NULL]); 847 XCTAssertTrue([dict getUInt64:NULL forKey:YES]);
848 XCTAssertTrue([dict valueForKey:YES value:&value]); 848 XCTAssertTrue([dict getUInt64:&value forKey:YES]);
849 XCTAssertEqual(value, 300U); 849 XCTAssertEqual(value, 300U);
850 XCTAssertTrue([dict valueForKey:NO value:NULL]); 850 XCTAssertTrue([dict getUInt64:NULL forKey:NO]);
851 XCTAssertTrue([dict valueForKey:NO value:&value]); 851 XCTAssertTrue([dict getUInt64:&value forKey:NO]);
852 XCTAssertEqual(value, 301U); 852 XCTAssertEqual(value, 301U);
853 [dict2 release]; 853 [dict2 release];
854 } 854 }
855 855
856 - (void)testRemove { 856 - (void)testRemove {
857 const BOOL kKeys[] = { YES, NO}; 857 const BOOL kKeys[] = { YES, NO};
858 const uint64_t kValues[] = { 300U, 301U }; 858 const uint64_t kValues[] = { 300U, 301U };
859 GPBBoolUInt64Dictionary *dict = 859 GPBBoolUInt64Dictionary *dict =
860 [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues 860 [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues
861 forKeys:kKeys 861 forKeys:kKeys
862 count:GPBARRAYSIZE(kValues)]; 862 count:GPBARRAYSIZE(kValues)];
863 XCTAssertNotNil(dict); 863 XCTAssertNotNil(dict);
864 XCTAssertEqual(dict.count, 2U); 864 XCTAssertEqual(dict.count, 2U);
865 865
866 [dict removeValueForKey:NO]; 866 [dict removeUInt64ForKey:NO];
867 XCTAssertEqual(dict.count, 1U); 867 XCTAssertEqual(dict.count, 1U);
868 uint64_t value; 868 uint64_t value;
869 XCTAssertTrue([dict valueForKey:YES value:NULL]); 869 XCTAssertTrue([dict getUInt64:NULL forKey:YES]);
870 XCTAssertTrue([dict valueForKey:YES value:&value]); 870 XCTAssertTrue([dict getUInt64:&value forKey:YES]);
871 XCTAssertEqual(value, 300U); 871 XCTAssertEqual(value, 300U);
872 XCTAssertFalse([dict valueForKey:NO value:NULL]); 872 XCTAssertFalse([dict getUInt64:NULL forKey:NO]);
873 873
874 // Remove again does nothing. 874 // Remove again does nothing.
875 [dict removeValueForKey:NO]; 875 [dict removeUInt64ForKey:NO];
876 XCTAssertEqual(dict.count, 1U); 876 XCTAssertEqual(dict.count, 1U);
877 XCTAssertTrue([dict valueForKey:YES value:NULL]); 877 XCTAssertTrue([dict getUInt64:NULL forKey:YES]);
878 XCTAssertTrue([dict valueForKey:YES value:&value]); 878 XCTAssertTrue([dict getUInt64:&value forKey:YES]);
879 XCTAssertEqual(value, 300U); 879 XCTAssertEqual(value, 300U);
880 XCTAssertFalse([dict valueForKey:NO value:NULL]); 880 XCTAssertFalse([dict getUInt64:NULL forKey:NO]);
881 881
882 [dict removeAll]; 882 [dict removeAll];
883 XCTAssertEqual(dict.count, 0U); 883 XCTAssertEqual(dict.count, 0U);
884 XCTAssertFalse([dict valueForKey:YES value:NULL]); 884 XCTAssertFalse([dict getUInt64:NULL forKey:YES]);
885 XCTAssertFalse([dict valueForKey:NO value:NULL]); 885 XCTAssertFalse([dict getUInt64:NULL forKey:NO]);
886 [dict release]; 886 [dict release];
887 } 887 }
888 888
889 - (void)testInplaceMutation { 889 - (void)testInplaceMutation {
890 const BOOL kKeys[] = { YES, NO }; 890 const BOOL kKeys[] = { YES, NO };
891 const uint64_t kValues[] = { 300U, 301U }; 891 const uint64_t kValues[] = { 300U, 301U };
892 GPBBoolUInt64Dictionary *dict = 892 GPBBoolUInt64Dictionary *dict =
893 [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues 893 [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues
894 forKeys:kKeys 894 forKeys:kKeys
895 count:GPBARRAYSIZE(kValues)]; 895 count:GPBARRAYSIZE(kValues)];
896 XCTAssertNotNil(dict); 896 XCTAssertNotNil(dict);
897 XCTAssertEqual(dict.count, 2U); 897 XCTAssertEqual(dict.count, 2U);
898 uint64_t value; 898 uint64_t value;
899 XCTAssertTrue([dict valueForKey:YES value:NULL]); 899 XCTAssertTrue([dict getUInt64:NULL forKey:YES]);
900 XCTAssertTrue([dict valueForKey:YES value:&value]); 900 XCTAssertTrue([dict getUInt64:&value forKey:YES]);
901 XCTAssertEqual(value, 300U); 901 XCTAssertEqual(value, 300U);
902 XCTAssertTrue([dict valueForKey:NO value:NULL]); 902 XCTAssertTrue([dict getUInt64:NULL forKey:NO]);
903 XCTAssertTrue([dict valueForKey:NO value:&value]); 903 XCTAssertTrue([dict getUInt64:&value forKey:NO]);
904 XCTAssertEqual(value, 301U); 904 XCTAssertEqual(value, 301U);
905 905
906 [dict setValue:301U forKey:YES]; 906 [dict setUInt64:301U forKey:YES];
907 XCTAssertEqual(dict.count, 2U); 907 XCTAssertEqual(dict.count, 2U);
908 XCTAssertTrue([dict valueForKey:YES value:NULL]); 908 XCTAssertTrue([dict getUInt64:NULL forKey:YES]);
909 XCTAssertTrue([dict valueForKey:YES value:&value]); 909 XCTAssertTrue([dict getUInt64:&value forKey:YES]);
910 XCTAssertEqual(value, 301U); 910 XCTAssertEqual(value, 301U);
911 XCTAssertTrue([dict valueForKey:NO value:NULL]); 911 XCTAssertTrue([dict getUInt64:NULL forKey:NO]);
912 XCTAssertTrue([dict valueForKey:NO value:&value]); 912 XCTAssertTrue([dict getUInt64:&value forKey:NO]);
913 XCTAssertEqual(value, 301U); 913 XCTAssertEqual(value, 301U);
914 914
915 [dict setValue:300U forKey:NO]; 915 [dict setUInt64:300U forKey:NO];
916 XCTAssertEqual(dict.count, 2U); 916 XCTAssertEqual(dict.count, 2U);
917 XCTAssertTrue([dict valueForKey:YES value:NULL]); 917 XCTAssertTrue([dict getUInt64:NULL forKey:YES]);
918 XCTAssertTrue([dict valueForKey:YES value:&value]); 918 XCTAssertTrue([dict getUInt64:&value forKey:YES]);
919 XCTAssertEqual(value, 301U); 919 XCTAssertEqual(value, 301U);
920 XCTAssertTrue([dict valueForKey:NO value:NULL]); 920 XCTAssertTrue([dict getUInt64:NULL forKey:NO]);
921 XCTAssertTrue([dict valueForKey:NO value:&value]); 921 XCTAssertTrue([dict getUInt64:&value forKey:NO]);
922 XCTAssertEqual(value, 300U); 922 XCTAssertEqual(value, 300U);
923 923
924 const BOOL kKeys2[] = { NO, YES }; 924 const BOOL kKeys2[] = { NO, YES };
925 const uint64_t kValues2[] = { 301U, 300U }; 925 const uint64_t kValues2[] = { 301U, 300U };
926 GPBBoolUInt64Dictionary *dict2 = 926 GPBBoolUInt64Dictionary *dict2 =
927 [[GPBBoolUInt64Dictionary alloc] initWithValues:kValues2 927 [[GPBBoolUInt64Dictionary alloc] initWithUInt64s:kValues2
928 forKeys:kKeys2 928 forKeys:kKeys2
929 count:GPBARRAYSIZE(kValues2)]; 929 count:GPBARRAYSIZE(kValues2)];
930 XCTAssertNotNil(dict2); 930 XCTAssertNotNil(dict2);
931 [dict addEntriesFromDictionary:dict2]; 931 [dict addEntriesFromDictionary:dict2];
932 XCTAssertEqual(dict.count, 2U); 932 XCTAssertEqual(dict.count, 2U);
933 XCTAssertTrue([dict valueForKey:YES value:NULL]); 933 XCTAssertTrue([dict getUInt64:NULL forKey:YES]);
934 XCTAssertTrue([dict valueForKey:YES value:&value]); 934 XCTAssertTrue([dict getUInt64:&value forKey:YES]);
935 XCTAssertEqual(value, 300U); 935 XCTAssertEqual(value, 300U);
936 XCTAssertTrue([dict valueForKey:NO value:NULL]); 936 XCTAssertTrue([dict getUInt64:NULL forKey:NO]);
937 XCTAssertTrue([dict valueForKey:NO value:&value]); 937 XCTAssertTrue([dict getUInt64:&value forKey:NO]);
938 XCTAssertEqual(value, 301U); 938 XCTAssertEqual(value, 301U);
939 939
940 [dict2 release]; 940 [dict2 release];
941 [dict release]; 941 [dict release];
942 } 942 }
943 943
944 @end 944 @end
945 945
946 //%PDDM-EXPAND BOOL_TESTS_FOR_POD_VALUE(Int64, int64_t, 400, 401) 946 //%PDDM-EXPAND BOOL_TESTS_FOR_POD_VALUE(Int64, int64_t, 400, 401)
947 // This block of code is generated, do not edit it directly. 947 // This block of code is generated, do not edit it directly.
948 948
949 #pragma mark - Bool -> Int64 949 #pragma mark - Bool -> Int64
950 950
951 @interface GPBBoolInt64DictionaryTests : XCTestCase 951 @interface GPBBoolInt64DictionaryTests : XCTestCase
952 @end 952 @end
953 953
954 @implementation GPBBoolInt64DictionaryTests 954 @implementation GPBBoolInt64DictionaryTests
955 955
956 - (void)testEmpty { 956 - (void)testEmpty {
957 GPBBoolInt64Dictionary *dict = [[GPBBoolInt64Dictionary alloc] init]; 957 GPBBoolInt64Dictionary *dict = [[GPBBoolInt64Dictionary alloc] init];
958 XCTAssertNotNil(dict); 958 XCTAssertNotNil(dict);
959 XCTAssertEqual(dict.count, 0U); 959 XCTAssertEqual(dict.count, 0U);
960 XCTAssertFalse([dict valueForKey:YES value:NULL]); 960 XCTAssertFalse([dict getInt64:NULL forKey:YES]);
961 [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, int64_t aValue, BOOL *stop ) { 961 [dict enumerateKeysAndInt64sUsingBlock:^(BOOL aKey, int64_t aValue, BOOL *stop ) {
962 #pragma unused(aKey, aValue, stop) 962 #pragma unused(aKey, aValue, stop)
963 XCTFail(@"Shouldn't get here!"); 963 XCTFail(@"Shouldn't get here!");
964 }]; 964 }];
965 [dict release]; 965 [dict release];
966 } 966 }
967 967
968 - (void)testOne { 968 - (void)testOne {
969 GPBBoolInt64Dictionary *dict = [GPBBoolInt64Dictionary dictionaryWithValue:400 forKey:YES]; 969 GPBBoolInt64Dictionary *dict = [GPBBoolInt64Dictionary dictionaryWithInt64:400 forKey:YES];
970 XCTAssertNotNil(dict); 970 XCTAssertNotNil(dict);
971 XCTAssertEqual(dict.count, 1U); 971 XCTAssertEqual(dict.count, 1U);
972 int64_t value; 972 int64_t value;
973 XCTAssertTrue([dict valueForKey:YES value:NULL]); 973 XCTAssertTrue([dict getInt64:NULL forKey:YES]);
974 XCTAssertTrue([dict valueForKey:YES value:&value]); 974 XCTAssertTrue([dict getInt64:&value forKey:YES]);
975 XCTAssertEqual(value, 400); 975 XCTAssertEqual(value, 400);
976 XCTAssertFalse([dict valueForKey:NO value:NULL]); 976 XCTAssertFalse([dict getInt64:NULL forKey:NO]);
977 [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, int64_t aValue, BOOL *stop ) { 977 [dict enumerateKeysAndInt64sUsingBlock:^(BOOL aKey, int64_t aValue, BOOL *stop ) {
978 XCTAssertEqual(aKey, YES); 978 XCTAssertEqual(aKey, YES);
979 XCTAssertEqual(aValue, 400); 979 XCTAssertEqual(aValue, 400);
980 XCTAssertNotEqual(stop, NULL); 980 XCTAssertNotEqual(stop, NULL);
981 }]; 981 }];
982 } 982 }
983 983
984 - (void)testBasics { 984 - (void)testBasics {
985 const BOOL kKeys[] = { YES, NO }; 985 const BOOL kKeys[] = { YES, NO };
986 const int64_t kValues[] = { 400, 401 }; 986 const int64_t kValues[] = { 400, 401 };
987 GPBBoolInt64Dictionary *dict = 987 GPBBoolInt64Dictionary *dict =
988 [[GPBBoolInt64Dictionary alloc] initWithValues:kValues 988 [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues
989 forKeys:kKeys 989 forKeys:kKeys
990 count:GPBARRAYSIZE(kValues)]; 990 count:GPBARRAYSIZE(kValues)];
991 XCTAssertNotNil(dict); 991 XCTAssertNotNil(dict);
992 XCTAssertEqual(dict.count, 2U); 992 XCTAssertEqual(dict.count, 2U);
993 int64_t value; 993 int64_t value;
994 XCTAssertTrue([dict valueForKey:YES value:NULL]); 994 XCTAssertTrue([dict getInt64:NULL forKey:YES]);
995 XCTAssertTrue([dict valueForKey:YES value:&value]); 995 XCTAssertTrue([dict getInt64:&value forKey:YES]);
996 XCTAssertEqual(value, 400); 996 XCTAssertEqual(value, 400);
997 XCTAssertTrue([dict valueForKey:NO value:NULL]); 997 XCTAssertTrue([dict getInt64:NULL forKey:NO]);
998 XCTAssertTrue([dict valueForKey:NO value:&value]); 998 XCTAssertTrue([dict getInt64:&value forKey:NO]);
999 XCTAssertEqual(value, 401); 999 XCTAssertEqual(value, 401);
1000 1000
1001 __block NSUInteger idx = 0; 1001 __block NSUInteger idx = 0;
1002 BOOL *seenKeys = malloc(2 * sizeof(BOOL)); 1002 BOOL *seenKeys = malloc(2 * sizeof(BOOL));
1003 int64_t *seenValues = malloc(2 * sizeof(int64_t)); 1003 int64_t *seenValues = malloc(2 * sizeof(int64_t));
1004 [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, int64_t aValue, BOOL *stop ) { 1004 [dict enumerateKeysAndInt64sUsingBlock:^(BOOL aKey, int64_t aValue, BOOL *stop ) {
1005 XCTAssertLessThan(idx, 2U); 1005 XCTAssertLessThan(idx, 2U);
1006 seenKeys[idx] = aKey; 1006 seenKeys[idx] = aKey;
1007 seenValues[idx] = aValue; 1007 seenValues[idx] = aValue;
1008 XCTAssertNotEqual(stop, NULL); 1008 XCTAssertNotEqual(stop, NULL);
1009 ++idx; 1009 ++idx;
1010 }]; 1010 }];
1011 for (int i = 0; i < 2; ++i) { 1011 for (int i = 0; i < 2; ++i) {
1012 BOOL foundKey = NO; 1012 BOOL foundKey = NO;
1013 for (int j = 0; (j < 2) && !foundKey; ++j) { 1013 for (int j = 0; (j < 2) && !foundKey; ++j) {
1014 if (kKeys[i] == seenKeys[j]) { 1014 if (kKeys[i] == seenKeys[j]) {
1015 foundKey = YES; 1015 foundKey = YES;
1016 XCTAssertEqual(kValues[i], seenValues[j], @"i = %d, j = %d", i, j); 1016 XCTAssertEqual(kValues[i], seenValues[j], @"i = %d, j = %d", i, j);
1017 } 1017 }
1018 } 1018 }
1019 XCTAssertTrue(foundKey, @"i = %d", i); 1019 XCTAssertTrue(foundKey, @"i = %d", i);
1020 } 1020 }
1021 free(seenKeys); 1021 free(seenKeys);
1022 free(seenValues); 1022 free(seenValues);
1023 1023
1024 // Stopping the enumeration. 1024 // Stopping the enumeration.
1025 idx = 0; 1025 idx = 0;
1026 [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, int64_t aValue, BOOL *stop ) { 1026 [dict enumerateKeysAndInt64sUsingBlock:^(BOOL aKey, int64_t aValue, BOOL *stop ) {
1027 #pragma unused(aKey, aValue) 1027 #pragma unused(aKey, aValue)
1028 if (idx == 0) *stop = YES; 1028 if (idx == 0) *stop = YES;
1029 XCTAssertNotEqual(idx, 2U); 1029 XCTAssertNotEqual(idx, 2U);
1030 ++idx; 1030 ++idx;
1031 }]; 1031 }];
1032 [dict release]; 1032 [dict release];
1033 } 1033 }
1034 1034
1035 - (void)testEquality { 1035 - (void)testEquality {
1036 const BOOL kKeys1[] = { YES, NO }; 1036 const BOOL kKeys1[] = { YES, NO };
1037 const BOOL kKeys2[] = { NO, YES }; 1037 const BOOL kKeys2[] = { NO, YES };
1038 const int64_t kValues1[] = { 400, 401 }; 1038 const int64_t kValues1[] = { 400, 401 };
1039 const int64_t kValues2[] = { 401, 400 }; 1039 const int64_t kValues2[] = { 401, 400 };
1040 const int64_t kValues3[] = { 401 }; 1040 const int64_t kValues3[] = { 401 };
1041 GPBBoolInt64Dictionary *dict1 = 1041 GPBBoolInt64Dictionary *dict1 =
1042 [[GPBBoolInt64Dictionary alloc] initWithValues:kValues1 1042 [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues1
1043 forKeys:kKeys1 1043 forKeys:kKeys1
1044 count:GPBARRAYSIZE(kValues1)]; 1044 count:GPBARRAYSIZE(kValues1)];
1045 XCTAssertNotNil(dict1); 1045 XCTAssertNotNil(dict1);
1046 GPBBoolInt64Dictionary *dict1prime = 1046 GPBBoolInt64Dictionary *dict1prime =
1047 [[GPBBoolInt64Dictionary alloc] initWithValues:kValues1 1047 [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues1
1048 forKeys:kKeys1 1048 forKeys:kKeys1
1049 count:GPBARRAYSIZE(kValues1)]; 1049 count:GPBARRAYSIZE(kValues1)];
1050 XCTAssertNotNil(dict1prime); 1050 XCTAssertNotNil(dict1prime);
1051 GPBBoolInt64Dictionary *dict2 = 1051 GPBBoolInt64Dictionary *dict2 =
1052 [[GPBBoolInt64Dictionary alloc] initWithValues:kValues2 1052 [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues2
1053 forKeys:kKeys1 1053 forKeys:kKeys1
1054 count:GPBARRAYSIZE(kValues2)]; 1054 count:GPBARRAYSIZE(kValues2)];
1055 XCTAssertNotNil(dict2); 1055 XCTAssertNotNil(dict2);
1056 GPBBoolInt64Dictionary *dict3 = 1056 GPBBoolInt64Dictionary *dict3 =
1057 [[GPBBoolInt64Dictionary alloc] initWithValues:kValues1 1057 [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues1
1058 forKeys:kKeys2 1058 forKeys:kKeys2
1059 count:GPBARRAYSIZE(kValues1)]; 1059 count:GPBARRAYSIZE(kValues1)];
1060 XCTAssertNotNil(dict3); 1060 XCTAssertNotNil(dict3);
1061 GPBBoolInt64Dictionary *dict4 = 1061 GPBBoolInt64Dictionary *dict4 =
1062 [[GPBBoolInt64Dictionary alloc] initWithValues:kValues3 1062 [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues3
1063 forKeys:kKeys1 1063 forKeys:kKeys1
1064 count:GPBARRAYSIZE(kValues3)]; 1064 count:GPBARRAYSIZE(kValues3)];
1065 XCTAssertNotNil(dict4); 1065 XCTAssertNotNil(dict4);
1066 1066
1067 // 1/1Prime should be different objects, but equal. 1067 // 1/1Prime should be different objects, but equal.
1068 XCTAssertNotEqual(dict1, dict1prime); 1068 XCTAssertNotEqual(dict1, dict1prime);
1069 XCTAssertEqualObjects(dict1, dict1prime); 1069 XCTAssertEqualObjects(dict1, dict1prime);
1070 // Equal, so they must have same hash. 1070 // Equal, so they must have same hash.
1071 XCTAssertEqual([dict1 hash], [dict1prime hash]); 1071 XCTAssertEqual([dict1 hash], [dict1prime hash]);
1072 1072
(...skipping 10 matching lines...) Expand all
1083 [dict1prime release]; 1083 [dict1prime release];
1084 [dict2 release]; 1084 [dict2 release];
1085 [dict3 release]; 1085 [dict3 release];
1086 [dict4 release]; 1086 [dict4 release];
1087 } 1087 }
1088 1088
1089 - (void)testCopy { 1089 - (void)testCopy {
1090 const BOOL kKeys[] = { YES, NO }; 1090 const BOOL kKeys[] = { YES, NO };
1091 const int64_t kValues[] = { 400, 401 }; 1091 const int64_t kValues[] = { 400, 401 };
1092 GPBBoolInt64Dictionary *dict = 1092 GPBBoolInt64Dictionary *dict =
1093 [[GPBBoolInt64Dictionary alloc] initWithValues:kValues 1093 [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues
1094 forKeys:kKeys 1094 forKeys:kKeys
1095 count:GPBARRAYSIZE(kValues)]; 1095 count:GPBARRAYSIZE(kValues)];
1096 XCTAssertNotNil(dict); 1096 XCTAssertNotNil(dict);
1097 1097
1098 GPBBoolInt64Dictionary *dict2 = [dict copy]; 1098 GPBBoolInt64Dictionary *dict2 = [dict copy];
1099 XCTAssertNotNil(dict2); 1099 XCTAssertNotNil(dict2);
1100 1100
1101 // Should be new object but equal. 1101 // Should be new object but equal.
1102 XCTAssertNotEqual(dict, dict2); 1102 XCTAssertNotEqual(dict, dict2);
1103 XCTAssertEqualObjects(dict, dict2); 1103 XCTAssertEqualObjects(dict, dict2);
1104 XCTAssertTrue([dict2 isKindOfClass:[GPBBoolInt64Dictionary class]]); 1104 XCTAssertTrue([dict2 isKindOfClass:[GPBBoolInt64Dictionary class]]);
1105 1105
1106 [dict2 release]; 1106 [dict2 release];
1107 [dict release]; 1107 [dict release];
1108 } 1108 }
1109 1109
1110 - (void)testDictionaryFromDictionary { 1110 - (void)testDictionaryFromDictionary {
1111 const BOOL kKeys[] = { YES, NO }; 1111 const BOOL kKeys[] = { YES, NO };
1112 const int64_t kValues[] = { 400, 401 }; 1112 const int64_t kValues[] = { 400, 401 };
1113 GPBBoolInt64Dictionary *dict = 1113 GPBBoolInt64Dictionary *dict =
1114 [[GPBBoolInt64Dictionary alloc] initWithValues:kValues 1114 [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues
1115 forKeys:kKeys 1115 forKeys:kKeys
1116 count:GPBARRAYSIZE(kValues)]; 1116 count:GPBARRAYSIZE(kValues)];
1117 XCTAssertNotNil(dict); 1117 XCTAssertNotNil(dict);
1118 1118
1119 GPBBoolInt64Dictionary *dict2 = 1119 GPBBoolInt64Dictionary *dict2 =
1120 [GPBBoolInt64Dictionary dictionaryWithDictionary:dict]; 1120 [GPBBoolInt64Dictionary dictionaryWithDictionary:dict];
1121 XCTAssertNotNil(dict2); 1121 XCTAssertNotNil(dict2);
1122 1122
1123 // Should be new pointer, but equal objects. 1123 // Should be new pointer, but equal objects.
1124 XCTAssertNotEqual(dict, dict2); 1124 XCTAssertNotEqual(dict, dict2);
1125 XCTAssertEqualObjects(dict, dict2); 1125 XCTAssertEqualObjects(dict, dict2);
1126 [dict release]; 1126 [dict release];
1127 } 1127 }
1128 1128
1129 - (void)testAdds { 1129 - (void)testAdds {
1130 GPBBoolInt64Dictionary *dict = [GPBBoolInt64Dictionary dictionary]; 1130 GPBBoolInt64Dictionary *dict = [GPBBoolInt64Dictionary dictionary];
1131 XCTAssertNotNil(dict); 1131 XCTAssertNotNil(dict);
1132 1132
1133 XCTAssertEqual(dict.count, 0U); 1133 XCTAssertEqual(dict.count, 0U);
1134 [dict setValue:400 forKey:YES]; 1134 [dict setInt64:400 forKey:YES];
1135 XCTAssertEqual(dict.count, 1U); 1135 XCTAssertEqual(dict.count, 1U);
1136 1136
1137 const BOOL kKeys[] = { NO }; 1137 const BOOL kKeys[] = { NO };
1138 const int64_t kValues[] = { 401 }; 1138 const int64_t kValues[] = { 401 };
1139 GPBBoolInt64Dictionary *dict2 = 1139 GPBBoolInt64Dictionary *dict2 =
1140 [[GPBBoolInt64Dictionary alloc] initWithValues:kValues 1140 [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues
1141 forKeys:kKeys 1141 forKeys:kKeys
1142 count:GPBARRAYSIZE(kValues)]; 1142 count:GPBARRAYSIZE(kValues)];
1143 XCTAssertNotNil(dict2); 1143 XCTAssertNotNil(dict2);
1144 [dict addEntriesFromDictionary:dict2]; 1144 [dict addEntriesFromDictionary:dict2];
1145 XCTAssertEqual(dict.count, 2U); 1145 XCTAssertEqual(dict.count, 2U);
1146 1146
1147 int64_t value; 1147 int64_t value;
1148 XCTAssertTrue([dict valueForKey:YES value:NULL]); 1148 XCTAssertTrue([dict getInt64:NULL forKey:YES]);
1149 XCTAssertTrue([dict valueForKey:YES value:&value]); 1149 XCTAssertTrue([dict getInt64:&value forKey:YES]);
1150 XCTAssertEqual(value, 400); 1150 XCTAssertEqual(value, 400);
1151 XCTAssertTrue([dict valueForKey:NO value:NULL]); 1151 XCTAssertTrue([dict getInt64:NULL forKey:NO]);
1152 XCTAssertTrue([dict valueForKey:NO value:&value]); 1152 XCTAssertTrue([dict getInt64:&value forKey:NO]);
1153 XCTAssertEqual(value, 401); 1153 XCTAssertEqual(value, 401);
1154 [dict2 release]; 1154 [dict2 release];
1155 } 1155 }
1156 1156
1157 - (void)testRemove { 1157 - (void)testRemove {
1158 const BOOL kKeys[] = { YES, NO}; 1158 const BOOL kKeys[] = { YES, NO};
1159 const int64_t kValues[] = { 400, 401 }; 1159 const int64_t kValues[] = { 400, 401 };
1160 GPBBoolInt64Dictionary *dict = 1160 GPBBoolInt64Dictionary *dict =
1161 [[GPBBoolInt64Dictionary alloc] initWithValues:kValues 1161 [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues
1162 forKeys:kKeys 1162 forKeys:kKeys
1163 count:GPBARRAYSIZE(kValues)]; 1163 count:GPBARRAYSIZE(kValues)];
1164 XCTAssertNotNil(dict); 1164 XCTAssertNotNil(dict);
1165 XCTAssertEqual(dict.count, 2U); 1165 XCTAssertEqual(dict.count, 2U);
1166 1166
1167 [dict removeValueForKey:NO]; 1167 [dict removeInt64ForKey:NO];
1168 XCTAssertEqual(dict.count, 1U); 1168 XCTAssertEqual(dict.count, 1U);
1169 int64_t value; 1169 int64_t value;
1170 XCTAssertTrue([dict valueForKey:YES value:NULL]); 1170 XCTAssertTrue([dict getInt64:NULL forKey:YES]);
1171 XCTAssertTrue([dict valueForKey:YES value:&value]); 1171 XCTAssertTrue([dict getInt64:&value forKey:YES]);
1172 XCTAssertEqual(value, 400); 1172 XCTAssertEqual(value, 400);
1173 XCTAssertFalse([dict valueForKey:NO value:NULL]); 1173 XCTAssertFalse([dict getInt64:NULL forKey:NO]);
1174 1174
1175 // Remove again does nothing. 1175 // Remove again does nothing.
1176 [dict removeValueForKey:NO]; 1176 [dict removeInt64ForKey:NO];
1177 XCTAssertEqual(dict.count, 1U); 1177 XCTAssertEqual(dict.count, 1U);
1178 XCTAssertTrue([dict valueForKey:YES value:NULL]); 1178 XCTAssertTrue([dict getInt64:NULL forKey:YES]);
1179 XCTAssertTrue([dict valueForKey:YES value:&value]); 1179 XCTAssertTrue([dict getInt64:&value forKey:YES]);
1180 XCTAssertEqual(value, 400); 1180 XCTAssertEqual(value, 400);
1181 XCTAssertFalse([dict valueForKey:NO value:NULL]); 1181 XCTAssertFalse([dict getInt64:NULL forKey:NO]);
1182 1182
1183 [dict removeAll]; 1183 [dict removeAll];
1184 XCTAssertEqual(dict.count, 0U); 1184 XCTAssertEqual(dict.count, 0U);
1185 XCTAssertFalse([dict valueForKey:YES value:NULL]); 1185 XCTAssertFalse([dict getInt64:NULL forKey:YES]);
1186 XCTAssertFalse([dict valueForKey:NO value:NULL]); 1186 XCTAssertFalse([dict getInt64:NULL forKey:NO]);
1187 [dict release]; 1187 [dict release];
1188 } 1188 }
1189 1189
1190 - (void)testInplaceMutation { 1190 - (void)testInplaceMutation {
1191 const BOOL kKeys[] = { YES, NO }; 1191 const BOOL kKeys[] = { YES, NO };
1192 const int64_t kValues[] = { 400, 401 }; 1192 const int64_t kValues[] = { 400, 401 };
1193 GPBBoolInt64Dictionary *dict = 1193 GPBBoolInt64Dictionary *dict =
1194 [[GPBBoolInt64Dictionary alloc] initWithValues:kValues 1194 [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues
1195 forKeys:kKeys 1195 forKeys:kKeys
1196 count:GPBARRAYSIZE(kValues)]; 1196 count:GPBARRAYSIZE(kValues)];
1197 XCTAssertNotNil(dict); 1197 XCTAssertNotNil(dict);
1198 XCTAssertEqual(dict.count, 2U); 1198 XCTAssertEqual(dict.count, 2U);
1199 int64_t value; 1199 int64_t value;
1200 XCTAssertTrue([dict valueForKey:YES value:NULL]); 1200 XCTAssertTrue([dict getInt64:NULL forKey:YES]);
1201 XCTAssertTrue([dict valueForKey:YES value:&value]); 1201 XCTAssertTrue([dict getInt64:&value forKey:YES]);
1202 XCTAssertEqual(value, 400); 1202 XCTAssertEqual(value, 400);
1203 XCTAssertTrue([dict valueForKey:NO value:NULL]); 1203 XCTAssertTrue([dict getInt64:NULL forKey:NO]);
1204 XCTAssertTrue([dict valueForKey:NO value:&value]); 1204 XCTAssertTrue([dict getInt64:&value forKey:NO]);
1205 XCTAssertEqual(value, 401); 1205 XCTAssertEqual(value, 401);
1206 1206
1207 [dict setValue:401 forKey:YES]; 1207 [dict setInt64:401 forKey:YES];
1208 XCTAssertEqual(dict.count, 2U); 1208 XCTAssertEqual(dict.count, 2U);
1209 XCTAssertTrue([dict valueForKey:YES value:NULL]); 1209 XCTAssertTrue([dict getInt64:NULL forKey:YES]);
1210 XCTAssertTrue([dict valueForKey:YES value:&value]); 1210 XCTAssertTrue([dict getInt64:&value forKey:YES]);
1211 XCTAssertEqual(value, 401); 1211 XCTAssertEqual(value, 401);
1212 XCTAssertTrue([dict valueForKey:NO value:NULL]); 1212 XCTAssertTrue([dict getInt64:NULL forKey:NO]);
1213 XCTAssertTrue([dict valueForKey:NO value:&value]); 1213 XCTAssertTrue([dict getInt64:&value forKey:NO]);
1214 XCTAssertEqual(value, 401); 1214 XCTAssertEqual(value, 401);
1215 1215
1216 [dict setValue:400 forKey:NO]; 1216 [dict setInt64:400 forKey:NO];
1217 XCTAssertEqual(dict.count, 2U); 1217 XCTAssertEqual(dict.count, 2U);
1218 XCTAssertTrue([dict valueForKey:YES value:NULL]); 1218 XCTAssertTrue([dict getInt64:NULL forKey:YES]);
1219 XCTAssertTrue([dict valueForKey:YES value:&value]); 1219 XCTAssertTrue([dict getInt64:&value forKey:YES]);
1220 XCTAssertEqual(value, 401); 1220 XCTAssertEqual(value, 401);
1221 XCTAssertTrue([dict valueForKey:NO value:NULL]); 1221 XCTAssertTrue([dict getInt64:NULL forKey:NO]);
1222 XCTAssertTrue([dict valueForKey:NO value:&value]); 1222 XCTAssertTrue([dict getInt64:&value forKey:NO]);
1223 XCTAssertEqual(value, 400); 1223 XCTAssertEqual(value, 400);
1224 1224
1225 const BOOL kKeys2[] = { NO, YES }; 1225 const BOOL kKeys2[] = { NO, YES };
1226 const int64_t kValues2[] = { 401, 400 }; 1226 const int64_t kValues2[] = { 401, 400 };
1227 GPBBoolInt64Dictionary *dict2 = 1227 GPBBoolInt64Dictionary *dict2 =
1228 [[GPBBoolInt64Dictionary alloc] initWithValues:kValues2 1228 [[GPBBoolInt64Dictionary alloc] initWithInt64s:kValues2
1229 forKeys:kKeys2 1229 forKeys:kKeys2
1230 count:GPBARRAYSIZE(kValues2)]; 1230 count:GPBARRAYSIZE(kValues2)];
1231 XCTAssertNotNil(dict2); 1231 XCTAssertNotNil(dict2);
1232 [dict addEntriesFromDictionary:dict2]; 1232 [dict addEntriesFromDictionary:dict2];
1233 XCTAssertEqual(dict.count, 2U); 1233 XCTAssertEqual(dict.count, 2U);
1234 XCTAssertTrue([dict valueForKey:YES value:NULL]); 1234 XCTAssertTrue([dict getInt64:NULL forKey:YES]);
1235 XCTAssertTrue([dict valueForKey:YES value:&value]); 1235 XCTAssertTrue([dict getInt64:&value forKey:YES]);
1236 XCTAssertEqual(value, 400); 1236 XCTAssertEqual(value, 400);
1237 XCTAssertTrue([dict valueForKey:NO value:NULL]); 1237 XCTAssertTrue([dict getInt64:NULL forKey:NO]);
1238 XCTAssertTrue([dict valueForKey:NO value:&value]); 1238 XCTAssertTrue([dict getInt64:&value forKey:NO]);
1239 XCTAssertEqual(value, 401); 1239 XCTAssertEqual(value, 401);
1240 1240
1241 [dict2 release]; 1241 [dict2 release];
1242 [dict release]; 1242 [dict release];
1243 } 1243 }
1244 1244
1245 @end 1245 @end
1246 1246
1247 //%PDDM-EXPAND BOOL_TESTS_FOR_POD_VALUE(Bool, BOOL, NO, YES) 1247 //%PDDM-EXPAND BOOL_TESTS_FOR_POD_VALUE(Bool, BOOL, NO, YES)
1248 // This block of code is generated, do not edit it directly. 1248 // This block of code is generated, do not edit it directly.
1249 1249
1250 #pragma mark - Bool -> Bool 1250 #pragma mark - Bool -> Bool
1251 1251
1252 @interface GPBBoolBoolDictionaryTests : XCTestCase 1252 @interface GPBBoolBoolDictionaryTests : XCTestCase
1253 @end 1253 @end
1254 1254
1255 @implementation GPBBoolBoolDictionaryTests 1255 @implementation GPBBoolBoolDictionaryTests
1256 1256
1257 - (void)testEmpty { 1257 - (void)testEmpty {
1258 GPBBoolBoolDictionary *dict = [[GPBBoolBoolDictionary alloc] init]; 1258 GPBBoolBoolDictionary *dict = [[GPBBoolBoolDictionary alloc] init];
1259 XCTAssertNotNil(dict); 1259 XCTAssertNotNil(dict);
1260 XCTAssertEqual(dict.count, 0U); 1260 XCTAssertEqual(dict.count, 0U);
1261 XCTAssertFalse([dict valueForKey:YES value:NULL]); 1261 XCTAssertFalse([dict getBool:NULL forKey:YES]);
1262 [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, BOOL aValue, BOOL *stop) { 1262 [dict enumerateKeysAndBoolsUsingBlock:^(BOOL aKey, BOOL aValue, BOOL *stop) {
1263 #pragma unused(aKey, aValue, stop) 1263 #pragma unused(aKey, aValue, stop)
1264 XCTFail(@"Shouldn't get here!"); 1264 XCTFail(@"Shouldn't get here!");
1265 }]; 1265 }];
1266 [dict release]; 1266 [dict release];
1267 } 1267 }
1268 1268
1269 - (void)testOne { 1269 - (void)testOne {
1270 GPBBoolBoolDictionary *dict = [GPBBoolBoolDictionary dictionaryWithValue:NO fo rKey:YES]; 1270 GPBBoolBoolDictionary *dict = [GPBBoolBoolDictionary dictionaryWithBool:NO for Key:YES];
1271 XCTAssertNotNil(dict); 1271 XCTAssertNotNil(dict);
1272 XCTAssertEqual(dict.count, 1U); 1272 XCTAssertEqual(dict.count, 1U);
1273 BOOL value; 1273 BOOL value;
1274 XCTAssertTrue([dict valueForKey:YES value:NULL]); 1274 XCTAssertTrue([dict getBool:NULL forKey:YES]);
1275 XCTAssertTrue([dict valueForKey:YES value:&value]); 1275 XCTAssertTrue([dict getBool:&value forKey:YES]);
1276 XCTAssertEqual(value, NO); 1276 XCTAssertEqual(value, NO);
1277 XCTAssertFalse([dict valueForKey:NO value:NULL]); 1277 XCTAssertFalse([dict getBool:NULL forKey:NO]);
1278 [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, BOOL aValue, BOOL *stop) { 1278 [dict enumerateKeysAndBoolsUsingBlock:^(BOOL aKey, BOOL aValue, BOOL *stop) {
1279 XCTAssertEqual(aKey, YES); 1279 XCTAssertEqual(aKey, YES);
1280 XCTAssertEqual(aValue, NO); 1280 XCTAssertEqual(aValue, NO);
1281 XCTAssertNotEqual(stop, NULL); 1281 XCTAssertNotEqual(stop, NULL);
1282 }]; 1282 }];
1283 } 1283 }
1284 1284
1285 - (void)testBasics { 1285 - (void)testBasics {
1286 const BOOL kKeys[] = { YES, NO }; 1286 const BOOL kKeys[] = { YES, NO };
1287 const BOOL kValues[] = { NO, YES }; 1287 const BOOL kValues[] = { NO, YES };
1288 GPBBoolBoolDictionary *dict = 1288 GPBBoolBoolDictionary *dict =
1289 [[GPBBoolBoolDictionary alloc] initWithValues:kValues 1289 [[GPBBoolBoolDictionary alloc] initWithBools:kValues
1290 forKeys:kKeys 1290 forKeys:kKeys
1291 count:GPBARRAYSIZE(kValues)]; 1291 count:GPBARRAYSIZE(kValues)];
1292 XCTAssertNotNil(dict); 1292 XCTAssertNotNil(dict);
1293 XCTAssertEqual(dict.count, 2U); 1293 XCTAssertEqual(dict.count, 2U);
1294 BOOL value; 1294 BOOL value;
1295 XCTAssertTrue([dict valueForKey:YES value:NULL]); 1295 XCTAssertTrue([dict getBool:NULL forKey:YES]);
1296 XCTAssertTrue([dict valueForKey:YES value:&value]); 1296 XCTAssertTrue([dict getBool:&value forKey:YES]);
1297 XCTAssertEqual(value, NO); 1297 XCTAssertEqual(value, NO);
1298 XCTAssertTrue([dict valueForKey:NO value:NULL]); 1298 XCTAssertTrue([dict getBool:NULL forKey:NO]);
1299 XCTAssertTrue([dict valueForKey:NO value:&value]); 1299 XCTAssertTrue([dict getBool:&value forKey:NO]);
1300 XCTAssertEqual(value, YES); 1300 XCTAssertEqual(value, YES);
1301 1301
1302 __block NSUInteger idx = 0; 1302 __block NSUInteger idx = 0;
1303 BOOL *seenKeys = malloc(2 * sizeof(BOOL)); 1303 BOOL *seenKeys = malloc(2 * sizeof(BOOL));
1304 BOOL *seenValues = malloc(2 * sizeof(BOOL)); 1304 BOOL *seenValues = malloc(2 * sizeof(BOOL));
1305 [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, BOOL aValue, BOOL *stop) { 1305 [dict enumerateKeysAndBoolsUsingBlock:^(BOOL aKey, BOOL aValue, BOOL *stop) {
1306 XCTAssertLessThan(idx, 2U); 1306 XCTAssertLessThan(idx, 2U);
1307 seenKeys[idx] = aKey; 1307 seenKeys[idx] = aKey;
1308 seenValues[idx] = aValue; 1308 seenValues[idx] = aValue;
1309 XCTAssertNotEqual(stop, NULL); 1309 XCTAssertNotEqual(stop, NULL);
1310 ++idx; 1310 ++idx;
1311 }]; 1311 }];
1312 for (int i = 0; i < 2; ++i) { 1312 for (int i = 0; i < 2; ++i) {
1313 BOOL foundKey = NO; 1313 BOOL foundKey = NO;
1314 for (int j = 0; (j < 2) && !foundKey; ++j) { 1314 for (int j = 0; (j < 2) && !foundKey; ++j) {
1315 if (kKeys[i] == seenKeys[j]) { 1315 if (kKeys[i] == seenKeys[j]) {
1316 foundKey = YES; 1316 foundKey = YES;
1317 XCTAssertEqual(kValues[i], seenValues[j], @"i = %d, j = %d", i, j); 1317 XCTAssertEqual(kValues[i], seenValues[j], @"i = %d, j = %d", i, j);
1318 } 1318 }
1319 } 1319 }
1320 XCTAssertTrue(foundKey, @"i = %d", i); 1320 XCTAssertTrue(foundKey, @"i = %d", i);
1321 } 1321 }
1322 free(seenKeys); 1322 free(seenKeys);
1323 free(seenValues); 1323 free(seenValues);
1324 1324
1325 // Stopping the enumeration. 1325 // Stopping the enumeration.
1326 idx = 0; 1326 idx = 0;
1327 [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, BOOL aValue, BOOL *stop) { 1327 [dict enumerateKeysAndBoolsUsingBlock:^(BOOL aKey, BOOL aValue, BOOL *stop) {
1328 #pragma unused(aKey, aValue) 1328 #pragma unused(aKey, aValue)
1329 if (idx == 0) *stop = YES; 1329 if (idx == 0) *stop = YES;
1330 XCTAssertNotEqual(idx, 2U); 1330 XCTAssertNotEqual(idx, 2U);
1331 ++idx; 1331 ++idx;
1332 }]; 1332 }];
1333 [dict release]; 1333 [dict release];
1334 } 1334 }
1335 1335
1336 - (void)testEquality { 1336 - (void)testEquality {
1337 const BOOL kKeys1[] = { YES, NO }; 1337 const BOOL kKeys1[] = { YES, NO };
1338 const BOOL kKeys2[] = { NO, YES }; 1338 const BOOL kKeys2[] = { NO, YES };
1339 const BOOL kValues1[] = { NO, YES }; 1339 const BOOL kValues1[] = { NO, YES };
1340 const BOOL kValues2[] = { YES, NO }; 1340 const BOOL kValues2[] = { YES, NO };
1341 const BOOL kValues3[] = { YES }; 1341 const BOOL kValues3[] = { YES };
1342 GPBBoolBoolDictionary *dict1 = 1342 GPBBoolBoolDictionary *dict1 =
1343 [[GPBBoolBoolDictionary alloc] initWithValues:kValues1 1343 [[GPBBoolBoolDictionary alloc] initWithBools:kValues1
1344 forKeys:kKeys1 1344 forKeys:kKeys1
1345 count:GPBARRAYSIZE(kValues1)]; 1345 count:GPBARRAYSIZE(kValues1)];
1346 XCTAssertNotNil(dict1); 1346 XCTAssertNotNil(dict1);
1347 GPBBoolBoolDictionary *dict1prime = 1347 GPBBoolBoolDictionary *dict1prime =
1348 [[GPBBoolBoolDictionary alloc] initWithValues:kValues1 1348 [[GPBBoolBoolDictionary alloc] initWithBools:kValues1
1349 forKeys:kKeys1 1349 forKeys:kKeys1
1350 count:GPBARRAYSIZE(kValues1)]; 1350 count:GPBARRAYSIZE(kValues1)];
1351 XCTAssertNotNil(dict1prime); 1351 XCTAssertNotNil(dict1prime);
1352 GPBBoolBoolDictionary *dict2 = 1352 GPBBoolBoolDictionary *dict2 =
1353 [[GPBBoolBoolDictionary alloc] initWithValues:kValues2 1353 [[GPBBoolBoolDictionary alloc] initWithBools:kValues2
1354 forKeys:kKeys1 1354 forKeys:kKeys1
1355 count:GPBARRAYSIZE(kValues2)]; 1355 count:GPBARRAYSIZE(kValues2)];
1356 XCTAssertNotNil(dict2); 1356 XCTAssertNotNil(dict2);
1357 GPBBoolBoolDictionary *dict3 = 1357 GPBBoolBoolDictionary *dict3 =
1358 [[GPBBoolBoolDictionary alloc] initWithValues:kValues1 1358 [[GPBBoolBoolDictionary alloc] initWithBools:kValues1
1359 forKeys:kKeys2 1359 forKeys:kKeys2
1360 count:GPBARRAYSIZE(kValues1)]; 1360 count:GPBARRAYSIZE(kValues1)];
1361 XCTAssertNotNil(dict3); 1361 XCTAssertNotNil(dict3);
1362 GPBBoolBoolDictionary *dict4 = 1362 GPBBoolBoolDictionary *dict4 =
1363 [[GPBBoolBoolDictionary alloc] initWithValues:kValues3 1363 [[GPBBoolBoolDictionary alloc] initWithBools:kValues3
1364 forKeys:kKeys1 1364 forKeys:kKeys1
1365 count:GPBARRAYSIZE(kValues3)]; 1365 count:GPBARRAYSIZE(kValues3)];
1366 XCTAssertNotNil(dict4); 1366 XCTAssertNotNil(dict4);
1367 1367
1368 // 1/1Prime should be different objects, but equal. 1368 // 1/1Prime should be different objects, but equal.
1369 XCTAssertNotEqual(dict1, dict1prime); 1369 XCTAssertNotEqual(dict1, dict1prime);
1370 XCTAssertEqualObjects(dict1, dict1prime); 1370 XCTAssertEqualObjects(dict1, dict1prime);
1371 // Equal, so they must have same hash. 1371 // Equal, so they must have same hash.
1372 XCTAssertEqual([dict1 hash], [dict1prime hash]); 1372 XCTAssertEqual([dict1 hash], [dict1prime hash]);
1373 1373
1374 // 2 is same keys, different values; not equal. 1374 // 2 is same keys, different values; not equal.
1375 XCTAssertNotEqualObjects(dict1, dict2); 1375 XCTAssertNotEqualObjects(dict1, dict2);
1376 1376
1377 // 3 is different keys, same values; not equal. 1377 // 3 is different keys, same values; not equal.
1378 XCTAssertNotEqualObjects(dict1, dict3); 1378 XCTAssertNotEqualObjects(dict1, dict3);
1379 1379
1380 // 4 Fewer pairs; not equal 1380 // 4 Fewer pairs; not equal
1381 XCTAssertNotEqualObjects(dict1, dict4); 1381 XCTAssertNotEqualObjects(dict1, dict4);
1382 1382
1383 [dict1 release]; 1383 [dict1 release];
1384 [dict1prime release]; 1384 [dict1prime release];
1385 [dict2 release]; 1385 [dict2 release];
1386 [dict3 release]; 1386 [dict3 release];
1387 [dict4 release]; 1387 [dict4 release];
1388 } 1388 }
1389 1389
1390 - (void)testCopy { 1390 - (void)testCopy {
1391 const BOOL kKeys[] = { YES, NO }; 1391 const BOOL kKeys[] = { YES, NO };
1392 const BOOL kValues[] = { NO, YES }; 1392 const BOOL kValues[] = { NO, YES };
1393 GPBBoolBoolDictionary *dict = 1393 GPBBoolBoolDictionary *dict =
1394 [[GPBBoolBoolDictionary alloc] initWithValues:kValues 1394 [[GPBBoolBoolDictionary alloc] initWithBools:kValues
1395 forKeys:kKeys 1395 forKeys:kKeys
1396 count:GPBARRAYSIZE(kValues)]; 1396 count:GPBARRAYSIZE(kValues)];
1397 XCTAssertNotNil(dict); 1397 XCTAssertNotNil(dict);
1398 1398
1399 GPBBoolBoolDictionary *dict2 = [dict copy]; 1399 GPBBoolBoolDictionary *dict2 = [dict copy];
1400 XCTAssertNotNil(dict2); 1400 XCTAssertNotNil(dict2);
1401 1401
1402 // Should be new object but equal. 1402 // Should be new object but equal.
1403 XCTAssertNotEqual(dict, dict2); 1403 XCTAssertNotEqual(dict, dict2);
1404 XCTAssertEqualObjects(dict, dict2); 1404 XCTAssertEqualObjects(dict, dict2);
1405 XCTAssertTrue([dict2 isKindOfClass:[GPBBoolBoolDictionary class]]); 1405 XCTAssertTrue([dict2 isKindOfClass:[GPBBoolBoolDictionary class]]);
1406 1406
1407 [dict2 release]; 1407 [dict2 release];
1408 [dict release]; 1408 [dict release];
1409 } 1409 }
1410 1410
1411 - (void)testDictionaryFromDictionary { 1411 - (void)testDictionaryFromDictionary {
1412 const BOOL kKeys[] = { YES, NO }; 1412 const BOOL kKeys[] = { YES, NO };
1413 const BOOL kValues[] = { NO, YES }; 1413 const BOOL kValues[] = { NO, YES };
1414 GPBBoolBoolDictionary *dict = 1414 GPBBoolBoolDictionary *dict =
1415 [[GPBBoolBoolDictionary alloc] initWithValues:kValues 1415 [[GPBBoolBoolDictionary alloc] initWithBools:kValues
1416 forKeys:kKeys 1416 forKeys:kKeys
1417 count:GPBARRAYSIZE(kValues)]; 1417 count:GPBARRAYSIZE(kValues)];
1418 XCTAssertNotNil(dict); 1418 XCTAssertNotNil(dict);
1419 1419
1420 GPBBoolBoolDictionary *dict2 = 1420 GPBBoolBoolDictionary *dict2 =
1421 [GPBBoolBoolDictionary dictionaryWithDictionary:dict]; 1421 [GPBBoolBoolDictionary dictionaryWithDictionary:dict];
1422 XCTAssertNotNil(dict2); 1422 XCTAssertNotNil(dict2);
1423 1423
1424 // Should be new pointer, but equal objects. 1424 // Should be new pointer, but equal objects.
1425 XCTAssertNotEqual(dict, dict2); 1425 XCTAssertNotEqual(dict, dict2);
1426 XCTAssertEqualObjects(dict, dict2); 1426 XCTAssertEqualObjects(dict, dict2);
1427 [dict release]; 1427 [dict release];
1428 } 1428 }
1429 1429
1430 - (void)testAdds { 1430 - (void)testAdds {
1431 GPBBoolBoolDictionary *dict = [GPBBoolBoolDictionary dictionary]; 1431 GPBBoolBoolDictionary *dict = [GPBBoolBoolDictionary dictionary];
1432 XCTAssertNotNil(dict); 1432 XCTAssertNotNil(dict);
1433 1433
1434 XCTAssertEqual(dict.count, 0U); 1434 XCTAssertEqual(dict.count, 0U);
1435 [dict setValue:NO forKey:YES]; 1435 [dict setBool:NO forKey:YES];
1436 XCTAssertEqual(dict.count, 1U); 1436 XCTAssertEqual(dict.count, 1U);
1437 1437
1438 const BOOL kKeys[] = { NO }; 1438 const BOOL kKeys[] = { NO };
1439 const BOOL kValues[] = { YES }; 1439 const BOOL kValues[] = { YES };
1440 GPBBoolBoolDictionary *dict2 = 1440 GPBBoolBoolDictionary *dict2 =
1441 [[GPBBoolBoolDictionary alloc] initWithValues:kValues 1441 [[GPBBoolBoolDictionary alloc] initWithBools:kValues
1442 forKeys:kKeys 1442 forKeys:kKeys
1443 count:GPBARRAYSIZE(kValues)]; 1443 count:GPBARRAYSIZE(kValues)];
1444 XCTAssertNotNil(dict2); 1444 XCTAssertNotNil(dict2);
1445 [dict addEntriesFromDictionary:dict2]; 1445 [dict addEntriesFromDictionary:dict2];
1446 XCTAssertEqual(dict.count, 2U); 1446 XCTAssertEqual(dict.count, 2U);
1447 1447
1448 BOOL value; 1448 BOOL value;
1449 XCTAssertTrue([dict valueForKey:YES value:NULL]); 1449 XCTAssertTrue([dict getBool:NULL forKey:YES]);
1450 XCTAssertTrue([dict valueForKey:YES value:&value]); 1450 XCTAssertTrue([dict getBool:&value forKey:YES]);
1451 XCTAssertEqual(value, NO); 1451 XCTAssertEqual(value, NO);
1452 XCTAssertTrue([dict valueForKey:NO value:NULL]); 1452 XCTAssertTrue([dict getBool:NULL forKey:NO]);
1453 XCTAssertTrue([dict valueForKey:NO value:&value]); 1453 XCTAssertTrue([dict getBool:&value forKey:NO]);
1454 XCTAssertEqual(value, YES); 1454 XCTAssertEqual(value, YES);
1455 [dict2 release]; 1455 [dict2 release];
1456 } 1456 }
1457 1457
1458 - (void)testRemove { 1458 - (void)testRemove {
1459 const BOOL kKeys[] = { YES, NO}; 1459 const BOOL kKeys[] = { YES, NO};
1460 const BOOL kValues[] = { NO, YES }; 1460 const BOOL kValues[] = { NO, YES };
1461 GPBBoolBoolDictionary *dict = 1461 GPBBoolBoolDictionary *dict =
1462 [[GPBBoolBoolDictionary alloc] initWithValues:kValues 1462 [[GPBBoolBoolDictionary alloc] initWithBools:kValues
1463 forKeys:kKeys 1463 forKeys:kKeys
1464 count:GPBARRAYSIZE(kValues)]; 1464 count:GPBARRAYSIZE(kValues)];
1465 XCTAssertNotNil(dict); 1465 XCTAssertNotNil(dict);
1466 XCTAssertEqual(dict.count, 2U); 1466 XCTAssertEqual(dict.count, 2U);
1467 1467
1468 [dict removeValueForKey:NO]; 1468 [dict removeBoolForKey:NO];
1469 XCTAssertEqual(dict.count, 1U); 1469 XCTAssertEqual(dict.count, 1U);
1470 BOOL value; 1470 BOOL value;
1471 XCTAssertTrue([dict valueForKey:YES value:NULL]); 1471 XCTAssertTrue([dict getBool:NULL forKey:YES]);
1472 XCTAssertTrue([dict valueForKey:YES value:&value]); 1472 XCTAssertTrue([dict getBool:&value forKey:YES]);
1473 XCTAssertEqual(value, NO); 1473 XCTAssertEqual(value, NO);
1474 XCTAssertFalse([dict valueForKey:NO value:NULL]); 1474 XCTAssertFalse([dict getBool:NULL forKey:NO]);
1475 1475
1476 // Remove again does nothing. 1476 // Remove again does nothing.
1477 [dict removeValueForKey:NO]; 1477 [dict removeBoolForKey:NO];
1478 XCTAssertEqual(dict.count, 1U); 1478 XCTAssertEqual(dict.count, 1U);
1479 XCTAssertTrue([dict valueForKey:YES value:NULL]); 1479 XCTAssertTrue([dict getBool:NULL forKey:YES]);
1480 XCTAssertTrue([dict valueForKey:YES value:&value]); 1480 XCTAssertTrue([dict getBool:&value forKey:YES]);
1481 XCTAssertEqual(value, NO); 1481 XCTAssertEqual(value, NO);
1482 XCTAssertFalse([dict valueForKey:NO value:NULL]); 1482 XCTAssertFalse([dict getBool:NULL forKey:NO]);
1483 1483
1484 [dict removeAll]; 1484 [dict removeAll];
1485 XCTAssertEqual(dict.count, 0U); 1485 XCTAssertEqual(dict.count, 0U);
1486 XCTAssertFalse([dict valueForKey:YES value:NULL]); 1486 XCTAssertFalse([dict getBool:NULL forKey:YES]);
1487 XCTAssertFalse([dict valueForKey:NO value:NULL]); 1487 XCTAssertFalse([dict getBool:NULL forKey:NO]);
1488 [dict release]; 1488 [dict release];
1489 } 1489 }
1490 1490
1491 - (void)testInplaceMutation { 1491 - (void)testInplaceMutation {
1492 const BOOL kKeys[] = { YES, NO }; 1492 const BOOL kKeys[] = { YES, NO };
1493 const BOOL kValues[] = { NO, YES }; 1493 const BOOL kValues[] = { NO, YES };
1494 GPBBoolBoolDictionary *dict = 1494 GPBBoolBoolDictionary *dict =
1495 [[GPBBoolBoolDictionary alloc] initWithValues:kValues 1495 [[GPBBoolBoolDictionary alloc] initWithBools:kValues
1496 forKeys:kKeys 1496 forKeys:kKeys
1497 count:GPBARRAYSIZE(kValues)]; 1497 count:GPBARRAYSIZE(kValues)];
1498 XCTAssertNotNil(dict); 1498 XCTAssertNotNil(dict);
1499 XCTAssertEqual(dict.count, 2U); 1499 XCTAssertEqual(dict.count, 2U);
1500 BOOL value; 1500 BOOL value;
1501 XCTAssertTrue([dict valueForKey:YES value:NULL]); 1501 XCTAssertTrue([dict getBool:NULL forKey:YES]);
1502 XCTAssertTrue([dict valueForKey:YES value:&value]); 1502 XCTAssertTrue([dict getBool:&value forKey:YES]);
1503 XCTAssertEqual(value, NO); 1503 XCTAssertEqual(value, NO);
1504 XCTAssertTrue([dict valueForKey:NO value:NULL]); 1504 XCTAssertTrue([dict getBool:NULL forKey:NO]);
1505 XCTAssertTrue([dict valueForKey:NO value:&value]); 1505 XCTAssertTrue([dict getBool:&value forKey:NO]);
1506 XCTAssertEqual(value, YES); 1506 XCTAssertEqual(value, YES);
1507 1507
1508 [dict setValue:YES forKey:YES]; 1508 [dict setBool:YES forKey:YES];
1509 XCTAssertEqual(dict.count, 2U); 1509 XCTAssertEqual(dict.count, 2U);
1510 XCTAssertTrue([dict valueForKey:YES value:NULL]); 1510 XCTAssertTrue([dict getBool:NULL forKey:YES]);
1511 XCTAssertTrue([dict valueForKey:YES value:&value]); 1511 XCTAssertTrue([dict getBool:&value forKey:YES]);
1512 XCTAssertEqual(value, YES); 1512 XCTAssertEqual(value, YES);
1513 XCTAssertTrue([dict valueForKey:NO value:NULL]); 1513 XCTAssertTrue([dict getBool:NULL forKey:NO]);
1514 XCTAssertTrue([dict valueForKey:NO value:&value]); 1514 XCTAssertTrue([dict getBool:&value forKey:NO]);
1515 XCTAssertEqual(value, YES); 1515 XCTAssertEqual(value, YES);
1516 1516
1517 [dict setValue:NO forKey:NO]; 1517 [dict setBool:NO forKey:NO];
1518 XCTAssertEqual(dict.count, 2U); 1518 XCTAssertEqual(dict.count, 2U);
1519 XCTAssertTrue([dict valueForKey:YES value:NULL]); 1519 XCTAssertTrue([dict getBool:NULL forKey:YES]);
1520 XCTAssertTrue([dict valueForKey:YES value:&value]); 1520 XCTAssertTrue([dict getBool:&value forKey:YES]);
1521 XCTAssertEqual(value, YES); 1521 XCTAssertEqual(value, YES);
1522 XCTAssertTrue([dict valueForKey:NO value:NULL]); 1522 XCTAssertTrue([dict getBool:NULL forKey:NO]);
1523 XCTAssertTrue([dict valueForKey:NO value:&value]); 1523 XCTAssertTrue([dict getBool:&value forKey:NO]);
1524 XCTAssertEqual(value, NO); 1524 XCTAssertEqual(value, NO);
1525 1525
1526 const BOOL kKeys2[] = { NO, YES }; 1526 const BOOL kKeys2[] = { NO, YES };
1527 const BOOL kValues2[] = { YES, NO }; 1527 const BOOL kValues2[] = { YES, NO };
1528 GPBBoolBoolDictionary *dict2 = 1528 GPBBoolBoolDictionary *dict2 =
1529 [[GPBBoolBoolDictionary alloc] initWithValues:kValues2 1529 [[GPBBoolBoolDictionary alloc] initWithBools:kValues2
1530 forKeys:kKeys2 1530 forKeys:kKeys2
1531 count:GPBARRAYSIZE(kValues2)]; 1531 count:GPBARRAYSIZE(kValues2)];
1532 XCTAssertNotNil(dict2); 1532 XCTAssertNotNil(dict2);
1533 [dict addEntriesFromDictionary:dict2]; 1533 [dict addEntriesFromDictionary:dict2];
1534 XCTAssertEqual(dict.count, 2U); 1534 XCTAssertEqual(dict.count, 2U);
1535 XCTAssertTrue([dict valueForKey:YES value:NULL]); 1535 XCTAssertTrue([dict getBool:NULL forKey:YES]);
1536 XCTAssertTrue([dict valueForKey:YES value:&value]); 1536 XCTAssertTrue([dict getBool:&value forKey:YES]);
1537 XCTAssertEqual(value, NO); 1537 XCTAssertEqual(value, NO);
1538 XCTAssertTrue([dict valueForKey:NO value:NULL]); 1538 XCTAssertTrue([dict getBool:NULL forKey:NO]);
1539 XCTAssertTrue([dict valueForKey:NO value:&value]); 1539 XCTAssertTrue([dict getBool:&value forKey:NO]);
1540 XCTAssertEqual(value, YES); 1540 XCTAssertEqual(value, YES);
1541 1541
1542 [dict2 release]; 1542 [dict2 release];
1543 [dict release]; 1543 [dict release];
1544 } 1544 }
1545 1545
1546 @end 1546 @end
1547 1547
1548 //%PDDM-EXPAND BOOL_TESTS_FOR_POD_VALUE(Float, float, 500.f, 501.f) 1548 //%PDDM-EXPAND BOOL_TESTS_FOR_POD_VALUE(Float, float, 500.f, 501.f)
1549 // This block of code is generated, do not edit it directly. 1549 // This block of code is generated, do not edit it directly.
1550 1550
1551 #pragma mark - Bool -> Float 1551 #pragma mark - Bool -> Float
1552 1552
1553 @interface GPBBoolFloatDictionaryTests : XCTestCase 1553 @interface GPBBoolFloatDictionaryTests : XCTestCase
1554 @end 1554 @end
1555 1555
1556 @implementation GPBBoolFloatDictionaryTests 1556 @implementation GPBBoolFloatDictionaryTests
1557 1557
1558 - (void)testEmpty { 1558 - (void)testEmpty {
1559 GPBBoolFloatDictionary *dict = [[GPBBoolFloatDictionary alloc] init]; 1559 GPBBoolFloatDictionary *dict = [[GPBBoolFloatDictionary alloc] init];
1560 XCTAssertNotNil(dict); 1560 XCTAssertNotNil(dict);
1561 XCTAssertEqual(dict.count, 0U); 1561 XCTAssertEqual(dict.count, 0U);
1562 XCTAssertFalse([dict valueForKey:YES value:NULL]); 1562 XCTAssertFalse([dict getFloat:NULL forKey:YES]);
1563 [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, float aValue, BOOL *stop) { 1563 [dict enumerateKeysAndFloatsUsingBlock:^(BOOL aKey, float aValue, BOOL *stop) {
1564 #pragma unused(aKey, aValue, stop) 1564 #pragma unused(aKey, aValue, stop)
1565 XCTFail(@"Shouldn't get here!"); 1565 XCTFail(@"Shouldn't get here!");
1566 }]; 1566 }];
1567 [dict release]; 1567 [dict release];
1568 } 1568 }
1569 1569
1570 - (void)testOne { 1570 - (void)testOne {
1571 GPBBoolFloatDictionary *dict = [GPBBoolFloatDictionary dictionaryWithValue:500 .f forKey:YES]; 1571 GPBBoolFloatDictionary *dict = [GPBBoolFloatDictionary dictionaryWithFloat:500 .f forKey:YES];
1572 XCTAssertNotNil(dict); 1572 XCTAssertNotNil(dict);
1573 XCTAssertEqual(dict.count, 1U); 1573 XCTAssertEqual(dict.count, 1U);
1574 float value; 1574 float value;
1575 XCTAssertTrue([dict valueForKey:YES value:NULL]); 1575 XCTAssertTrue([dict getFloat:NULL forKey:YES]);
1576 XCTAssertTrue([dict valueForKey:YES value:&value]); 1576 XCTAssertTrue([dict getFloat:&value forKey:YES]);
1577 XCTAssertEqual(value, 500.f); 1577 XCTAssertEqual(value, 500.f);
1578 XCTAssertFalse([dict valueForKey:NO value:NULL]); 1578 XCTAssertFalse([dict getFloat:NULL forKey:NO]);
1579 [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, float aValue, BOOL *stop) { 1579 [dict enumerateKeysAndFloatsUsingBlock:^(BOOL aKey, float aValue, BOOL *stop) {
1580 XCTAssertEqual(aKey, YES); 1580 XCTAssertEqual(aKey, YES);
1581 XCTAssertEqual(aValue, 500.f); 1581 XCTAssertEqual(aValue, 500.f);
1582 XCTAssertNotEqual(stop, NULL); 1582 XCTAssertNotEqual(stop, NULL);
1583 }]; 1583 }];
1584 } 1584 }
1585 1585
1586 - (void)testBasics { 1586 - (void)testBasics {
1587 const BOOL kKeys[] = { YES, NO }; 1587 const BOOL kKeys[] = { YES, NO };
1588 const float kValues[] = { 500.f, 501.f }; 1588 const float kValues[] = { 500.f, 501.f };
1589 GPBBoolFloatDictionary *dict = 1589 GPBBoolFloatDictionary *dict =
1590 [[GPBBoolFloatDictionary alloc] initWithValues:kValues 1590 [[GPBBoolFloatDictionary alloc] initWithFloats:kValues
1591 forKeys:kKeys 1591 forKeys:kKeys
1592 count:GPBARRAYSIZE(kValues)]; 1592 count:GPBARRAYSIZE(kValues)];
1593 XCTAssertNotNil(dict); 1593 XCTAssertNotNil(dict);
1594 XCTAssertEqual(dict.count, 2U); 1594 XCTAssertEqual(dict.count, 2U);
1595 float value; 1595 float value;
1596 XCTAssertTrue([dict valueForKey:YES value:NULL]); 1596 XCTAssertTrue([dict getFloat:NULL forKey:YES]);
1597 XCTAssertTrue([dict valueForKey:YES value:&value]); 1597 XCTAssertTrue([dict getFloat:&value forKey:YES]);
1598 XCTAssertEqual(value, 500.f); 1598 XCTAssertEqual(value, 500.f);
1599 XCTAssertTrue([dict valueForKey:NO value:NULL]); 1599 XCTAssertTrue([dict getFloat:NULL forKey:NO]);
1600 XCTAssertTrue([dict valueForKey:NO value:&value]); 1600 XCTAssertTrue([dict getFloat:&value forKey:NO]);
1601 XCTAssertEqual(value, 501.f); 1601 XCTAssertEqual(value, 501.f);
1602 1602
1603 __block NSUInteger idx = 0; 1603 __block NSUInteger idx = 0;
1604 BOOL *seenKeys = malloc(2 * sizeof(BOOL)); 1604 BOOL *seenKeys = malloc(2 * sizeof(BOOL));
1605 float *seenValues = malloc(2 * sizeof(float)); 1605 float *seenValues = malloc(2 * sizeof(float));
1606 [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, float aValue, BOOL *stop) { 1606 [dict enumerateKeysAndFloatsUsingBlock:^(BOOL aKey, float aValue, BOOL *stop) {
1607 XCTAssertLessThan(idx, 2U); 1607 XCTAssertLessThan(idx, 2U);
1608 seenKeys[idx] = aKey; 1608 seenKeys[idx] = aKey;
1609 seenValues[idx] = aValue; 1609 seenValues[idx] = aValue;
1610 XCTAssertNotEqual(stop, NULL); 1610 XCTAssertNotEqual(stop, NULL);
1611 ++idx; 1611 ++idx;
1612 }]; 1612 }];
1613 for (int i = 0; i < 2; ++i) { 1613 for (int i = 0; i < 2; ++i) {
1614 BOOL foundKey = NO; 1614 BOOL foundKey = NO;
1615 for (int j = 0; (j < 2) && !foundKey; ++j) { 1615 for (int j = 0; (j < 2) && !foundKey; ++j) {
1616 if (kKeys[i] == seenKeys[j]) { 1616 if (kKeys[i] == seenKeys[j]) {
1617 foundKey = YES; 1617 foundKey = YES;
1618 XCTAssertEqual(kValues[i], seenValues[j], @"i = %d, j = %d", i, j); 1618 XCTAssertEqual(kValues[i], seenValues[j], @"i = %d, j = %d", i, j);
1619 } 1619 }
1620 } 1620 }
1621 XCTAssertTrue(foundKey, @"i = %d", i); 1621 XCTAssertTrue(foundKey, @"i = %d", i);
1622 } 1622 }
1623 free(seenKeys); 1623 free(seenKeys);
1624 free(seenValues); 1624 free(seenValues);
1625 1625
1626 // Stopping the enumeration. 1626 // Stopping the enumeration.
1627 idx = 0; 1627 idx = 0;
1628 [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, float aValue, BOOL *stop) { 1628 [dict enumerateKeysAndFloatsUsingBlock:^(BOOL aKey, float aValue, BOOL *stop) {
1629 #pragma unused(aKey, aValue) 1629 #pragma unused(aKey, aValue)
1630 if (idx == 0) *stop = YES; 1630 if (idx == 0) *stop = YES;
1631 XCTAssertNotEqual(idx, 2U); 1631 XCTAssertNotEqual(idx, 2U);
1632 ++idx; 1632 ++idx;
1633 }]; 1633 }];
1634 [dict release]; 1634 [dict release];
1635 } 1635 }
1636 1636
1637 - (void)testEquality { 1637 - (void)testEquality {
1638 const BOOL kKeys1[] = { YES, NO }; 1638 const BOOL kKeys1[] = { YES, NO };
1639 const BOOL kKeys2[] = { NO, YES }; 1639 const BOOL kKeys2[] = { NO, YES };
1640 const float kValues1[] = { 500.f, 501.f }; 1640 const float kValues1[] = { 500.f, 501.f };
1641 const float kValues2[] = { 501.f, 500.f }; 1641 const float kValues2[] = { 501.f, 500.f };
1642 const float kValues3[] = { 501.f }; 1642 const float kValues3[] = { 501.f };
1643 GPBBoolFloatDictionary *dict1 = 1643 GPBBoolFloatDictionary *dict1 =
1644 [[GPBBoolFloatDictionary alloc] initWithValues:kValues1 1644 [[GPBBoolFloatDictionary alloc] initWithFloats:kValues1
1645 forKeys:kKeys1 1645 forKeys:kKeys1
1646 count:GPBARRAYSIZE(kValues1)]; 1646 count:GPBARRAYSIZE(kValues1)];
1647 XCTAssertNotNil(dict1); 1647 XCTAssertNotNil(dict1);
1648 GPBBoolFloatDictionary *dict1prime = 1648 GPBBoolFloatDictionary *dict1prime =
1649 [[GPBBoolFloatDictionary alloc] initWithValues:kValues1 1649 [[GPBBoolFloatDictionary alloc] initWithFloats:kValues1
1650 forKeys:kKeys1 1650 forKeys:kKeys1
1651 count:GPBARRAYSIZE(kValues1)]; 1651 count:GPBARRAYSIZE(kValues1)];
1652 XCTAssertNotNil(dict1prime); 1652 XCTAssertNotNil(dict1prime);
1653 GPBBoolFloatDictionary *dict2 = 1653 GPBBoolFloatDictionary *dict2 =
1654 [[GPBBoolFloatDictionary alloc] initWithValues:kValues2 1654 [[GPBBoolFloatDictionary alloc] initWithFloats:kValues2
1655 forKeys:kKeys1 1655 forKeys:kKeys1
1656 count:GPBARRAYSIZE(kValues2)]; 1656 count:GPBARRAYSIZE(kValues2)];
1657 XCTAssertNotNil(dict2); 1657 XCTAssertNotNil(dict2);
1658 GPBBoolFloatDictionary *dict3 = 1658 GPBBoolFloatDictionary *dict3 =
1659 [[GPBBoolFloatDictionary alloc] initWithValues:kValues1 1659 [[GPBBoolFloatDictionary alloc] initWithFloats:kValues1
1660 forKeys:kKeys2 1660 forKeys:kKeys2
1661 count:GPBARRAYSIZE(kValues1)]; 1661 count:GPBARRAYSIZE(kValues1)];
1662 XCTAssertNotNil(dict3); 1662 XCTAssertNotNil(dict3);
1663 GPBBoolFloatDictionary *dict4 = 1663 GPBBoolFloatDictionary *dict4 =
1664 [[GPBBoolFloatDictionary alloc] initWithValues:kValues3 1664 [[GPBBoolFloatDictionary alloc] initWithFloats:kValues3
1665 forKeys:kKeys1 1665 forKeys:kKeys1
1666 count:GPBARRAYSIZE(kValues3)]; 1666 count:GPBARRAYSIZE(kValues3)];
1667 XCTAssertNotNil(dict4); 1667 XCTAssertNotNil(dict4);
1668 1668
1669 // 1/1Prime should be different objects, but equal. 1669 // 1/1Prime should be different objects, but equal.
1670 XCTAssertNotEqual(dict1, dict1prime); 1670 XCTAssertNotEqual(dict1, dict1prime);
1671 XCTAssertEqualObjects(dict1, dict1prime); 1671 XCTAssertEqualObjects(dict1, dict1prime);
1672 // Equal, so they must have same hash. 1672 // Equal, so they must have same hash.
1673 XCTAssertEqual([dict1 hash], [dict1prime hash]); 1673 XCTAssertEqual([dict1 hash], [dict1prime hash]);
1674 1674
(...skipping 10 matching lines...) Expand all
1685 [dict1prime release]; 1685 [dict1prime release];
1686 [dict2 release]; 1686 [dict2 release];
1687 [dict3 release]; 1687 [dict3 release];
1688 [dict4 release]; 1688 [dict4 release];
1689 } 1689 }
1690 1690
1691 - (void)testCopy { 1691 - (void)testCopy {
1692 const BOOL kKeys[] = { YES, NO }; 1692 const BOOL kKeys[] = { YES, NO };
1693 const float kValues[] = { 500.f, 501.f }; 1693 const float kValues[] = { 500.f, 501.f };
1694 GPBBoolFloatDictionary *dict = 1694 GPBBoolFloatDictionary *dict =
1695 [[GPBBoolFloatDictionary alloc] initWithValues:kValues 1695 [[GPBBoolFloatDictionary alloc] initWithFloats:kValues
1696 forKeys:kKeys 1696 forKeys:kKeys
1697 count:GPBARRAYSIZE(kValues)]; 1697 count:GPBARRAYSIZE(kValues)];
1698 XCTAssertNotNil(dict); 1698 XCTAssertNotNil(dict);
1699 1699
1700 GPBBoolFloatDictionary *dict2 = [dict copy]; 1700 GPBBoolFloatDictionary *dict2 = [dict copy];
1701 XCTAssertNotNil(dict2); 1701 XCTAssertNotNil(dict2);
1702 1702
1703 // Should be new object but equal. 1703 // Should be new object but equal.
1704 XCTAssertNotEqual(dict, dict2); 1704 XCTAssertNotEqual(dict, dict2);
1705 XCTAssertEqualObjects(dict, dict2); 1705 XCTAssertEqualObjects(dict, dict2);
1706 XCTAssertTrue([dict2 isKindOfClass:[GPBBoolFloatDictionary class]]); 1706 XCTAssertTrue([dict2 isKindOfClass:[GPBBoolFloatDictionary class]]);
1707 1707
1708 [dict2 release]; 1708 [dict2 release];
1709 [dict release]; 1709 [dict release];
1710 } 1710 }
1711 1711
1712 - (void)testDictionaryFromDictionary { 1712 - (void)testDictionaryFromDictionary {
1713 const BOOL kKeys[] = { YES, NO }; 1713 const BOOL kKeys[] = { YES, NO };
1714 const float kValues[] = { 500.f, 501.f }; 1714 const float kValues[] = { 500.f, 501.f };
1715 GPBBoolFloatDictionary *dict = 1715 GPBBoolFloatDictionary *dict =
1716 [[GPBBoolFloatDictionary alloc] initWithValues:kValues 1716 [[GPBBoolFloatDictionary alloc] initWithFloats:kValues
1717 forKeys:kKeys 1717 forKeys:kKeys
1718 count:GPBARRAYSIZE(kValues)]; 1718 count:GPBARRAYSIZE(kValues)];
1719 XCTAssertNotNil(dict); 1719 XCTAssertNotNil(dict);
1720 1720
1721 GPBBoolFloatDictionary *dict2 = 1721 GPBBoolFloatDictionary *dict2 =
1722 [GPBBoolFloatDictionary dictionaryWithDictionary:dict]; 1722 [GPBBoolFloatDictionary dictionaryWithDictionary:dict];
1723 XCTAssertNotNil(dict2); 1723 XCTAssertNotNil(dict2);
1724 1724
1725 // Should be new pointer, but equal objects. 1725 // Should be new pointer, but equal objects.
1726 XCTAssertNotEqual(dict, dict2); 1726 XCTAssertNotEqual(dict, dict2);
1727 XCTAssertEqualObjects(dict, dict2); 1727 XCTAssertEqualObjects(dict, dict2);
1728 [dict release]; 1728 [dict release];
1729 } 1729 }
1730 1730
1731 - (void)testAdds { 1731 - (void)testAdds {
1732 GPBBoolFloatDictionary *dict = [GPBBoolFloatDictionary dictionary]; 1732 GPBBoolFloatDictionary *dict = [GPBBoolFloatDictionary dictionary];
1733 XCTAssertNotNil(dict); 1733 XCTAssertNotNil(dict);
1734 1734
1735 XCTAssertEqual(dict.count, 0U); 1735 XCTAssertEqual(dict.count, 0U);
1736 [dict setValue:500.f forKey:YES]; 1736 [dict setFloat:500.f forKey:YES];
1737 XCTAssertEqual(dict.count, 1U); 1737 XCTAssertEqual(dict.count, 1U);
1738 1738
1739 const BOOL kKeys[] = { NO }; 1739 const BOOL kKeys[] = { NO };
1740 const float kValues[] = { 501.f }; 1740 const float kValues[] = { 501.f };
1741 GPBBoolFloatDictionary *dict2 = 1741 GPBBoolFloatDictionary *dict2 =
1742 [[GPBBoolFloatDictionary alloc] initWithValues:kValues 1742 [[GPBBoolFloatDictionary alloc] initWithFloats:kValues
1743 forKeys:kKeys 1743 forKeys:kKeys
1744 count:GPBARRAYSIZE(kValues)]; 1744 count:GPBARRAYSIZE(kValues)];
1745 XCTAssertNotNil(dict2); 1745 XCTAssertNotNil(dict2);
1746 [dict addEntriesFromDictionary:dict2]; 1746 [dict addEntriesFromDictionary:dict2];
1747 XCTAssertEqual(dict.count, 2U); 1747 XCTAssertEqual(dict.count, 2U);
1748 1748
1749 float value; 1749 float value;
1750 XCTAssertTrue([dict valueForKey:YES value:NULL]); 1750 XCTAssertTrue([dict getFloat:NULL forKey:YES]);
1751 XCTAssertTrue([dict valueForKey:YES value:&value]); 1751 XCTAssertTrue([dict getFloat:&value forKey:YES]);
1752 XCTAssertEqual(value, 500.f); 1752 XCTAssertEqual(value, 500.f);
1753 XCTAssertTrue([dict valueForKey:NO value:NULL]); 1753 XCTAssertTrue([dict getFloat:NULL forKey:NO]);
1754 XCTAssertTrue([dict valueForKey:NO value:&value]); 1754 XCTAssertTrue([dict getFloat:&value forKey:NO]);
1755 XCTAssertEqual(value, 501.f); 1755 XCTAssertEqual(value, 501.f);
1756 [dict2 release]; 1756 [dict2 release];
1757 } 1757 }
1758 1758
1759 - (void)testRemove { 1759 - (void)testRemove {
1760 const BOOL kKeys[] = { YES, NO}; 1760 const BOOL kKeys[] = { YES, NO};
1761 const float kValues[] = { 500.f, 501.f }; 1761 const float kValues[] = { 500.f, 501.f };
1762 GPBBoolFloatDictionary *dict = 1762 GPBBoolFloatDictionary *dict =
1763 [[GPBBoolFloatDictionary alloc] initWithValues:kValues 1763 [[GPBBoolFloatDictionary alloc] initWithFloats:kValues
1764 forKeys:kKeys 1764 forKeys:kKeys
1765 count:GPBARRAYSIZE(kValues)]; 1765 count:GPBARRAYSIZE(kValues)];
1766 XCTAssertNotNil(dict); 1766 XCTAssertNotNil(dict);
1767 XCTAssertEqual(dict.count, 2U); 1767 XCTAssertEqual(dict.count, 2U);
1768 1768
1769 [dict removeValueForKey:NO]; 1769 [dict removeFloatForKey:NO];
1770 XCTAssertEqual(dict.count, 1U); 1770 XCTAssertEqual(dict.count, 1U);
1771 float value; 1771 float value;
1772 XCTAssertTrue([dict valueForKey:YES value:NULL]); 1772 XCTAssertTrue([dict getFloat:NULL forKey:YES]);
1773 XCTAssertTrue([dict valueForKey:YES value:&value]); 1773 XCTAssertTrue([dict getFloat:&value forKey:YES]);
1774 XCTAssertEqual(value, 500.f); 1774 XCTAssertEqual(value, 500.f);
1775 XCTAssertFalse([dict valueForKey:NO value:NULL]); 1775 XCTAssertFalse([dict getFloat:NULL forKey:NO]);
1776 1776
1777 // Remove again does nothing. 1777 // Remove again does nothing.
1778 [dict removeValueForKey:NO]; 1778 [dict removeFloatForKey:NO];
1779 XCTAssertEqual(dict.count, 1U); 1779 XCTAssertEqual(dict.count, 1U);
1780 XCTAssertTrue([dict valueForKey:YES value:NULL]); 1780 XCTAssertTrue([dict getFloat:NULL forKey:YES]);
1781 XCTAssertTrue([dict valueForKey:YES value:&value]); 1781 XCTAssertTrue([dict getFloat:&value forKey:YES]);
1782 XCTAssertEqual(value, 500.f); 1782 XCTAssertEqual(value, 500.f);
1783 XCTAssertFalse([dict valueForKey:NO value:NULL]); 1783 XCTAssertFalse([dict getFloat:NULL forKey:NO]);
1784 1784
1785 [dict removeAll]; 1785 [dict removeAll];
1786 XCTAssertEqual(dict.count, 0U); 1786 XCTAssertEqual(dict.count, 0U);
1787 XCTAssertFalse([dict valueForKey:YES value:NULL]); 1787 XCTAssertFalse([dict getFloat:NULL forKey:YES]);
1788 XCTAssertFalse([dict valueForKey:NO value:NULL]); 1788 XCTAssertFalse([dict getFloat:NULL forKey:NO]);
1789 [dict release]; 1789 [dict release];
1790 } 1790 }
1791 1791
1792 - (void)testInplaceMutation { 1792 - (void)testInplaceMutation {
1793 const BOOL kKeys[] = { YES, NO }; 1793 const BOOL kKeys[] = { YES, NO };
1794 const float kValues[] = { 500.f, 501.f }; 1794 const float kValues[] = { 500.f, 501.f };
1795 GPBBoolFloatDictionary *dict = 1795 GPBBoolFloatDictionary *dict =
1796 [[GPBBoolFloatDictionary alloc] initWithValues:kValues 1796 [[GPBBoolFloatDictionary alloc] initWithFloats:kValues
1797 forKeys:kKeys 1797 forKeys:kKeys
1798 count:GPBARRAYSIZE(kValues)]; 1798 count:GPBARRAYSIZE(kValues)];
1799 XCTAssertNotNil(dict); 1799 XCTAssertNotNil(dict);
1800 XCTAssertEqual(dict.count, 2U); 1800 XCTAssertEqual(dict.count, 2U);
1801 float value; 1801 float value;
1802 XCTAssertTrue([dict valueForKey:YES value:NULL]); 1802 XCTAssertTrue([dict getFloat:NULL forKey:YES]);
1803 XCTAssertTrue([dict valueForKey:YES value:&value]); 1803 XCTAssertTrue([dict getFloat:&value forKey:YES]);
1804 XCTAssertEqual(value, 500.f); 1804 XCTAssertEqual(value, 500.f);
1805 XCTAssertTrue([dict valueForKey:NO value:NULL]); 1805 XCTAssertTrue([dict getFloat:NULL forKey:NO]);
1806 XCTAssertTrue([dict valueForKey:NO value:&value]); 1806 XCTAssertTrue([dict getFloat:&value forKey:NO]);
1807 XCTAssertEqual(value, 501.f); 1807 XCTAssertEqual(value, 501.f);
1808 1808
1809 [dict setValue:501.f forKey:YES]; 1809 [dict setFloat:501.f forKey:YES];
1810 XCTAssertEqual(dict.count, 2U); 1810 XCTAssertEqual(dict.count, 2U);
1811 XCTAssertTrue([dict valueForKey:YES value:NULL]); 1811 XCTAssertTrue([dict getFloat:NULL forKey:YES]);
1812 XCTAssertTrue([dict valueForKey:YES value:&value]); 1812 XCTAssertTrue([dict getFloat:&value forKey:YES]);
1813 XCTAssertEqual(value, 501.f); 1813 XCTAssertEqual(value, 501.f);
1814 XCTAssertTrue([dict valueForKey:NO value:NULL]); 1814 XCTAssertTrue([dict getFloat:NULL forKey:NO]);
1815 XCTAssertTrue([dict valueForKey:NO value:&value]); 1815 XCTAssertTrue([dict getFloat:&value forKey:NO]);
1816 XCTAssertEqual(value, 501.f); 1816 XCTAssertEqual(value, 501.f);
1817 1817
1818 [dict setValue:500.f forKey:NO]; 1818 [dict setFloat:500.f forKey:NO];
1819 XCTAssertEqual(dict.count, 2U); 1819 XCTAssertEqual(dict.count, 2U);
1820 XCTAssertTrue([dict valueForKey:YES value:NULL]); 1820 XCTAssertTrue([dict getFloat:NULL forKey:YES]);
1821 XCTAssertTrue([dict valueForKey:YES value:&value]); 1821 XCTAssertTrue([dict getFloat:&value forKey:YES]);
1822 XCTAssertEqual(value, 501.f); 1822 XCTAssertEqual(value, 501.f);
1823 XCTAssertTrue([dict valueForKey:NO value:NULL]); 1823 XCTAssertTrue([dict getFloat:NULL forKey:NO]);
1824 XCTAssertTrue([dict valueForKey:NO value:&value]); 1824 XCTAssertTrue([dict getFloat:&value forKey:NO]);
1825 XCTAssertEqual(value, 500.f); 1825 XCTAssertEqual(value, 500.f);
1826 1826
1827 const BOOL kKeys2[] = { NO, YES }; 1827 const BOOL kKeys2[] = { NO, YES };
1828 const float kValues2[] = { 501.f, 500.f }; 1828 const float kValues2[] = { 501.f, 500.f };
1829 GPBBoolFloatDictionary *dict2 = 1829 GPBBoolFloatDictionary *dict2 =
1830 [[GPBBoolFloatDictionary alloc] initWithValues:kValues2 1830 [[GPBBoolFloatDictionary alloc] initWithFloats:kValues2
1831 forKeys:kKeys2 1831 forKeys:kKeys2
1832 count:GPBARRAYSIZE(kValues2)]; 1832 count:GPBARRAYSIZE(kValues2)];
1833 XCTAssertNotNil(dict2); 1833 XCTAssertNotNil(dict2);
1834 [dict addEntriesFromDictionary:dict2]; 1834 [dict addEntriesFromDictionary:dict2];
1835 XCTAssertEqual(dict.count, 2U); 1835 XCTAssertEqual(dict.count, 2U);
1836 XCTAssertTrue([dict valueForKey:YES value:NULL]); 1836 XCTAssertTrue([dict getFloat:NULL forKey:YES]);
1837 XCTAssertTrue([dict valueForKey:YES value:&value]); 1837 XCTAssertTrue([dict getFloat:&value forKey:YES]);
1838 XCTAssertEqual(value, 500.f); 1838 XCTAssertEqual(value, 500.f);
1839 XCTAssertTrue([dict valueForKey:NO value:NULL]); 1839 XCTAssertTrue([dict getFloat:NULL forKey:NO]);
1840 XCTAssertTrue([dict valueForKey:NO value:&value]); 1840 XCTAssertTrue([dict getFloat:&value forKey:NO]);
1841 XCTAssertEqual(value, 501.f); 1841 XCTAssertEqual(value, 501.f);
1842 1842
1843 [dict2 release]; 1843 [dict2 release];
1844 [dict release]; 1844 [dict release];
1845 } 1845 }
1846 1846
1847 @end 1847 @end
1848 1848
1849 //%PDDM-EXPAND BOOL_TESTS_FOR_POD_VALUE(Double, double, 600., 601.) 1849 //%PDDM-EXPAND BOOL_TESTS_FOR_POD_VALUE(Double, double, 600., 601.)
1850 // This block of code is generated, do not edit it directly. 1850 // This block of code is generated, do not edit it directly.
1851 1851
1852 #pragma mark - Bool -> Double 1852 #pragma mark - Bool -> Double
1853 1853
1854 @interface GPBBoolDoubleDictionaryTests : XCTestCase 1854 @interface GPBBoolDoubleDictionaryTests : XCTestCase
1855 @end 1855 @end
1856 1856
1857 @implementation GPBBoolDoubleDictionaryTests 1857 @implementation GPBBoolDoubleDictionaryTests
1858 1858
1859 - (void)testEmpty { 1859 - (void)testEmpty {
1860 GPBBoolDoubleDictionary *dict = [[GPBBoolDoubleDictionary alloc] init]; 1860 GPBBoolDoubleDictionary *dict = [[GPBBoolDoubleDictionary alloc] init];
1861 XCTAssertNotNil(dict); 1861 XCTAssertNotNil(dict);
1862 XCTAssertEqual(dict.count, 0U); 1862 XCTAssertEqual(dict.count, 0U);
1863 XCTAssertFalse([dict valueForKey:YES value:NULL]); 1863 XCTAssertFalse([dict getDouble:NULL forKey:YES]);
1864 [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, double aValue, BOOL *stop) { 1864 [dict enumerateKeysAndDoublesUsingBlock:^(BOOL aKey, double aValue, BOOL *stop ) {
1865 #pragma unused(aKey, aValue, stop) 1865 #pragma unused(aKey, aValue, stop)
1866 XCTFail(@"Shouldn't get here!"); 1866 XCTFail(@"Shouldn't get here!");
1867 }]; 1867 }];
1868 [dict release]; 1868 [dict release];
1869 } 1869 }
1870 1870
1871 - (void)testOne { 1871 - (void)testOne {
1872 GPBBoolDoubleDictionary *dict = [GPBBoolDoubleDictionary dictionaryWithValue:6 00. forKey:YES]; 1872 GPBBoolDoubleDictionary *dict = [GPBBoolDoubleDictionary dictionaryWithDouble: 600. forKey:YES];
1873 XCTAssertNotNil(dict); 1873 XCTAssertNotNil(dict);
1874 XCTAssertEqual(dict.count, 1U); 1874 XCTAssertEqual(dict.count, 1U);
1875 double value; 1875 double value;
1876 XCTAssertTrue([dict valueForKey:YES value:NULL]); 1876 XCTAssertTrue([dict getDouble:NULL forKey:YES]);
1877 XCTAssertTrue([dict valueForKey:YES value:&value]); 1877 XCTAssertTrue([dict getDouble:&value forKey:YES]);
1878 XCTAssertEqual(value, 600.); 1878 XCTAssertEqual(value, 600.);
1879 XCTAssertFalse([dict valueForKey:NO value:NULL]); 1879 XCTAssertFalse([dict getDouble:NULL forKey:NO]);
1880 [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, double aValue, BOOL *stop) { 1880 [dict enumerateKeysAndDoublesUsingBlock:^(BOOL aKey, double aValue, BOOL *stop ) {
1881 XCTAssertEqual(aKey, YES); 1881 XCTAssertEqual(aKey, YES);
1882 XCTAssertEqual(aValue, 600.); 1882 XCTAssertEqual(aValue, 600.);
1883 XCTAssertNotEqual(stop, NULL); 1883 XCTAssertNotEqual(stop, NULL);
1884 }]; 1884 }];
1885 } 1885 }
1886 1886
1887 - (void)testBasics { 1887 - (void)testBasics {
1888 const BOOL kKeys[] = { YES, NO }; 1888 const BOOL kKeys[] = { YES, NO };
1889 const double kValues[] = { 600., 601. }; 1889 const double kValues[] = { 600., 601. };
1890 GPBBoolDoubleDictionary *dict = 1890 GPBBoolDoubleDictionary *dict =
1891 [[GPBBoolDoubleDictionary alloc] initWithValues:kValues 1891 [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues
1892 forKeys:kKeys 1892 forKeys:kKeys
1893 count:GPBARRAYSIZE(kValues)]; 1893 count:GPBARRAYSIZE(kValues)];
1894 XCTAssertNotNil(dict); 1894 XCTAssertNotNil(dict);
1895 XCTAssertEqual(dict.count, 2U); 1895 XCTAssertEqual(dict.count, 2U);
1896 double value; 1896 double value;
1897 XCTAssertTrue([dict valueForKey:YES value:NULL]); 1897 XCTAssertTrue([dict getDouble:NULL forKey:YES]);
1898 XCTAssertTrue([dict valueForKey:YES value:&value]); 1898 XCTAssertTrue([dict getDouble:&value forKey:YES]);
1899 XCTAssertEqual(value, 600.); 1899 XCTAssertEqual(value, 600.);
1900 XCTAssertTrue([dict valueForKey:NO value:NULL]); 1900 XCTAssertTrue([dict getDouble:NULL forKey:NO]);
1901 XCTAssertTrue([dict valueForKey:NO value:&value]); 1901 XCTAssertTrue([dict getDouble:&value forKey:NO]);
1902 XCTAssertEqual(value, 601.); 1902 XCTAssertEqual(value, 601.);
1903 1903
1904 __block NSUInteger idx = 0; 1904 __block NSUInteger idx = 0;
1905 BOOL *seenKeys = malloc(2 * sizeof(BOOL)); 1905 BOOL *seenKeys = malloc(2 * sizeof(BOOL));
1906 double *seenValues = malloc(2 * sizeof(double)); 1906 double *seenValues = malloc(2 * sizeof(double));
1907 [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, double aValue, BOOL *stop) { 1907 [dict enumerateKeysAndDoublesUsingBlock:^(BOOL aKey, double aValue, BOOL *stop ) {
1908 XCTAssertLessThan(idx, 2U); 1908 XCTAssertLessThan(idx, 2U);
1909 seenKeys[idx] = aKey; 1909 seenKeys[idx] = aKey;
1910 seenValues[idx] = aValue; 1910 seenValues[idx] = aValue;
1911 XCTAssertNotEqual(stop, NULL); 1911 XCTAssertNotEqual(stop, NULL);
1912 ++idx; 1912 ++idx;
1913 }]; 1913 }];
1914 for (int i = 0; i < 2; ++i) { 1914 for (int i = 0; i < 2; ++i) {
1915 BOOL foundKey = NO; 1915 BOOL foundKey = NO;
1916 for (int j = 0; (j < 2) && !foundKey; ++j) { 1916 for (int j = 0; (j < 2) && !foundKey; ++j) {
1917 if (kKeys[i] == seenKeys[j]) { 1917 if (kKeys[i] == seenKeys[j]) {
1918 foundKey = YES; 1918 foundKey = YES;
1919 XCTAssertEqual(kValues[i], seenValues[j], @"i = %d, j = %d", i, j); 1919 XCTAssertEqual(kValues[i], seenValues[j], @"i = %d, j = %d", i, j);
1920 } 1920 }
1921 } 1921 }
1922 XCTAssertTrue(foundKey, @"i = %d", i); 1922 XCTAssertTrue(foundKey, @"i = %d", i);
1923 } 1923 }
1924 free(seenKeys); 1924 free(seenKeys);
1925 free(seenValues); 1925 free(seenValues);
1926 1926
1927 // Stopping the enumeration. 1927 // Stopping the enumeration.
1928 idx = 0; 1928 idx = 0;
1929 [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, double aValue, BOOL *stop) { 1929 [dict enumerateKeysAndDoublesUsingBlock:^(BOOL aKey, double aValue, BOOL *stop ) {
1930 #pragma unused(aKey, aValue) 1930 #pragma unused(aKey, aValue)
1931 if (idx == 0) *stop = YES; 1931 if (idx == 0) *stop = YES;
1932 XCTAssertNotEqual(idx, 2U); 1932 XCTAssertNotEqual(idx, 2U);
1933 ++idx; 1933 ++idx;
1934 }]; 1934 }];
1935 [dict release]; 1935 [dict release];
1936 } 1936 }
1937 1937
1938 - (void)testEquality { 1938 - (void)testEquality {
1939 const BOOL kKeys1[] = { YES, NO }; 1939 const BOOL kKeys1[] = { YES, NO };
1940 const BOOL kKeys2[] = { NO, YES }; 1940 const BOOL kKeys2[] = { NO, YES };
1941 const double kValues1[] = { 600., 601. }; 1941 const double kValues1[] = { 600., 601. };
1942 const double kValues2[] = { 601., 600. }; 1942 const double kValues2[] = { 601., 600. };
1943 const double kValues3[] = { 601. }; 1943 const double kValues3[] = { 601. };
1944 GPBBoolDoubleDictionary *dict1 = 1944 GPBBoolDoubleDictionary *dict1 =
1945 [[GPBBoolDoubleDictionary alloc] initWithValues:kValues1 1945 [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues1
1946 forKeys:kKeys1 1946 forKeys:kKeys1
1947 count:GPBARRAYSIZE(kValues1)]; 1947 count:GPBARRAYSIZE(kValues1)];
1948 XCTAssertNotNil(dict1); 1948 XCTAssertNotNil(dict1);
1949 GPBBoolDoubleDictionary *dict1prime = 1949 GPBBoolDoubleDictionary *dict1prime =
1950 [[GPBBoolDoubleDictionary alloc] initWithValues:kValues1 1950 [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues1
1951 forKeys:kKeys1 1951 forKeys:kKeys1
1952 count:GPBARRAYSIZE(kValues1)]; 1952 count:GPBARRAYSIZE(kValues1)];
1953 XCTAssertNotNil(dict1prime); 1953 XCTAssertNotNil(dict1prime);
1954 GPBBoolDoubleDictionary *dict2 = 1954 GPBBoolDoubleDictionary *dict2 =
1955 [[GPBBoolDoubleDictionary alloc] initWithValues:kValues2 1955 [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues2
1956 forKeys:kKeys1 1956 forKeys:kKeys1
1957 count:GPBARRAYSIZE(kValues2)]; 1957 count:GPBARRAYSIZE(kValues2)];
1958 XCTAssertNotNil(dict2); 1958 XCTAssertNotNil(dict2);
1959 GPBBoolDoubleDictionary *dict3 = 1959 GPBBoolDoubleDictionary *dict3 =
1960 [[GPBBoolDoubleDictionary alloc] initWithValues:kValues1 1960 [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues1
1961 forKeys:kKeys2 1961 forKeys:kKeys2
1962 count:GPBARRAYSIZE(kValues1)]; 1962 count:GPBARRAYSIZE(kValues1)];
1963 XCTAssertNotNil(dict3); 1963 XCTAssertNotNil(dict3);
1964 GPBBoolDoubleDictionary *dict4 = 1964 GPBBoolDoubleDictionary *dict4 =
1965 [[GPBBoolDoubleDictionary alloc] initWithValues:kValues3 1965 [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues3
1966 forKeys:kKeys1 1966 forKeys:kKeys1
1967 count:GPBARRAYSIZE(kValues3)]; 1967 count:GPBARRAYSIZE(kValues3)];
1968 XCTAssertNotNil(dict4); 1968 XCTAssertNotNil(dict4);
1969 1969
1970 // 1/1Prime should be different objects, but equal. 1970 // 1/1Prime should be different objects, but equal.
1971 XCTAssertNotEqual(dict1, dict1prime); 1971 XCTAssertNotEqual(dict1, dict1prime);
1972 XCTAssertEqualObjects(dict1, dict1prime); 1972 XCTAssertEqualObjects(dict1, dict1prime);
1973 // Equal, so they must have same hash. 1973 // Equal, so they must have same hash.
1974 XCTAssertEqual([dict1 hash], [dict1prime hash]); 1974 XCTAssertEqual([dict1 hash], [dict1prime hash]);
1975 1975
1976 // 2 is same keys, different values; not equal. 1976 // 2 is same keys, different values; not equal.
1977 XCTAssertNotEqualObjects(dict1, dict2); 1977 XCTAssertNotEqualObjects(dict1, dict2);
1978 1978
1979 // 3 is different keys, same values; not equal. 1979 // 3 is different keys, same values; not equal.
1980 XCTAssertNotEqualObjects(dict1, dict3); 1980 XCTAssertNotEqualObjects(dict1, dict3);
1981 1981
1982 // 4 Fewer pairs; not equal 1982 // 4 Fewer pairs; not equal
1983 XCTAssertNotEqualObjects(dict1, dict4); 1983 XCTAssertNotEqualObjects(dict1, dict4);
1984 1984
1985 [dict1 release]; 1985 [dict1 release];
1986 [dict1prime release]; 1986 [dict1prime release];
1987 [dict2 release]; 1987 [dict2 release];
1988 [dict3 release]; 1988 [dict3 release];
1989 [dict4 release]; 1989 [dict4 release];
1990 } 1990 }
1991 1991
1992 - (void)testCopy { 1992 - (void)testCopy {
1993 const BOOL kKeys[] = { YES, NO }; 1993 const BOOL kKeys[] = { YES, NO };
1994 const double kValues[] = { 600., 601. }; 1994 const double kValues[] = { 600., 601. };
1995 GPBBoolDoubleDictionary *dict = 1995 GPBBoolDoubleDictionary *dict =
1996 [[GPBBoolDoubleDictionary alloc] initWithValues:kValues 1996 [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues
1997 forKeys:kKeys 1997 forKeys:kKeys
1998 count:GPBARRAYSIZE(kValues)]; 1998 count:GPBARRAYSIZE(kValues)];
1999 XCTAssertNotNil(dict); 1999 XCTAssertNotNil(dict);
2000 2000
2001 GPBBoolDoubleDictionary *dict2 = [dict copy]; 2001 GPBBoolDoubleDictionary *dict2 = [dict copy];
2002 XCTAssertNotNil(dict2); 2002 XCTAssertNotNil(dict2);
2003 2003
2004 // Should be new object but equal. 2004 // Should be new object but equal.
2005 XCTAssertNotEqual(dict, dict2); 2005 XCTAssertNotEqual(dict, dict2);
2006 XCTAssertEqualObjects(dict, dict2); 2006 XCTAssertEqualObjects(dict, dict2);
2007 XCTAssertTrue([dict2 isKindOfClass:[GPBBoolDoubleDictionary class]]); 2007 XCTAssertTrue([dict2 isKindOfClass:[GPBBoolDoubleDictionary class]]);
2008 2008
2009 [dict2 release]; 2009 [dict2 release];
2010 [dict release]; 2010 [dict release];
2011 } 2011 }
2012 2012
2013 - (void)testDictionaryFromDictionary { 2013 - (void)testDictionaryFromDictionary {
2014 const BOOL kKeys[] = { YES, NO }; 2014 const BOOL kKeys[] = { YES, NO };
2015 const double kValues[] = { 600., 601. }; 2015 const double kValues[] = { 600., 601. };
2016 GPBBoolDoubleDictionary *dict = 2016 GPBBoolDoubleDictionary *dict =
2017 [[GPBBoolDoubleDictionary alloc] initWithValues:kValues 2017 [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues
2018 forKeys:kKeys 2018 forKeys:kKeys
2019 count:GPBARRAYSIZE(kValues)]; 2019 count:GPBARRAYSIZE(kValues)];
2020 XCTAssertNotNil(dict); 2020 XCTAssertNotNil(dict);
2021 2021
2022 GPBBoolDoubleDictionary *dict2 = 2022 GPBBoolDoubleDictionary *dict2 =
2023 [GPBBoolDoubleDictionary dictionaryWithDictionary:dict]; 2023 [GPBBoolDoubleDictionary dictionaryWithDictionary:dict];
2024 XCTAssertNotNil(dict2); 2024 XCTAssertNotNil(dict2);
2025 2025
2026 // Should be new pointer, but equal objects. 2026 // Should be new pointer, but equal objects.
2027 XCTAssertNotEqual(dict, dict2); 2027 XCTAssertNotEqual(dict, dict2);
2028 XCTAssertEqualObjects(dict, dict2); 2028 XCTAssertEqualObjects(dict, dict2);
2029 [dict release]; 2029 [dict release];
2030 } 2030 }
2031 2031
2032 - (void)testAdds { 2032 - (void)testAdds {
2033 GPBBoolDoubleDictionary *dict = [GPBBoolDoubleDictionary dictionary]; 2033 GPBBoolDoubleDictionary *dict = [GPBBoolDoubleDictionary dictionary];
2034 XCTAssertNotNil(dict); 2034 XCTAssertNotNil(dict);
2035 2035
2036 XCTAssertEqual(dict.count, 0U); 2036 XCTAssertEqual(dict.count, 0U);
2037 [dict setValue:600. forKey:YES]; 2037 [dict setDouble:600. forKey:YES];
2038 XCTAssertEqual(dict.count, 1U); 2038 XCTAssertEqual(dict.count, 1U);
2039 2039
2040 const BOOL kKeys[] = { NO }; 2040 const BOOL kKeys[] = { NO };
2041 const double kValues[] = { 601. }; 2041 const double kValues[] = { 601. };
2042 GPBBoolDoubleDictionary *dict2 = 2042 GPBBoolDoubleDictionary *dict2 =
2043 [[GPBBoolDoubleDictionary alloc] initWithValues:kValues 2043 [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues
2044 forKeys:kKeys 2044 forKeys:kKeys
2045 count:GPBARRAYSIZE(kValues)]; 2045 count:GPBARRAYSIZE(kValues)];
2046 XCTAssertNotNil(dict2); 2046 XCTAssertNotNil(dict2);
2047 [dict addEntriesFromDictionary:dict2]; 2047 [dict addEntriesFromDictionary:dict2];
2048 XCTAssertEqual(dict.count, 2U); 2048 XCTAssertEqual(dict.count, 2U);
2049 2049
2050 double value; 2050 double value;
2051 XCTAssertTrue([dict valueForKey:YES value:NULL]); 2051 XCTAssertTrue([dict getDouble:NULL forKey:YES]);
2052 XCTAssertTrue([dict valueForKey:YES value:&value]); 2052 XCTAssertTrue([dict getDouble:&value forKey:YES]);
2053 XCTAssertEqual(value, 600.); 2053 XCTAssertEqual(value, 600.);
2054 XCTAssertTrue([dict valueForKey:NO value:NULL]); 2054 XCTAssertTrue([dict getDouble:NULL forKey:NO]);
2055 XCTAssertTrue([dict valueForKey:NO value:&value]); 2055 XCTAssertTrue([dict getDouble:&value forKey:NO]);
2056 XCTAssertEqual(value, 601.); 2056 XCTAssertEqual(value, 601.);
2057 [dict2 release]; 2057 [dict2 release];
2058 } 2058 }
2059 2059
2060 - (void)testRemove { 2060 - (void)testRemove {
2061 const BOOL kKeys[] = { YES, NO}; 2061 const BOOL kKeys[] = { YES, NO};
2062 const double kValues[] = { 600., 601. }; 2062 const double kValues[] = { 600., 601. };
2063 GPBBoolDoubleDictionary *dict = 2063 GPBBoolDoubleDictionary *dict =
2064 [[GPBBoolDoubleDictionary alloc] initWithValues:kValues 2064 [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues
2065 forKeys:kKeys 2065 forKeys:kKeys
2066 count:GPBARRAYSIZE(kValues)]; 2066 count:GPBARRAYSIZE(kValues)];
2067 XCTAssertNotNil(dict); 2067 XCTAssertNotNil(dict);
2068 XCTAssertEqual(dict.count, 2U); 2068 XCTAssertEqual(dict.count, 2U);
2069 2069
2070 [dict removeValueForKey:NO]; 2070 [dict removeDoubleForKey:NO];
2071 XCTAssertEqual(dict.count, 1U); 2071 XCTAssertEqual(dict.count, 1U);
2072 double value; 2072 double value;
2073 XCTAssertTrue([dict valueForKey:YES value:NULL]); 2073 XCTAssertTrue([dict getDouble:NULL forKey:YES]);
2074 XCTAssertTrue([dict valueForKey:YES value:&value]); 2074 XCTAssertTrue([dict getDouble:&value forKey:YES]);
2075 XCTAssertEqual(value, 600.); 2075 XCTAssertEqual(value, 600.);
2076 XCTAssertFalse([dict valueForKey:NO value:NULL]); 2076 XCTAssertFalse([dict getDouble:NULL forKey:NO]);
2077 2077
2078 // Remove again does nothing. 2078 // Remove again does nothing.
2079 [dict removeValueForKey:NO]; 2079 [dict removeDoubleForKey:NO];
2080 XCTAssertEqual(dict.count, 1U); 2080 XCTAssertEqual(dict.count, 1U);
2081 XCTAssertTrue([dict valueForKey:YES value:NULL]); 2081 XCTAssertTrue([dict getDouble:NULL forKey:YES]);
2082 XCTAssertTrue([dict valueForKey:YES value:&value]); 2082 XCTAssertTrue([dict getDouble:&value forKey:YES]);
2083 XCTAssertEqual(value, 600.); 2083 XCTAssertEqual(value, 600.);
2084 XCTAssertFalse([dict valueForKey:NO value:NULL]); 2084 XCTAssertFalse([dict getDouble:NULL forKey:NO]);
2085 2085
2086 [dict removeAll]; 2086 [dict removeAll];
2087 XCTAssertEqual(dict.count, 0U); 2087 XCTAssertEqual(dict.count, 0U);
2088 XCTAssertFalse([dict valueForKey:YES value:NULL]); 2088 XCTAssertFalse([dict getDouble:NULL forKey:YES]);
2089 XCTAssertFalse([dict valueForKey:NO value:NULL]); 2089 XCTAssertFalse([dict getDouble:NULL forKey:NO]);
2090 [dict release]; 2090 [dict release];
2091 } 2091 }
2092 2092
2093 - (void)testInplaceMutation { 2093 - (void)testInplaceMutation {
2094 const BOOL kKeys[] = { YES, NO }; 2094 const BOOL kKeys[] = { YES, NO };
2095 const double kValues[] = { 600., 601. }; 2095 const double kValues[] = { 600., 601. };
2096 GPBBoolDoubleDictionary *dict = 2096 GPBBoolDoubleDictionary *dict =
2097 [[GPBBoolDoubleDictionary alloc] initWithValues:kValues 2097 [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues
2098 forKeys:kKeys 2098 forKeys:kKeys
2099 count:GPBARRAYSIZE(kValues)]; 2099 count:GPBARRAYSIZE(kValues)];
2100 XCTAssertNotNil(dict); 2100 XCTAssertNotNil(dict);
2101 XCTAssertEqual(dict.count, 2U); 2101 XCTAssertEqual(dict.count, 2U);
2102 double value; 2102 double value;
2103 XCTAssertTrue([dict valueForKey:YES value:NULL]); 2103 XCTAssertTrue([dict getDouble:NULL forKey:YES]);
2104 XCTAssertTrue([dict valueForKey:YES value:&value]); 2104 XCTAssertTrue([dict getDouble:&value forKey:YES]);
2105 XCTAssertEqual(value, 600.); 2105 XCTAssertEqual(value, 600.);
2106 XCTAssertTrue([dict valueForKey:NO value:NULL]); 2106 XCTAssertTrue([dict getDouble:NULL forKey:NO]);
2107 XCTAssertTrue([dict valueForKey:NO value:&value]); 2107 XCTAssertTrue([dict getDouble:&value forKey:NO]);
2108 XCTAssertEqual(value, 601.); 2108 XCTAssertEqual(value, 601.);
2109 2109
2110 [dict setValue:601. forKey:YES]; 2110 [dict setDouble:601. forKey:YES];
2111 XCTAssertEqual(dict.count, 2U); 2111 XCTAssertEqual(dict.count, 2U);
2112 XCTAssertTrue([dict valueForKey:YES value:NULL]); 2112 XCTAssertTrue([dict getDouble:NULL forKey:YES]);
2113 XCTAssertTrue([dict valueForKey:YES value:&value]); 2113 XCTAssertTrue([dict getDouble:&value forKey:YES]);
2114 XCTAssertEqual(value, 601.); 2114 XCTAssertEqual(value, 601.);
2115 XCTAssertTrue([dict valueForKey:NO value:NULL]); 2115 XCTAssertTrue([dict getDouble:NULL forKey:NO]);
2116 XCTAssertTrue([dict valueForKey:NO value:&value]); 2116 XCTAssertTrue([dict getDouble:&value forKey:NO]);
2117 XCTAssertEqual(value, 601.); 2117 XCTAssertEqual(value, 601.);
2118 2118
2119 [dict setValue:600. forKey:NO]; 2119 [dict setDouble:600. forKey:NO];
2120 XCTAssertEqual(dict.count, 2U); 2120 XCTAssertEqual(dict.count, 2U);
2121 XCTAssertTrue([dict valueForKey:YES value:NULL]); 2121 XCTAssertTrue([dict getDouble:NULL forKey:YES]);
2122 XCTAssertTrue([dict valueForKey:YES value:&value]); 2122 XCTAssertTrue([dict getDouble:&value forKey:YES]);
2123 XCTAssertEqual(value, 601.); 2123 XCTAssertEqual(value, 601.);
2124 XCTAssertTrue([dict valueForKey:NO value:NULL]); 2124 XCTAssertTrue([dict getDouble:NULL forKey:NO]);
2125 XCTAssertTrue([dict valueForKey:NO value:&value]); 2125 XCTAssertTrue([dict getDouble:&value forKey:NO]);
2126 XCTAssertEqual(value, 600.); 2126 XCTAssertEqual(value, 600.);
2127 2127
2128 const BOOL kKeys2[] = { NO, YES }; 2128 const BOOL kKeys2[] = { NO, YES };
2129 const double kValues2[] = { 601., 600. }; 2129 const double kValues2[] = { 601., 600. };
2130 GPBBoolDoubleDictionary *dict2 = 2130 GPBBoolDoubleDictionary *dict2 =
2131 [[GPBBoolDoubleDictionary alloc] initWithValues:kValues2 2131 [[GPBBoolDoubleDictionary alloc] initWithDoubles:kValues2
2132 forKeys:kKeys2 2132 forKeys:kKeys2
2133 count:GPBARRAYSIZE(kValues2)]; 2133 count:GPBARRAYSIZE(kValues2)];
2134 XCTAssertNotNil(dict2); 2134 XCTAssertNotNil(dict2);
2135 [dict addEntriesFromDictionary:dict2]; 2135 [dict addEntriesFromDictionary:dict2];
2136 XCTAssertEqual(dict.count, 2U); 2136 XCTAssertEqual(dict.count, 2U);
2137 XCTAssertTrue([dict valueForKey:YES value:NULL]); 2137 XCTAssertTrue([dict getDouble:NULL forKey:YES]);
2138 XCTAssertTrue([dict valueForKey:YES value:&value]); 2138 XCTAssertTrue([dict getDouble:&value forKey:YES]);
2139 XCTAssertEqual(value, 600.); 2139 XCTAssertEqual(value, 600.);
2140 XCTAssertTrue([dict valueForKey:NO value:NULL]); 2140 XCTAssertTrue([dict getDouble:NULL forKey:NO]);
2141 XCTAssertTrue([dict valueForKey:NO value:&value]); 2141 XCTAssertTrue([dict getDouble:&value forKey:NO]);
2142 XCTAssertEqual(value, 601.); 2142 XCTAssertEqual(value, 601.);
2143 2143
2144 [dict2 release]; 2144 [dict2 release];
2145 [dict release]; 2145 [dict release];
2146 } 2146 }
2147 2147
2148 @end 2148 @end
2149 2149
2150 //%PDDM-EXPAND TESTS_FOR_BOOL_KEY_OBJECT_VALUE(Object, NSString*, @"abc", @"def" ) 2150 //%PDDM-EXPAND TESTS_FOR_BOOL_KEY_OBJECT_VALUE(Object, NSString*, @"abc", @"def" )
2151 // This block of code is generated, do not edit it directly. 2151 // This block of code is generated, do not edit it directly.
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
2371 XCTAssertNil([dict objectForKey:YES]); 2371 XCTAssertNil([dict objectForKey:YES]);
2372 XCTAssertNil([dict objectForKey:NO]); 2372 XCTAssertNil([dict objectForKey:NO]);
2373 [dict release]; 2373 [dict release];
2374 } 2374 }
2375 2375
2376 - (void)testInplaceMutation { 2376 - (void)testInplaceMutation {
2377 const BOOL kKeys[] = { YES, NO }; 2377 const BOOL kKeys[] = { YES, NO };
2378 const NSString* kObjects[] = { @"abc", @"def" }; 2378 const NSString* kObjects[] = { @"abc", @"def" };
2379 GPBBoolObjectDictionary<NSString*> *dict = 2379 GPBBoolObjectDictionary<NSString*> *dict =
2380 [[GPBBoolObjectDictionary alloc] initWithObjects:kObjects 2380 [[GPBBoolObjectDictionary alloc] initWithObjects:kObjects
2381 forKeys:kKeys 2381 forKeys:kKeys
2382 count:GPBARRAYSIZE(kObjects)]; 2382 count:GPBARRAYSIZE(kObjects)];
2383 XCTAssertNotNil(dict); 2383 XCTAssertNotNil(dict);
2384 XCTAssertEqual(dict.count, 2U); 2384 XCTAssertEqual(dict.count, 2U);
2385 XCTAssertEqualObjects([dict objectForKey:YES], @"abc"); 2385 XCTAssertEqualObjects([dict objectForKey:YES], @"abc");
2386 XCTAssertEqualObjects([dict objectForKey:NO], @"def"); 2386 XCTAssertEqualObjects([dict objectForKey:NO], @"def");
2387 2387
2388 [dict setObject:@"def" forKey:YES]; 2388 [dict setObject:@"def" forKey:YES];
2389 XCTAssertEqual(dict.count, 2U); 2389 XCTAssertEqual(dict.count, 2U);
2390 XCTAssertEqualObjects([dict objectForKey:YES], @"def"); 2390 XCTAssertEqualObjects([dict objectForKey:YES], @"def");
2391 XCTAssertEqualObjects([dict objectForKey:NO], @"def"); 2391 XCTAssertEqualObjects([dict objectForKey:NO], @"def");
2392 2392
(...skipping 16 matching lines...) Expand all
2409 2409
2410 [dict2 release]; 2410 [dict2 release];
2411 [dict release]; 2411 [dict release];
2412 } 2412 }
2413 2413
2414 @end 2414 @end
2415 2415
2416 //%PDDM-EXPAND-END (8 expansions) 2416 //%PDDM-EXPAND-END (8 expansions)
2417 2417
2418 2418
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698