Exemple #1
0
char * test_nlist()
{
    unsigned ui;
    struct nlist *nl;
/*
    ui = hash("how");
    printf("how -> %u\n", ui);

    ui = hash("are");
    printf("are -> %u\n", ui);

    ui = hash("you");
    printf("you -> %u\n", ui);
*/
    nl = install("how", "how");
    nl = install("are", "are");
    nl = install("you", "you");

    nl = lookup("how");
    mu_assert(nl != NULL, "did not find 'how'");
    mu_assert(strcmp(nl->name, "how") == 0, "name is not 'how'");
    mu_assert(strcmp(nl->defn, "how") == 0, "defn is not 'how'");

    undef("how");
    nl = lookup("how");
    mu_assert(nl == NULL, "still find 'how'");

    releaselist();

    return NULL;
}
int main()
{
    List *head = NULL;
    int data[10] = {1, 4, 2, 7, 9, 3, 5, 0, 8, 6};
    int i;

    for (i = 0; i < 10; i++) {
        insertnode(&head, data[i]);
    }

    printlist(head); //show data after sorting.

    releaselist(head); //free node memory.

    return 0;
}