/*---- signature: main: void -> int purpose: testing program for my collection of linked list functions compiled using: (written on 1 line!) g++ linked-list-tests.cpp linked-list-functs.cpp Node.cpp -o linked-list-tests run using: ./linled-list-tests by: Sharon Tuttle last modified: 2022-10-28 ----*/ #include <cstdlib> #include <iostream> #include <string> #include <cmath> #include "Node.h" #include "linked-list-functs.h" using namespace std; int main() { cout << boolalpha; cout << endl << "*** Testing insert_at_front ***" << endl; Node *begin = NULL; insert_at_front(begin, 47); /*--- if the above worked, list now contains 47 ---*/ cout << (begin->get_data() == 47) << endl; cout << (begin->get_next() == NULL) << endl; insert_at_front(begin, 36); /*--- after this: * begin should point to a node containing 36, * ...whose next data field should point to a node containing 47 * ...and the node with 47 should have a NULL next data field. ---*/ cout << (begin->get_data() == 36) << endl; cout << ( begin->get_next()->get_data() == 47 ) << endl; cout << ( begin->get_next()->get_next() == NULL ) << endl; cout << endl << "*** Testing print_list ***" << endl; Node* my_first; my_first = NULL; cout << endl << "should see List header, and no contents:" << endl; print_list(my_first); insert_at_front(my_first, 12); insert_at_front(my_first, 700); insert_at_front(my_first, 15); cout << endl << "should see List contents of 15, then 700, then 12" << endl; print_list(my_first); cout << endl << "*** Testing delete_list ***" << endl; cout << (delete_list(my_first) == 3) << endl; Node *empty; empty = NULL; cout << (delete_list(empty) == 0) << endl; // and want to clean up list Node pointer begin // points to, also -- so why not an additional // test while I am at it? 8-) cout << (delete_list(begin) == 2) << endl; cout << endl; return EXIT_SUCCESS; }