summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-06-28 14:31:20 -0600
committermo khan <mo.khan@gmail.com>2020-06-28 14:31:20 -0600
commit50d10ed4909c602c45b2a8d5dc305d7963e3d1d4 (patch)
tree5f2bdc019d7889831e028a3d70254001f4ddc9ed
parentfec6a090e1d10b8a3c46d0081c91a54651375b23 (diff)
Add duplicates
-rw-r--r--assignments/01/min_stack_test.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/assignments/01/min_stack_test.c b/assignments/01/min_stack_test.c
index 92160d5..8d2a618 100644
--- a/assignments/01/min_stack_test.c
+++ b/assignments/01/min_stack_test.c
@@ -62,12 +62,10 @@ static void insert(Node **self, int data) {
else
(*self)->next = node;
break;
- case -1:
+ default:
node->next = *self;
*self = node;
break;
- default:
- break;
}
}
@@ -142,6 +140,24 @@ Ensure(MinStack, when_pushing_multiple_integers_out_of_order) {
free(stack);
}
+Ensure(MinStack, when_pushing_duplicate_values_on_to_the_stack) {
+ Stack *stack = initialize();
+
+ push(stack, 2);
+ push(stack, 1);
+ push(stack, 2);
+
+ assert_that(size(stack), is_equal_to(3));
+ assert_that(min(stack), is_equal_to(1));
+
+ assert_that(pop(stack), is_equal_to(1));
+ assert_that(pop(stack), is_equal_to(2));
+ assert_that(pop(stack), is_equal_to(2));
+ assert_that(pop(stack), is_equal_to(NULL));
+
+ free(stack);
+}
+
TestSuite *min_stack_tests() {
TestSuite *suite = create_test_suite();