Example #1
0
LONGBOW_TEST_CASE(Global, PARC_TreeRedBlack_Values)
{
    PARCTreeRedBlack *tree1;
    PARCArrayList *list;

    tree1 = parcTreeRedBlack_Create(pointerComp, NULL, NULL, NULL, NULL, NULL);
    list = parcArrayList_Create(NULL);

    // Insert in tree out of order
    for (long i = 10; i < 20; i++) {
        // Add some elements to the tree
        parcTreeRedBlack_Insert(tree1, (void *) i, (void *) (i << 8));
    }
    for (long i = 1; i < 10; i++) {
        // Add some elements to the tree
        parcTreeRedBlack_Insert(tree1, (void *) i, (void *) (i << 8));
    }

    // Insert in list in order
    for (long i = 1; i < 20; i++) {
        // Add some elements to the tree
        parcArrayList_Add(list, (void *) (i << 8));
    }

    PARCArrayList *values = parcTreeRedBlack_Values(tree1);

    assertTrue(parcArrayList_Equals(list, values), "Key list doesnt' match");

    parcArrayList_Destroy(&values);
    parcArrayList_Destroy(&list);
    parcTreeRedBlack_Destroy(&tree1);
}
Example #2
0
LONGBOW_TEST_CASE(Global, PARCList_Equals_Same)
{
    PARCArrayList *a = parcArrayList_Create(parcArrayList_StdlibFreeFunction);
    assertTrue(parcArrayList_Equals(a, a), "Expected the same array list to be equal to itself.");

    parcArrayList_Destroy(&a);
}
Example #3
0
LONGBOW_TEST_CASE(Global, PARCList_Equals_Empty)
{
    PARCArrayList *a = parcArrayList_Create(parcArrayList_StdlibFreeFunction);
    PARCArrayList *b = parcArrayList_Create(parcArrayList_StdlibFreeFunction);
    assertTrue(parcArrayList_Equals(a, b), "Equal values were expected to be equal");

    parcArrayList_Destroy(&a);
    parcArrayList_Destroy(&b);
}
Example #4
0
LONGBOW_TEST_CASE(Global, PARCList_RemoveAndDestroy_AtIndex_Last)
{
    char a[] = "apple";
    char b[] = "bananna";
    char c[] = "cherry";

    PARCArrayList *array = parcArrayList_Create(NULL);
    parcArrayList_Add(array, a);
    parcArrayList_Add(array, b);
    parcArrayList_Add(array, c);

    PARCArrayList *expected = parcArrayList_Create(NULL);
    parcArrayList_Add(expected, a);
    parcArrayList_Add(expected, b);

    parcArrayList_RemoveAndDestroyAtIndex(array, 2);

    assertTrue(parcArrayList_Equals(expected, array), "Expected ");

    parcArrayList_Destroy(&expected);
    parcArrayList_Destroy(&array);
}
Example #5
0
LONGBOW_TEST_CASE(Global, PARCList_Remove_AtIndex)
{
    char a[] = "apple";
    char b[] = "bananna";
    char c[] = "cherry";

    PARCArrayList *array = parcArrayList_Create(NULL);
    parcArrayList_Add(array, a);
    parcArrayList_Add(array, b);
    parcArrayList_Add(array, c);

    PARCArrayList *expected = parcArrayList_Create(NULL);
    parcArrayList_Add(expected, a);
    parcArrayList_Add(expected, c);

    void *removedElement = parcArrayList_RemoveAtIndex(array, 1);

    assertTrue(removedElement == b, "Expected ");
    assertTrue(parcArrayList_Equals(expected, array), "Expected ");

    parcArrayList_Destroy(&expected);
    parcArrayList_Destroy(&array);
}