Commit af699bd6 authored by Florian Klemme's avatar Florian Klemme
Browse files

Teste const/non-const Map::at().

parent 211e3e71
Pipeline #90 passed with stages
in 2 minutes and 5 seconds
......@@ -4,21 +4,25 @@
TEST(Map, access) {
Map<char, int> m1;
const auto& const_m1 = m1;
ASSERT_EQ(m1.size(), 0);
m1['a'] = 5;
ASSERT_EQ(m1.size(), 1);
ASSERT_EQ(m1.at('a'), 5);
ASSERT_EQ(const_m1.at('a'), 5);
ASSERT_TRUE(m1.contains('a'));
ASSERT_FALSE(m1.contains('b'));
m1['b'] = 3;
ASSERT_EQ(m1.size(), 2);
ASSERT_EQ(m1.at('b'), 3);
ASSERT_EQ(const_m1.at('b'), 3);
ASSERT_TRUE(m1.contains('a'));
ASSERT_TRUE(m1.contains('b'));
ASSERT_ANY_THROW(m1.at('z')); // out of range
ASSERT_ANY_THROW(m1.at('z')); // out of range
ASSERT_ANY_THROW(const_m1.at('z')); // out of range
}
TEST(Map, erase) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment