diff options
author | Vicent Martà <tanoku@gmail.com> | 2011-07-06 21:55:06 +0400 |
---|---|---|
committer | Vicent Martà <tanoku@gmail.com> | 2011-07-06 21:55:06 +0400 |
commit | bf9a2e98b83c8de2b8664a91167b5529ae1d9d39 (patch) | |
tree | 6db283bad395273d08b96f779ff349d00530f948 /tests | |
parent | c68dee2a74fc6c5a2adab12857e9840254647a4b (diff) | |
parent | 245adf4f3cc1d47352e626ef53372d07761d84cf (diff) |
Merge pull request #296 from kiryl/index-optimization
Index optimization
Diffstat (limited to 'tests')
-rw-r--r-- | tests/t00-core.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/t00-core.c b/tests/t00-core.c index c01518b28..ee1eb6df2 100644 --- a/tests/t00-core.c +++ b/tests/t00-core.c @@ -73,6 +73,28 @@ BEGIN_TEST(vector1, "don't read past array bounds on remove()") git_vector_free(&x); END_TEST +static int test_cmp(const void *a, const void *b) +{ + int n1 = *(int *)a; + int n2 = *(int *)b; + + return n1 - n2; +} + +BEGIN_TEST(vector2, "remove duplicates") + git_vector x; + 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_be_true(x.length == 5); + git_vector_uniq(&x); + must_be_true(x.length == 2); + git_vector_free(&x); +END_TEST + BEGIN_TEST(path0, "get the dirname of a path") char dir[64], *dir2; @@ -531,6 +553,7 @@ BEGIN_SUITE(core) ADD_TEST(vector0); ADD_TEST(vector1); + ADD_TEST(vector2); ADD_TEST(path0); ADD_TEST(path1); |