TEST(LinkedHashmapTest, Keys) { LinkedHashMap<string, int> map; list<string> keys = {"foo", "bar", "food", "rad", "cat"}; // Insert keys into the map. foreach (const string& key, keys) { map[key] = 1; } map["foo"] = 1; // Re-insert a key. // Ensure the keys returned are the same as insertion order. ASSERT_EQ(keys, map.keys()); }
TEST(LinkedHashmapTest, Keys) { LinkedHashMap<string, int> map; std::list<string> keys; keys.push_back("foo"); keys.push_back("bar"); keys.push_back("food"); keys.push_back("rad"); keys.push_back("cat"); // Insert keys into the map. foreach (const string& key, keys) { map[key] = 1; } map["foo"] = 1; // Re-insert a key. // Ensure the keys returned are the same as insertion order. ASSERT_EQ(keys, map.keys()); }
TEST(LinkedHashMapTest, Foreach) { LinkedHashMap<string, int> map; map["foo"] = 1; map["bar"] = 2; map["caz"] = 3; map["foo"] = 4; // Re-insert a key. list<string> keyList = map.keys(); list<int> valueList = map.values(); vector<string> keys{keyList.begin(), keyList.end()}; vector<int> values{valueList.begin(), valueList.end()}; { int i = 0; foreachpair (const string& key, int value, map) { EXPECT_EQ(keys[i], key); EXPECT_EQ(values[i], value); i++; } }