| 33 | typedef SliceMap<int>::type MySliceMap; |
| 34 | |
| 35 | TEST(SliceTest, TestSliceMap) { |
| 36 | MySliceMap my_map; |
| 37 | Slice a("a"); |
| 38 | Slice b("b"); |
| 39 | Slice c("c"); |
| 40 | |
| 41 | // Insertion is deliberately out-of-order; the map should restore order. |
| 42 | InsertOrDie(&my_map, c, 3); |
| 43 | InsertOrDie(&my_map, a, 1); |
| 44 | InsertOrDie(&my_map, b, 2); |
| 45 | |
| 46 | int expectedValue = 0; |
| 47 | for (const MySliceMap::value_type& pair : my_map) { |
| 48 | int data = 'a' + expectedValue++; |
| 49 | ASSERT_EQ(Slice(reinterpret_cast<uint8_t*>(&data), 1), pair.first); |
| 50 | ASSERT_EQ(expectedValue, pair.second); |
| 51 | } |
| 52 | |
| 53 | expectedValue = 0; |
| 54 | for (auto iter = my_map.begin(); iter != my_map.end(); iter++) { |
| 55 | int data = 'a' + expectedValue++; |
| 56 | ASSERT_EQ(Slice(reinterpret_cast<uint8_t*>(&data), 1), iter->first); |
| 57 | ASSERT_EQ(expectedValue, iter->second); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | } // namespace kudu |
nothing calls this directly
no test coverage detected