TEST(GTestMap, TestClear) { Map::Ptr m = Map::create(); String::CPtr x = String::create("x"); String::CPtr y = String::create("y"); m->put(x, 123); m->put(y, 456); m->put(String::null(), UNDEFINED); m->clear(); ASSERT_TRUE(m->isEmpty()); }
TEST(GTestMap, TestRemove) { Map::Ptr m = Map::create(); String::CPtr x = String::create("x"); String::CPtr y = String::create("y"); String::CPtr z = String::create("z"); m->put(x, 123); m->put(y, String::null()); m->put(String::null(), z); m->put(UNDEFINED, UNDEFINED); ASSERT_EQ(4, m->size()); ASSERT_TRUE(m->remove(x).equals(123)); ASSERT_EQ(3, m->size()); ASSERT_TRUE(m->remove(y).equals(String::null())); ASSERT_EQ(2, m->size()); ASSERT_TRUE(m->remove(String::null()).equals(z)); ASSERT_EQ(1, m->size()); ASSERT_TRUE(m->remove(UNDEFINED).isUndefined()); ASSERT_TRUE(m->isEmpty()); }