Exemplo n.º 1
0
void aTest5() {
    int arr[] = {3, 4};
    struct node * root = to_red_black_tree(arr, 2);
    assert(is_red_black_tree(root));
    setNodeRed(root);
    assert(!is_red_black_tree(root));
    printf("finished atest5\n\n");
}
Exemplo n.º 2
0
void aTest3() {
    int arr[] = {3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 17};
    struct node * root = to_red_black_tree(arr, 13);
    assert(is_red_black_tree(root));
    printf("finished atest3\n\n");

}
Exemplo n.º 3
0
void aTest2() {
    int arr[] = {1, 6, 8, 11, 13, 15, 17, 22, 25, 27};
    struct node * root = to_red_black_tree(arr, 10);
    assert(root->key == 13);
    assert(is_red_black_tree(root));
    printf("finished atest2\n\n");
}
Exemplo n.º 4
0
void aTest1() {
    int arr[] = {2, 4, 6};
    struct node * root = to_red_black_tree(arr, 3);
    assert(root->key == 4);

    assert(is_red_black_tree(root));
    printf("finished atest1\n\n");

}
Exemplo n.º 5
0
Arquivo: main.c Projeto: pochuan/cs166
void test_red_black(int size) {
    printf("Making a tree of size %i...\n", size);
    struct node* rbroot = to_red_black_tree(elems, size);
    printf("Checking if the tree was well-formed\n");
    if (is_red_black_tree(rbroot)) {
        printf("PASS\n");
    }
    else {
        printf("\tFAIL\n");
    }
}
Exemplo n.º 6
0
void test2() {
    struct node rootStruct;
    struct node * root = &rootStruct;
    setNodeRed(root);
    struct node lStruct;
    struct node lStruct2;
    struct node lStruct3;
    root->left = &lStruct;
    root->right = &lStruct2;
    setNodeRed(root->left);
    getLeftChild(root)->left = &lStruct3;
    setNodeRed(root->right);
    assert(!is_red_black_tree(root));
}
Exemplo n.º 7
0
void test1() {

    struct node * root = calloc(1, sizeof(struct node));
    struct node * lStruct = calloc(1, sizeof(struct node));

    struct node * lStruct2 = calloc(1, sizeof(struct node));

    setLeftChild(root, lStruct);
    setRightChild(root, lStruct2);

    setNodeRed(lStruct2);
    setNodeRed(root->left);


    struct node * third1 = calloc(1, sizeof(struct node));
    struct node * third2 = calloc(1, sizeof(struct node));
    struct node * third3 = calloc(1, sizeof(struct node));
    struct node * third4 = calloc(1, sizeof(struct node));

    setLeftChild(lStruct, third1);
    setRightChild(lStruct, third2);
    setLeftChild(lStruct2, third3);
    setRightChild(lStruct2, third4);

    // setNodeRed(third1);
    setNodeRed(third2);

    assert(!is_red_black_tree(root));

    free(third1);
    free(third2);
    free(third3);
    free(third4);

    free(lStruct);
    free(lStruct2);

    free(root);

}
Exemplo n.º 8
0
void aTest4() {
    int arr[] = {3};
    struct node * root = to_red_black_tree(arr, 1);
    assert(is_red_black_tree(root));
    printf("finished atest4\n\n");
}
Exemplo n.º 9
0
void aTest6() {
    int arr[] = {3, 4, 5, 6};
    struct node * root = to_red_black_tree(arr, 4);
    assert(is_red_black_tree(root));
    printf("finished atest6\n\n");
}