diff options
Diffstat (limited to 'src/01/01b/stack_test.c')
| -rw-r--r-- | src/01/01b/stack_test.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/01/01b/stack_test.c b/src/01/01b/stack_test.c index 457f656..b05f278 100644 --- a/src/01/01b/stack_test.c +++ b/src/01/01b/stack_test.c @@ -1,5 +1,6 @@ -#include <cgreen/cgreen.h> #include "stack.h" +#include <cgreen/cgreen.h> +#include <math.h> Describe(Stack); BeforeEach(Stack){ } @@ -38,12 +39,35 @@ Ensure(Stack, pop_successive_items) { destroy(stack); } +Ensure(Stack, when_popping_an_item_off_an_empty_stack) { + Stack *stack = initialize(); + + assert_that(pop(stack), is_equal_to(NULL)); + + destroy(stack); +} + +Ensure(Stack, when_pushing_an_item_on_to_a_full_stack) { + Stack *stack = initialize(); + int max = 2147483647; + + for (int i = 0; i < max; i++) + push(stack, 1); + + push(stack, 1); + + assert_that(size(stack), is_equal_to(max)); + destroy(stack); +} + TestSuite *stack_tests() { TestSuite *suite = create_test_suite(); - add_test_with_context(suite, Stack, push_onto_stack); add_test_with_context(suite, Stack, pop_single_item); add_test_with_context(suite, Stack, pop_successive_items); + add_test_with_context(suite, Stack, push_onto_stack); + add_test_with_context(suite, Stack, when_popping_an_item_off_an_empty_stack); + add_test_with_context(suite, Stack, when_pushing_an_item_on_to_a_full_stack); return suite; } |
