If map has an entry for k, return the corresponding value, else return def.
| 31 | |
| 32 | // If map has an entry for k, return the corresponding value, else return def. |
| 33 | int32 Get(const NumMap& map, int64 k, int32 def = -1) { |
| 34 | auto iter = map.find(k); |
| 35 | if (iter == map.end()) { |
| 36 | EXPECT_EQ(map.count(k), 0); |
| 37 | return def; |
| 38 | } else { |
| 39 | EXPECT_EQ(map.count(k), 1); |
| 40 | EXPECT_EQ(&map.at(k), &iter->second); |
| 41 | EXPECT_EQ(iter->first, k); |
| 42 | return iter->second; |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | // Return contents of map as a sorted list of pairs. |
| 47 | typedef std::vector<std::pair<int64, int32>> NumMapContents; |
no test coverage detected