Пример #1
0
TEST_F(HashTableTest, find)
{
    Int32HashMap newmap;
    EXPECT_EQ(newmap.end(), newmap.find(4));
    newmap.put(1, 5);
    EXPECT_EQ(5, (*newmap.find(1)).value);
}
Пример #2
0
TEST_F(HashTableTest, IteratorRemove)
{
    Int32HashMap newmap;

    newmap.put(0, 12);
    newmap.put(3, 10);
    newmap.put(2, 11);

    for (Int32HashMap::Iterator iter = newmap.begin(); iter != newmap.end();)
    {
        newmap.remove(iter);
    }

    EXPECT_EQ(0u, newmap.count());
    capu::status_t ret = 0;

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

    newmap.put(0, 12);
    newmap.put(3, 10);
    newmap.put(2, 11);

    Int32HashMap::Iterator iter2 = newmap.begin();
    capu::int32_t expectedValue = iter2->value;
    capu::int32_t oldValue = 0;
    newmap.remove(iter2, &oldValue);
    EXPECT_EQ(expectedValue, oldValue);

    while (iter2 != newmap.end())
    {
        newmap.remove(iter2);
    }

    EXPECT_EQ(0u, newmap.count());
}
Пример #3
0
TEST_F(HashTableTest, TestRemove1)
{
    Int32HashMap newmap;

    newmap.put(1, 10);
    newmap.remove(1);
    newmap.put(2, 10);

    Int32HashMap::Iterator it = newmap.begin();
    while (it != newmap.end())
    {
        it++;
    }
}