Exemplo n.º 1
0
TEST(GTestMap, TestPutAndGet) {
    Map::Ptr m = Map::create();
    String::CPtr x = String::create("x");
    ASSERT_TRUE(m->put(x, 123).isUndefined());
    ASSERT_TRUE(m->get(x).equals(123));
    ASSERT_TRUE(m->get(String::create("x")).equals(123));

    ASSERT_TRUE(m->put(x, 456).equals(123));
    ASSERT_TRUE(m->get(x).equals(456));
    ASSERT_TRUE(m->get(String::intern("x")).equals(456));
}
Exemplo n.º 2
0
TEST(GTestMap, TestPutAndGet2) {
    Map::Ptr m = Map::create();
    ASSERT_TRUE(m->put(String::null(), 123).isUndefined());
    ASSERT_TRUE(m->get(String::null()).equals(123));
    ASSERT_TRUE(m->get(Map::null()).equals(123));

    ASSERT_TRUE(m->put(Map::null(), String::null()).equals(123));
    ASSERT_TRUE(m->get(String::null()).equals(Map::null()));

    ASSERT_TRUE(m->put(UNDEFINED, UNDEFINED).isUndefined());
    ASSERT_TRUE(m->get(UNDEFINED).isUndefined());
}