/* * This is a test suite, and demonstration example, for nested lists of * integers. As a test suite, it performs complete testing of both unnested * and nested integer lists. Integer is used as a representative atomic type * for list element data. The nesting structure is a reprsentative * implementation of recursively-defined nestable lists. Tests are provided to * fully exercise all list operations, on both unnested and nested lists. * * As an example, this suite illustrates a typical form of list usage. It * defines the list specialization nested-int-list.{h,c}. This specialization * has a specialized elem data type for nested list elements. It also defines * specialized functions for constructing and accessing nested int lists, and * elements thereof. * * This testing example is considered adequately representative of list usage. * It covers the basic list functinality using plain integer lists, then the * functionality of arbitrarily nested lists of integers. * * The following is a module test plan: ... TO APPEAR. * */ #include #include #include "nested-int-list.h" /* * The Ini function is a quick testing function to see if an int value is in a * list. Per the documentation in list.h, InList returns the list position in * of the first occurance of an element value, if the value is found. It * returns 0 if the element value is not found. E.g., the following two call * return 3 and 0, respectively: * * Ini(l, 3); * Ini(l, 5); */ bool Ini(List* l, int i); /* * The following are four quick testing functions, used to construct lists. * The "L" function can be called in a chain to build up a list. It takes a * list and an int, and returns the list with the int put on the end. The Ni * function creates a new 1-element list with an int in it. Used together, * these two functions can create a list value in a somewhat readable for. * E.g., the following creates the list [1,2,3,4]: * * l = L(L(L(Ni(1),2),3),4); * * The Ll and Nl functions are analogous constructors for sublist elements. Ll * takes two lists, and puts them together. E.g, the following creates the * nested list [ [1,2,3,4], [1,2,3.4] ] (using the list variable l in the * example just above): * * nl = Ll(l1, l1); */ List* L(List* l, int i); List* Ni(int i); List* Ll(List* l, List* ld); List* Nl(List* l);