Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorVicent Martí <tanoku@gmail.com>2011-07-06 21:55:06 +0400
committerVicent Martí <tanoku@gmail.com>2011-07-06 21:55:06 +0400
commitbf9a2e98b83c8de2b8664a91167b5529ae1d9d39 (patch)
tree6db283bad395273d08b96f779ff349d00530f948 /tests
parentc68dee2a74fc6c5a2adab12857e9840254647a4b (diff)
parent245adf4f3cc1d47352e626ef53372d07761d84cf (diff)
Merge pull request #296 from kiryl/index-optimization
Index optimization
Diffstat (limited to 'tests')
-rw-r--r--tests/t00-core.c23
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);