]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
testsuite: add test for array_pop()
authorLucas De Marchi <lucas.demarchi@intel.com>
Thu, 8 Jan 2015 19:10:18 +0000 (17:10 -0200)
committerLucas De Marchi <lucas.demarchi@intel.com>
Thu, 8 Jan 2015 19:10:18 +0000 (17:10 -0200)
testsuite/test-array.c

index 62982ad20d82b0f6b1e89d9a070fae79b088b324..3c72a8a109c58b0d5b5450da6523175f5fd626a3 100644 (file)
@@ -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();