/* File: batchtest.c * Author: Samuel A. Rebelsky * Version: 1.0 of February 2000 * * Some simple non-interactive tests of the list implementation. */ /*********** * Headers * *****************************************************************/ #include "stringlist.h" /* Defines these functions. */ #include /* Provides: printf */ /******** * Main * *****************************************************************/ int main() { stringlist stuff; /* The list we'll work with. */ stuff = newList(); if (stuff == NULL) { fprintf(stderr, "Could not create list.\n"); return 1; } printf("Start of empty list.\n"); printList(stdout,stuff); printf("End of empty list.\n\n"); /* Test addToEnd */ if (!addToEnd(stuff,"A")) { fprintf(stderr, "Could not add first A"); return 2; } if (!addToEnd(stuff,"B")) { fprintf(stderr, "Could not add B"); return 2; } if (!addToEnd(stuff,"C")) { fprintf(stderr, "Could not add C"); return 2; } if (!addToEnd(stuff,"A")) { fprintf(stderr, "Could not add second A"); return 2; } if (!addToEnd(stuff,"D")) { fprintf(stderr, "Could not add D"); return 2; } if (!addToEnd(stuff,"A")) { fprintf(stderr, "Could not add last A"); return 2; } printf("Start of A B C A D A.\n"); printList(stdout,stuff); printf("End of A B C A D A.\n\n"); /* Test delete */ printf("About to delete A.\n"); deleteAll(stuff, "A"); printf("After deleting A.\n"); printList(stdout,stuff); printf("End of revised list.\n\n"); return 0; } /* main */