stack.test.c (406B)
1 #include <stdbool.h> 2 #include <assert.h> 3 4 #include "stack.h" 5 6 bool 7 test_push_then_pop() 8 { 9 stack *s = new_stack(); 10 push(s, (void*)0xfa); 11 return (pop(s) == (void*)0xfa && is_empty(s)); 12 } 13 14 bool 15 test_push_then_peek() 16 { 17 stack *s = new_stack(); 18 push(s, (void*)0x1); 19 return (peek(s) == (void*)0x1 && !is_empty(s)); 20 } 21 22 int 23 main() 24 { 25 assert(test_push_then_pop()); 26 assert(test_push_then_peek()); 27 return 0; 28 }