OLD | NEW |
1 // Copyright (c) 2014, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dartino project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 #include "src/shared/assert.h" | 5 #include "src/shared/assert.h" |
6 #include "src/vm/object_map.h" | 6 #include "src/vm/object_map.h" |
7 #include "src/shared/test_case.h" | 7 #include "src/shared/test_case.h" |
8 | 8 |
9 namespace fletch { | 9 namespace dartino { |
10 | 10 |
11 TEST_CASE(ObjectMap) { | 11 TEST_CASE(ObjectMap) { |
12 ObjectMap map(256); | 12 ObjectMap map(256); |
13 for (int i = 0; i < 1024; i++) { | 13 for (int i = 0; i < 1024; i++) { |
14 map.Add(i, Smi::FromWord(i)); | 14 map.Add(i, Smi::FromWord(i)); |
15 } | 15 } |
16 EXPECT_EQ(1024, map.size()); | 16 EXPECT_EQ(1024, map.size()); |
17 | 17 |
18 for (int i = 0; i < 1024; i++) { | 18 for (int i = 0; i < 1024; i++) { |
19 EXPECT_EQ(i, Smi::cast(map.LookupById(i))->value()); | 19 EXPECT_EQ(i, Smi::cast(map.LookupById(i))->value()); |
(...skipping 20 matching lines...) Expand all Loading... |
40 | 40 |
41 for (int i = 0; i < 1024; i++) { | 41 for (int i = 0; i < 1024; i++) { |
42 EXPECT(map.RemoveById(i)); | 42 EXPECT(map.RemoveById(i)); |
43 EXPECT(!map.RemoveById(i)); | 43 EXPECT(!map.RemoveById(i)); |
44 EXPECT(map.LookupById(i) == NULL); | 44 EXPECT(map.LookupById(i) == NULL); |
45 EXPECT_EQ(-1, map.LookupByObject(Smi::FromWord(i))); | 45 EXPECT_EQ(-1, map.LookupByObject(Smi::FromWord(i))); |
46 } | 46 } |
47 EXPECT_EQ(0, map.size()); | 47 EXPECT_EQ(0, map.size()); |
48 } | 48 } |
49 | 49 |
50 } // namespace fletch | 50 } // namespace dartino |
OLD | NEW |