Exemple #1
0
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());
}
Exemple #2
0
TEST(GTestMap, TestSize) {
    Map::Ptr m = Map::create();
    m->put(String::create("x"), 123);
    ASSERT_EQ(1, m->size());
    m->put(String::create("y"), 456);
    ASSERT_EQ(2, m->size());
    m->put(123, String::create("x"));
    ASSERT_EQ(3, m->size());
    m->put(456, String::create("y"));
    ASSERT_EQ(4, m->size());
    m->put(Object::null(), String::null());
    ASSERT_EQ(5, m->size());
    m->put(UNDEFINED, UNDEFINED);
    ASSERT_EQ(6, m->size());
}