about summary refs log tree commit diff
path: root/test/unittests/unit_maybe_alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/unittests/unit_maybe_alloc.c')
-rw-r--r--test/unittests/unit_maybe_alloc.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/test/unittests/unit_maybe_alloc.c b/test/unittests/unit_maybe_alloc.c
index 93f10889..a856fa08 100644
--- a/test/unittests/unit_maybe_alloc.c
+++ b/test/unittests/unit_maybe_alloc.c
@@ -3,6 +3,17 @@
 #include <setjmp.h>
 #include <assert.h>
 #include <cmocka.h>
+/* cmocka < 1.0 didn't support these features we need */
+#ifndef assert_ptr_equal
+#define assert_ptr_equal(a, b) \
+    _assert_int_equal(cast_ptr_to_largest_integral_type(a), \
+                      cast_ptr_to_largest_integral_type(b), \
+                      __FILE__, __LINE__)
+#define CMUnitTest UnitTest
+#define cmocka_unit_test unit_test
+#define cmocka_run_group_tests(t, setup, teardown) run_tests(t)
+#endif
+
 
 extern void mock_assert(const int result, const char* const expression,
                         const char * const file, const int line);
@@ -28,11 +39,13 @@ int __wrap_printf(const char *format, ...) {
 
 #define BUF_PARAMS (void **)&buf, &size
 
+/*
 static int setup(void **state) {
 
     return 0;
 
 }
+*/
 
 static void test_null_allocs(void **state) {
 
@@ -62,7 +75,7 @@ static void test_zero_size() {
 
     char *buf = NULL;
     size_t size = 0;
-    //assert_non_null(maybe_grow(BUF_PARAMS, 0));
+    assert_non_null(maybe_grow(BUF_PARAMS, 0));
     free(buf);
     buf = NULL;
     size = 0;
@@ -74,6 +87,8 @@ static void test_zero_size() {
 
     expect_assert_failure(ck_maybe_grow(BUF_PARAMS, 0));
 
+    ck_free(ptr);
+
 }
 
 static void test_unchanged_size(void **state) {
@@ -119,11 +134,13 @@ static void test_grow_multiple(void **state) {
 
 }
 
+/*
 static int teardown(void **state) {
 
     return 0;
 
 }
+*/
 
 int main(int argc, char **argv) {
 
@@ -135,6 +152,7 @@ int main(int argc, char **argv) {
         cmocka_unit_test(test_grow_multiple),
 	};
 
-    return cmocka_run_group_tests (tests, setup, teardown);
+    //return cmocka_run_group_tests (tests, setup, teardown);
+    return cmocka_run_group_tests (tests, NULL, NULL);
 
-}
\ No newline at end of file
+}