Пример #1
0
void LinkedHashSetTest::testContains() {

    LinkedHashSet<int> set;
    populateSet(set);

    CPPUNIT_ASSERT_MESSAGE("Returned false for valid object", set.contains(90));
    CPPUNIT_ASSERT_MESSAGE("Returned true for invalid Object", !set.contains(SET_SIZE + 1));
}
Пример #2
0
void LinkedHashSetTest::testConstructor() {

    LinkedHashSet<int> set;
    CPPUNIT_ASSERT(set.isEmpty());
    CPPUNIT_ASSERT_EQUAL(0, set.size());
    CPPUNIT_ASSERT_EQUAL(false, set.contains(1));
}
Пример #3
0
void LinkedHashSetTest::testRemove() {

    LinkedHashSet<int> set;
    populateSet(set);
    int size = set.size();
    set.remove(98);
    CPPUNIT_ASSERT_MESSAGE("Failed to remove element", !set.contains(98));
    CPPUNIT_ASSERT_MESSAGE("Failed to decrement set size", set.size() == size - 1);
}
Пример #4
0
void LinkedHashSetTest::testClear() {

    LinkedHashSet<int> set;
    populateSet(set);

    CPPUNIT_ASSERT(set.size() > 0);
    set.clear();
    CPPUNIT_ASSERT(set.size() == 0);
    CPPUNIT_ASSERT(!set.contains(1));
}
Пример #5
0
void LinkedHashSetTest::testAdd() {

    LinkedHashSet<int> set;
    populateSet(set);
    int size = set.size();

    set.add(8);
    CPPUNIT_ASSERT_MESSAGE("Added element already contained by set", set.size() == size);
    set.add(-9);
    CPPUNIT_ASSERT_MESSAGE("Failed to increment set size after add", set.size() == size + 1);
    CPPUNIT_ASSERT_MESSAGE("Failed to add element to set", set.contains(-9));
}
Пример #6
0
void LinkedHashSetTest::testCopy2() {

    LinkedList<int> collection;

    for (int i = 0; i < 50; ++i) {
        collection.add(i);
    }

    LinkedHashSet<int> set;

    set.copy(collection);

    CPPUNIT_ASSERT(collection.size() == set.size());

    for (int i = 0; i < 50; ++i) {
        CPPUNIT_ASSERT(set.contains(i));
    }

    CPPUNIT_ASSERT(set.equals(collection));
}