Example #1
0
TEST_F(HashTableTest, TestContains)
{
    Int32HashMap newmap;
    EXPECT_FALSE(newmap.contains(1));
    EXPECT_FALSE(newmap.contains(2));
    EXPECT_FALSE(newmap.contains(3));

    newmap.put(1, 10);
    EXPECT_TRUE(newmap.contains(1));
    EXPECT_FALSE(newmap.contains(2));
    EXPECT_FALSE(newmap.contains(3));

    newmap.put(2, 20);
    EXPECT_TRUE(newmap.contains(1));
    EXPECT_TRUE(newmap.contains(2));
    EXPECT_FALSE(newmap.contains(3));

    newmap.put(3, 30);
    EXPECT_TRUE(newmap.contains(1));
    EXPECT_TRUE(newmap.contains(2));
    EXPECT_TRUE(newmap.contains(3));

    newmap.clear();
    EXPECT_FALSE(newmap.contains(1));
    EXPECT_FALSE(newmap.contains(2));
    EXPECT_FALSE(newmap.contains(3));
}
Example #2
0
TEST_F(HashTableTest, TestClear)
{
    Int32HashMap newmap;

    newmap.put(1, 10);
    newmap.put(2, 20);
    newmap.put(3, 30);

    newmap.clear();
    EXPECT_EQ(static_cast<capu::uint32_t>(0), newmap.count());

    capu::status_t ret = 0;
    capu::int32_t value = newmap.at(1, &ret);
    EXPECT_EQ(capu::CAPU_ENOT_EXIST, ret);
    EXPECT_EQ(0, value);

    value = newmap.at(2, &ret);
    EXPECT_EQ(capu::CAPU_ENOT_EXIST, ret);
    EXPECT_EQ(0, value);

    value = newmap.at(3, &ret);
    EXPECT_EQ(capu::CAPU_ENOT_EXIST, ret);
    EXPECT_EQ(0, value);

    newmap.put(1, 10);
    value = newmap.at(1, &ret);
    EXPECT_EQ(capu::CAPU_OK, ret);
    EXPECT_EQ(10, value);
}