From c78066aef16a35430647344285aa40975868da87 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Thu, 8 Jan 2015 17:10:18 -0200 Subject: [PATCH] testsuite: add test for array_pop() --- testsuite/test-array.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/testsuite/test-array.c b/testsuite/test-array.c index 62982ad2..3c72a8a1 100644 --- a/testsuite/test-array.c +++ b/testsuite/test-array.c @@ -159,4 +159,36 @@ static int test_array_remove_at(const struct test *t) DEFINE_TEST(test_array_remove_at, .description = "test array remove at"); +static int test_array_pop(const struct test *t) +{ + struct array array; + const char *c1 = "test1"; + const char *c2 = "test2"; + const char *c3 = "test3"; + + array_init(&array, 2); + array_append(&array, c1); + array_append(&array, c2); + array_append(&array, c3); + + + array_pop(&array); + + assert_return(array.count == 2, EXIT_FAILURE); + assert_return(array.array[0] == c1, EXIT_FAILURE); + assert_return(array.array[1] == c2, EXIT_FAILURE); + + array_pop(&array); + array_pop(&array); + + assert_return(array.count == 0, EXIT_FAILURE); + + array_free_array(&array); + + return 0; +} + +DEFINE_TEST(test_array_pop, + .description = "test array pop"); + TESTSUITE_MAIN(); -- 2.47.3