#include #include #include // for EXIT_FAILURE /*#include */ #include /*#include */ /* * Stub test program for the list implementation in list.c. * * Author: Niclas Borlin (niclas.borlin@cs.umu.se). * * Version information: * 2018-01-28: v1.0. First public version. * 2019-01-23: v1.1. Added file comment. Removed memory cleanup on failure. * 2023-01-21: v2.0. Complete re-write. Semi-serious attempt at a complete test program for * int_list. * 2023-01-21: v2.01. Updated print identification command. * 2023-03-23: v2.1. Renamed list_pos_are_equal to list_pos_is_equal. * 2023-03-23: v2.2. Removed empty if statements in test code. */ #define VERSION "v2.2" #define VERSION_DATE "2023-03-23" /* * Function to compare the values stored in the list. */ bool value_equal(int v1, int v2) { return v1 == v2; } void isempty_return_true(void) { stack s = stack_empty(); if (stack_is_empty(s) == false){ fprintf(stderr,"\nStack is empty but \"stack_is_empty\" reports non empty\n"); /*return 1;*/ } stack_print(s); s = stack_push(s,10); stack_print(s); if (stack_is_empty(s) == true){ fprintf(stderr,"\nStack is non empty but \"stack_is_empty\" reports empty.\n"); /*return 1;*/ } fprintf(stderr,"\n \"stack_is_empty\" function works!\n"); stack_kill(s); {/* s = stack_push(s,2); int x; x = stack_top(s); fprintf(stderr,"value x: %x\n",x); int truevalue; truevalue = stack_is_empty(s); value_equal(truevalue,true); stack_print(s); */ /*if s == { }*/ } } void push_stack_on_top(void) { stack s = stack_empty(); s = stack_push(s,1); s = stack_push(s,2); if (stack_top(s) == 1){ fprintf(stderr,"\n\"stack_push\" puts values in wrong order.\n"); } } int main(void) { printf("%s, %s %s: Test program for the typed int_stack datatype.\n", __FILE__, VERSION, VERSION_DATE); printf("Code base version %s.\n\n", CODE_BASE_VERSION); isempty_return_true(); fprintf(stderr,"\nSUCCESS: Implementation passed all tests. Normal exit.\n"); return 0; }