1 #include <ATen/core/Dict.h>
2 #include <ATen/ATen.h>
3 #include <gtest/gtest.h>
4 #include <gmock/gmock.h>
5 #include <string>
6
7 using std::string;
8 using c10::Dict;
9
10 #define ASSERT_EQUAL(t1, t2) ASSERT_TRUE(t1.equal(t2));
11
TEST(DictTest,givenEmptyDict_whenCallingEmpty_thenReturnsTrue)12 TEST(DictTest, givenEmptyDict_whenCallingEmpty_thenReturnsTrue) {
13 Dict<int64_t, string> dict;
14 EXPECT_TRUE(dict.empty());
15 }
16
TEST(DictTest,givenNonemptyDict_whenCallingEmpty_thenReturnsFalse)17 TEST(DictTest, givenNonemptyDict_whenCallingEmpty_thenReturnsFalse) {
18 Dict<int64_t, string> dict;
19 dict.insert(3, "value");
20 EXPECT_FALSE(dict.empty());
21 }
22
TEST(DictTest,givenEmptyDict_whenCallingSize_thenReturnsZero)23 TEST(DictTest, givenEmptyDict_whenCallingSize_thenReturnsZero) {
24 Dict<int64_t, string> dict;
25 EXPECT_EQ(0, dict.size());
26 }
27
TEST(DictTest,givenNonemptyDict_whenCallingSize_thenReturnsNumberOfElements)28 TEST(DictTest, givenNonemptyDict_whenCallingSize_thenReturnsNumberOfElements) {
29 Dict<int64_t, string> dict;
30 dict.insert(3, "value");
31 dict.insert(4, "value2");
32 EXPECT_EQ(2, dict.size());
33 }
34
TEST(DictTest,givenNonemptyDict_whenCallingClear_thenIsEmpty)35 TEST(DictTest, givenNonemptyDict_whenCallingClear_thenIsEmpty) {
36 Dict<int64_t, string> dict;
37 dict.insert(3, "value");
38 dict.insert(4, "value2");
39 dict.clear();
40 EXPECT_TRUE(dict.empty());
41 }
42
TEST(DictTest,whenInsertingNewKey_thenReturnsTrueAndIteratorToNewElement)43 TEST(DictTest, whenInsertingNewKey_thenReturnsTrueAndIteratorToNewElement) {
44 Dict<int64_t, string> dict;
45 std::pair<Dict<int64_t, string>::iterator, bool> result = dict.insert(3, "value");
46 EXPECT_TRUE(result.second);
47 EXPECT_EQ(3, result.first->key());
48 EXPECT_EQ("value", result.first->value());
49 }
50
TEST(DictTest,whenInsertingExistingKey_thenReturnsFalseAndIteratorToExistingElement)51 TEST(DictTest, whenInsertingExistingKey_thenReturnsFalseAndIteratorToExistingElement) {
52 Dict<int64_t, string> dict;
53 dict.insert(3, "old_value");
54 std::pair<Dict<int64_t, string>::iterator, bool> result = dict.insert(3, "new_value");
55 EXPECT_FALSE(result.second);
56 EXPECT_EQ(3, result.first->key());
57 EXPECT_EQ("old_value", result.first->value());
58 }
59
TEST(DictTest,whenInsertingExistingKey_thenDoesNotModifyDict)60 TEST(DictTest, whenInsertingExistingKey_thenDoesNotModifyDict) {
61 Dict<int64_t, string> dict;
62 dict.insert(3, "old_value");
63 dict.insert(3, "new_value");
64 EXPECT_EQ(1, dict.size());
65 EXPECT_EQ(3, dict.begin()->key());
66 EXPECT_EQ("old_value", dict.begin()->value());
67 }
68
TEST(DictTest,whenInsertOrAssigningNewKey_thenReturnsTrueAndIteratorToNewElement)69 TEST(DictTest, whenInsertOrAssigningNewKey_thenReturnsTrueAndIteratorToNewElement) {
70 Dict<int64_t, string> dict;
71 std::pair<Dict<int64_t, string>::iterator, bool> result = dict.insert_or_assign(3, "value");
72 EXPECT_TRUE(result.second);
73 EXPECT_EQ(3, result.first->key());
74 EXPECT_EQ("value", result.first->value());
75 }
76
TEST(DictTest,whenInsertOrAssigningExistingKey_thenReturnsFalseAndIteratorToChangedElement)77 TEST(DictTest, whenInsertOrAssigningExistingKey_thenReturnsFalseAndIteratorToChangedElement) {
78 Dict<int64_t, string> dict;
79 dict.insert(3, "old_value");
80 std::pair<Dict<int64_t, string>::iterator, bool> result = dict.insert_or_assign(3, "new_value");
81 EXPECT_FALSE(result.second);
82 EXPECT_EQ(3, result.first->key());
83 EXPECT_EQ("new_value", result.first->value());
84 }
85
TEST(DictTest,whenInsertOrAssigningExistingKey_thenDoesModifyDict)86 TEST(DictTest, whenInsertOrAssigningExistingKey_thenDoesModifyDict) {
87 Dict<int64_t, string> dict;
88 dict.insert(3, "old_value");
89 dict.insert_or_assign(3, "new_value");
90 EXPECT_EQ(1, dict.size());
91 EXPECT_EQ(3, dict.begin()->key());
92 EXPECT_EQ("new_value", dict.begin()->value());
93 }
94
TEST(DictTest,givenEmptyDict_whenIterating_thenBeginIsEnd)95 TEST(DictTest, givenEmptyDict_whenIterating_thenBeginIsEnd) {
96 Dict<int64_t, string> dict;
97 EXPECT_EQ(dict.begin(), dict.end());
98 }
99
TEST(DictTest,givenMutableDict_whenIterating_thenFindsElements)100 TEST(DictTest, givenMutableDict_whenIterating_thenFindsElements) {
101 Dict<int64_t, string> dict;
102 dict.insert(3, "3");
103 dict.insert(5, "5");
104 bool found_first = false;
105 bool found_second = false;
106 for (Dict<int64_t, string>::iterator iter = dict.begin(); iter != dict.end(); ++iter) {
107 if (iter->key() == 3) {
108 EXPECT_EQ("3", iter->value());
109 EXPECT_FALSE(found_first);
110 found_first = true;
111 } else if (iter->key() == 5) {
112 EXPECT_EQ("5", iter->value());
113 EXPECT_FALSE(found_second);
114 found_second = true;
115 } else {
116 ADD_FAILURE();
117 }
118 }
119 EXPECT_TRUE(found_first);
120 EXPECT_TRUE(found_second);
121 }
122
TEST(DictTest,givenMutableDict_whenIteratingWithForeach_thenFindsElements)123 TEST(DictTest, givenMutableDict_whenIteratingWithForeach_thenFindsElements) {
124 Dict<int64_t, string> dict;
125 dict.insert(3, "3");
126 dict.insert(5, "5");
127 bool found_first = false;
128 bool found_second = false;
129 for (const auto& elem : dict) {
130 if (elem.key() == 3) {
131 EXPECT_EQ("3", elem.value());
132 EXPECT_FALSE(found_first);
133 found_first = true;
134 } else if (elem.key() == 5) {
135 EXPECT_EQ("5", elem.value());
136 EXPECT_FALSE(found_second);
137 found_second = true;
138 } else {
139 ADD_FAILURE();
140 }
141 }
142 EXPECT_TRUE(found_first);
143 EXPECT_TRUE(found_second);
144 }
145
TEST(DictTest,givenConstDict_whenIterating_thenFindsElements)146 TEST(DictTest, givenConstDict_whenIterating_thenFindsElements) {
147 Dict<int64_t, string> dict_;
148 dict_.insert(3, "3");
149 dict_.insert(5, "5");
150 const Dict<int64_t, string>& dict = dict_;
151 bool found_first = false;
152 bool found_second = false;
153 for (Dict<int64_t, string>::iterator iter = dict.begin(); iter != dict.end(); ++iter) {
154 if (iter->key() == 3) {
155 EXPECT_EQ("3", iter->value());
156 EXPECT_FALSE(found_first);
157 found_first = true;
158 } else if (iter->key() == 5) {
159 EXPECT_EQ("5", iter->value());
160 EXPECT_FALSE(found_second);
161 found_second = true;
162 } else {
163 ADD_FAILURE();
164 }
165 }
166 EXPECT_TRUE(found_first);
167 EXPECT_TRUE(found_second);
168 }
169
TEST(DictTest,givenConstDict_whenIteratingWithForeach_thenFindsElements)170 TEST(DictTest, givenConstDict_whenIteratingWithForeach_thenFindsElements) {
171 Dict<int64_t, string> dict_;
172 dict_.insert(3, "3");
173 dict_.insert(5, "5");
174 const Dict<int64_t, string>& dict = dict_;
175 bool found_first = false;
176 bool found_second = false;
177 for (const auto& elem : dict) {
178 if (elem.key() == 3) {
179 EXPECT_EQ("3", elem.value());
180 EXPECT_FALSE(found_first);
181 found_first = true;
182 } else if (elem.key() == 5) {
183 EXPECT_EQ("5", elem.value());
184 EXPECT_FALSE(found_second);
185 found_second = true;
186 } else {
187 ADD_FAILURE();
188 }
189 }
190 EXPECT_TRUE(found_first);
191 EXPECT_TRUE(found_second);
192 }
193
TEST(DictTest,givenIterator_thenCanModifyValue)194 TEST(DictTest, givenIterator_thenCanModifyValue) {
195 Dict<int64_t, string> dict;
196 dict.insert(3, "old_value");
197 dict.begin()->setValue("new_value");
198 EXPECT_EQ("new_value", dict.begin()->value());
199 }
200
TEST(DictTest,givenOneElementDict_whenErasingByIterator_thenDictIsEmpty)201 TEST(DictTest, givenOneElementDict_whenErasingByIterator_thenDictIsEmpty) {
202 Dict<int64_t, string> dict;
203 dict.insert(3, "3");
204 dict.erase(dict.begin());
205 EXPECT_TRUE(dict.empty());
206 }
207
TEST(DictTest,givenOneElementDict_whenErasingByKey_thenReturnsOneAndDictIsEmpty)208 TEST(DictTest, givenOneElementDict_whenErasingByKey_thenReturnsOneAndDictIsEmpty) {
209 Dict<int64_t, string> dict;
210 dict.insert(3, "3");
211 bool result = dict.erase(3);
212 EXPECT_EQ(1, result);
213 EXPECT_TRUE(dict.empty());
214 }
215
TEST(DictTest,givenOneElementDict_whenErasingByNonexistingKey_thenReturnsZeroAndDictIsUnchanged)216 TEST(DictTest, givenOneElementDict_whenErasingByNonexistingKey_thenReturnsZeroAndDictIsUnchanged) {
217 Dict<int64_t, string> dict;
218 dict.insert(3, "3");
219 bool result = dict.erase(4);
220 EXPECT_EQ(0, result);
221 EXPECT_EQ(1, dict.size());
222 }
223
TEST(DictTest,whenCallingAtWithExistingKey_thenReturnsCorrectElement)224 TEST(DictTest, whenCallingAtWithExistingKey_thenReturnsCorrectElement) {
225 Dict<int64_t, string> dict;
226 dict.insert(3, "3");
227 dict.insert(4, "4");
228 EXPECT_EQ("4", dict.at(4));
229 }
230
TEST(DictTest,whenCallingAtWithNonExistingKey_thenReturnsCorrectElement)231 TEST(DictTest, whenCallingAtWithNonExistingKey_thenReturnsCorrectElement) {
232 Dict<int64_t, string> dict;
233 dict.insert(3, "3");
234 dict.insert(4, "4");
235 // NOLINTNEXTLINE(cppcoreguidelines-avoid-goto,hicpp-avoid-goto)
236 EXPECT_THROW(dict.at(5), std::out_of_range);
237 }
238
TEST(DictTest,givenMutableDict_whenCallingFindOnExistingKey_thenFindsCorrectElement)239 TEST(DictTest, givenMutableDict_whenCallingFindOnExistingKey_thenFindsCorrectElement) {
240 Dict<int64_t, string> dict;
241 dict.insert(3, "3");
242 dict.insert(4, "4");
243 Dict<int64_t, string>::iterator found = dict.find(3);
244 EXPECT_EQ(3, found->key());
245 EXPECT_EQ("3", found->value());
246 }
247
TEST(DictTest,givenMutableDict_whenCallingFindOnNonExistingKey_thenReturnsEnd)248 TEST(DictTest, givenMutableDict_whenCallingFindOnNonExistingKey_thenReturnsEnd) {
249 Dict<int64_t, string> dict;
250 dict.insert(3, "3");
251 dict.insert(4, "4");
252 Dict<int64_t, string>::iterator found = dict.find(5);
253 EXPECT_EQ(dict.end(), found);
254 }
255
TEST(DictTest,givenConstDict_whenCallingFindOnExistingKey_thenFindsCorrectElement)256 TEST(DictTest, givenConstDict_whenCallingFindOnExistingKey_thenFindsCorrectElement) {
257 Dict<int64_t, string> dict_;
258 dict_.insert(3, "3");
259 dict_.insert(4, "4");
260 const Dict<int64_t, string>& dict = dict_;
261 Dict<int64_t, string>::iterator found = dict.find(3);
262 EXPECT_EQ(3, found->key());
263 EXPECT_EQ("3", found->value());
264 }
265
TEST(DictTest,givenConstDict_whenCallingFindOnNonExistingKey_thenReturnsEnd)266 TEST(DictTest, givenConstDict_whenCallingFindOnNonExistingKey_thenReturnsEnd) {
267 Dict<int64_t, string> dict_;
268 dict_.insert(3, "3");
269 dict_.insert(4, "4");
270 const Dict<int64_t, string>& dict = dict_;
271 Dict<int64_t, string>::iterator found = dict.find(5);
272 EXPECT_EQ(dict.end(), found);
273 }
274
TEST(DictTest,whenCallingContainsWithExistingKey_thenReturnsTrue)275 TEST(DictTest, whenCallingContainsWithExistingKey_thenReturnsTrue) {
276 Dict<int64_t, string> dict;
277 dict.insert(3, "3");
278 dict.insert(4, "4");
279 EXPECT_TRUE(dict.contains(3));
280 }
281
TEST(DictTest,whenCallingContainsWithNonExistingKey_thenReturnsFalse)282 TEST(DictTest, whenCallingContainsWithNonExistingKey_thenReturnsFalse) {
283 Dict<int64_t, string> dict;
284 dict.insert(3, "3");
285 dict.insert(4, "4");
286 EXPECT_FALSE(dict.contains(5));
287 }
288
TEST(DictTest,whenCallingReserve_thenDoesntCrash)289 TEST(DictTest, whenCallingReserve_thenDoesntCrash) {
290 Dict<int64_t, string> dict;
291 dict.reserve(100);
292 }
293
TEST(DictTest,whenCopyConstructingDict_thenAreEqual)294 TEST(DictTest, whenCopyConstructingDict_thenAreEqual) {
295 Dict<int64_t, string> dict1;
296 dict1.insert(3, "3");
297 dict1.insert(4, "4");
298
299 // NOLINTNEXTLINE(performance-unnecessary-copy-initialization)
300 Dict<int64_t, string> dict2(dict1);
301
302 EXPECT_EQ(2, dict2.size());
303 EXPECT_EQ("3", dict2.at(3));
304 EXPECT_EQ("4", dict2.at(4));
305 }
306
TEST(DictTest,whenCopyAssigningDict_thenAreEqual)307 TEST(DictTest, whenCopyAssigningDict_thenAreEqual) {
308 Dict<int64_t, string> dict1;
309 dict1.insert(3, "3");
310 dict1.insert(4, "4");
311
312 Dict<int64_t, string> dict2;
313 dict2 = dict1;
314
315 EXPECT_EQ(2, dict2.size());
316 EXPECT_EQ("3", dict2.at(3));
317 EXPECT_EQ("4", dict2.at(4));
318 }
319
TEST(DictTest,whenCopyingDict_thenAreEqual)320 TEST(DictTest, whenCopyingDict_thenAreEqual) {
321 Dict<int64_t, string> dict1;
322 dict1.insert(3, "3");
323 dict1.insert(4, "4");
324
325 Dict<int64_t, string> dict2 = dict1.copy();
326
327 EXPECT_EQ(2, dict2.size());
328 EXPECT_EQ("3", dict2.at(3));
329 EXPECT_EQ("4", dict2.at(4));
330 }
331
TEST(DictTest,whenMoveConstructingDict_thenNewIsCorrect)332 TEST(DictTest, whenMoveConstructingDict_thenNewIsCorrect) {
333 Dict<int64_t, string> dict1;
334 dict1.insert(3, "3");
335 dict1.insert(4, "4");
336
337 Dict<int64_t, string> dict2(std::move(dict1));
338
339 EXPECT_EQ(2, dict2.size());
340 EXPECT_EQ("3", dict2.at(3));
341 EXPECT_EQ("4", dict2.at(4));
342 }
343
TEST(DictTest,whenMoveAssigningDict_thenNewIsCorrect)344 TEST(DictTest, whenMoveAssigningDict_thenNewIsCorrect) {
345 Dict<int64_t, string> dict1;
346 dict1.insert(3, "3");
347 dict1.insert(4, "4");
348
349 Dict<int64_t, string> dict2;
350 dict2 = std::move(dict1);
351
352 EXPECT_EQ(2, dict2.size());
353 EXPECT_EQ("3", dict2.at(3));
354 EXPECT_EQ("4", dict2.at(4));
355 }
356
TEST(DictTest,whenMoveConstructingDict_thenOldIsUnchanged)357 TEST(DictTest, whenMoveConstructingDict_thenOldIsUnchanged) {
358 Dict<int64_t, string> dict1;
359 dict1.insert(3, "3");
360 dict1.insert(4, "4");
361
362 Dict<int64_t, string> dict2(std::move(dict1));
363 EXPECT_EQ(2, dict1.size());
364 EXPECT_EQ("3", dict1.at(3));
365 EXPECT_EQ("4", dict1.at(4));
366 }
367
TEST(DictTest,whenMoveAssigningDict_thenOldIsUnchanged)368 TEST(DictTest, whenMoveAssigningDict_thenOldIsUnchanged) {
369 Dict<int64_t, string> dict1;
370 dict1.insert(3, "3");
371 dict1.insert(4, "4");
372
373 Dict<int64_t, string> dict2;
374 dict2 = std::move(dict1);
375 EXPECT_EQ(2, dict1.size());
376 EXPECT_EQ("3", dict1.at(3));
377 EXPECT_EQ("4", dict1.at(4));
378 }
379
TEST(DictTest,givenIterator_whenPostfixIncrementing_thenMovesToNextAndReturnsOldPosition)380 TEST(DictTest, givenIterator_whenPostfixIncrementing_thenMovesToNextAndReturnsOldPosition) {
381 Dict<int64_t, string> dict;
382 dict.insert(3, "3");
383 dict.insert(4, "4");
384
385 Dict<int64_t, string>::iterator iter1 = dict.begin();
386 Dict<int64_t, string>::iterator iter2 = iter1++;
387 EXPECT_NE(dict.begin()->key(), iter1->key());
388 EXPECT_EQ(dict.begin()->key(), iter2->key());
389 }
390
TEST(DictTest,givenIterator_whenPrefixIncrementing_thenMovesToNextAndReturnsNewPosition)391 TEST(DictTest, givenIterator_whenPrefixIncrementing_thenMovesToNextAndReturnsNewPosition) {
392 Dict<int64_t, string> dict;
393 dict.insert(3, "3");
394 dict.insert(4, "4");
395
396 Dict<int64_t, string>::iterator iter1 = dict.begin();
397 Dict<int64_t, string>::iterator iter2 = ++iter1;
398 EXPECT_NE(dict.begin()->key(), iter1->key());
399 EXPECT_NE(dict.begin()->key(), iter2->key());
400 }
401
TEST(DictTest,givenEqualIterators_thenAreEqual)402 TEST(DictTest, givenEqualIterators_thenAreEqual) {
403 Dict<int64_t, string> dict;
404 dict.insert(3, "3");
405 dict.insert(4, "4");
406
407 Dict<int64_t, string>::iterator iter1 = dict.begin();
408 Dict<int64_t, string>::iterator iter2 = dict.begin();
409 EXPECT_TRUE(iter1 == iter2);
410 EXPECT_FALSE(iter1 != iter2);
411 }
412
TEST(DictTest,givenDifferentIterators_thenAreNotEqual)413 TEST(DictTest, givenDifferentIterators_thenAreNotEqual) {
414 Dict<int64_t, string> dict;
415 dict.insert(3, "3");
416 dict.insert(4, "4");
417
418 Dict<int64_t, string>::iterator iter1 = dict.begin();
419 Dict<int64_t, string>::iterator iter2 = dict.begin();
420 iter2++;
421
422 EXPECT_FALSE(iter1 == iter2);
423 EXPECT_TRUE(iter1 != iter2);
424 }
425
TEST(DictTest,givenIterator_whenDereferencing_thenPointsToCorrectElement)426 TEST(DictTest, givenIterator_whenDereferencing_thenPointsToCorrectElement) {
427 Dict<int64_t, string> dict;
428 dict.insert(3, "3");
429
430 Dict<int64_t, string>::iterator iter = dict.begin();
431 EXPECT_EQ(3, (*iter).key());
432 EXPECT_EQ("3", (*iter).value());
433 EXPECT_EQ(3, iter->key());
434 EXPECT_EQ("3", iter->value());
435 }
436
TEST(DictTest,givenIterator_whenWritingToValue_thenChangesValue)437 TEST(DictTest, givenIterator_whenWritingToValue_thenChangesValue) {
438 Dict<int64_t, string> dict;
439 dict.insert(3, "3");
440
441 Dict<int64_t, string>::iterator iter = dict.begin();
442
443 (*iter).setValue("new_value");
444 EXPECT_EQ("new_value", dict.begin()->value());
445
446 iter->setValue("new_value_2");
447 EXPECT_EQ("new_value_2", dict.begin()->value());
448 }
449
TEST(ListTestIValueBasedList,givenIterator_whenWritingToValueFromIterator_thenChangesValue)450 TEST(ListTestIValueBasedList, givenIterator_whenWritingToValueFromIterator_thenChangesValue) {
451 Dict<int64_t, string> dict;
452 dict.insert(3, "3");
453 dict.insert(4, "4");
454 dict.insert(5, "5");
455
456 (*dict.find(3)).setValue(dict.find(4)->value());
457 EXPECT_EQ("4", dict.find(3)->value());
458
459 dict.find(3)->setValue(dict.find(5)->value());
460 EXPECT_EQ("5", dict.find(3)->value());
461 }
462
TEST(DictTest,isReferenceType)463 TEST(DictTest, isReferenceType) {
464 Dict<int64_t, string> dict1;
465 // NOLINTNEXTLINE(performance-unnecessary-copy-initialization)
466 Dict<int64_t, string> dict2(dict1);
467 Dict<int64_t, string> dict3;
468 dict3 = dict1;
469
470 dict1.insert(3, "three");
471 EXPECT_EQ(1, dict1.size());
472 EXPECT_EQ(1, dict2.size());
473 EXPECT_EQ(1, dict3.size());
474 }
475
TEST(DictTest,copyHasSeparateStorage)476 TEST(DictTest, copyHasSeparateStorage) {
477 Dict<int64_t, string> dict1;
478 Dict<int64_t, string> dict2(dict1.copy());
479 Dict<int64_t, string> dict3;
480 dict3 = dict1.copy();
481
482 dict1.insert(3, "three");
483 EXPECT_EQ(1, dict1.size());
484 EXPECT_EQ(0, dict2.size());
485 EXPECT_EQ(0, dict3.size());
486 }
487
TEST(DictTest,dictTensorAsKey)488 TEST(DictTest, dictTensorAsKey) {
489 Dict<at::Tensor, string> dict;
490 at::Tensor key1 = at::tensor(3);
491 at::Tensor key2 = at::tensor(4);
492 dict.insert(key1, "three");
493 dict.insert(key2, "four");
494
495 EXPECT_EQ(2, dict.size());
496
497 Dict<at::Tensor, string>::iterator found_key1 = dict.find(key1);
498 ASSERT_EQUAL(key1, found_key1->key());
499 EXPECT_EQ("three", found_key1->value());
500
501 Dict<at::Tensor, string>::iterator found_nokey1 = dict.find(at::tensor(3));
502 Dict<at::Tensor, string>::iterator found_nokey2 = dict.find(at::tensor(5));
503 EXPECT_EQ(dict.end(), found_nokey1);
504 EXPECT_EQ(dict.end(), found_nokey2);
505 }
506
TEST(DictTest,dictEquality)507 TEST(DictTest, dictEquality) {
508 Dict<string, int64_t> dict;
509 dict.insert("one", 1);
510 dict.insert("two", 2);
511
512 Dict<string, int64_t> dictSameValue;
513 dictSameValue.insert("one", 1);
514 dictSameValue.insert("two", 2);
515
516 Dict<string, int64_t> dictNotEqual;
517 dictNotEqual.insert("foo", 1);
518 dictNotEqual.insert("bar", 2);
519
520 Dict<string, int64_t> dictRef = dict;
521
522 EXPECT_EQ(dict, dictSameValue);
523 EXPECT_NE(dict, dictNotEqual);
524 EXPECT_NE(dictSameValue, dictNotEqual);
525 EXPECT_FALSE(dict.is(dictSameValue));
526 EXPECT_TRUE(dict.is(dictRef));
527 }
528