test-core: Fix warning in uniq test
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
diff --git a/tests/t00-core.c b/tests/t00-core.c
index 6b20e18..1037ee2 100644
--- a/tests/t00-core.c
+++ b/tests/t00-core.c
@@ -75,21 +75,32 @@ END_TEST
static int test_cmp(const void *a, const void *b)
{
- return (int)a - (int)b;
+ return *(int *)a - *(int *)b;
}
BEGIN_TEST(vector2, "remove duplicates")
git_vector x;
+ int *ptrs[2];
+
+ ptrs[0] = git__malloc(sizeof(int));
+ ptrs[1] = git__malloc(sizeof(int));
+
+ *ptrs[0] = 2;
+ *ptrs[1] = 1;
+
must_pass(git_vector_init(&x, 5, test_cmp));
- must_pass(git_vector_insert(&x, (void *) 0xdeadbeef));
- must_pass(git_vector_insert(&x, (void *) 0xcafebabe));
- must_pass(git_vector_insert(&x, (void *) 0xcafebabe));
- must_pass(git_vector_insert(&x, (void *) 0xdeadbeef));
- must_pass(git_vector_insert(&x, (void *) 0xcafebabe));
+ must_pass(git_vector_insert(&x, ptrs[0]));
+ must_pass(git_vector_insert(&x, ptrs[1]));
+ must_pass(git_vector_insert(&x, ptrs[1]));
+ must_pass(git_vector_insert(&x, ptrs[0]));
+ must_pass(git_vector_insert(&x, ptrs[1]));
must_be_true(x.length == 5);
git_vector_uniq(&x);
must_be_true(x.length == 2);
git_vector_free(&x);
+
+ free(ptrs[0]);
+ free(ptrs[1]);
END_TEST