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:
authornulltoken <emeric.fermas@gmail.com>2011-07-07 15:47:45 +0400
committerVicent Marti <tanoku@gmail.com>2011-07-07 17:37:07 +0400
commit2b5af615e1f4344f6073d0ddf3e83256d9a8d58f (patch)
tree9c39ac80e17cb8e0c88d3663237c9f9353426ba6 /tests
parent417a581d9284021b1ce2edd4da7584b3e2379402 (diff)
tag: add pattern based retrieval of list of tag names
Diffstat (limited to 'tests')
-rw-r--r--tests/t08-tag.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/t08-tag.c b/tests/t08-tag.c
index 64a939f0e..aeff8b360 100644
--- a/tests/t08-tag.c
+++ b/tests/t08-tag.c
@@ -77,6 +77,35 @@ BEGIN_TEST(read1, "list all tag names from the repository")
git_repository_free(repo);
END_TEST
+static int ensure_tag_pattern_match(git_repository *repo, const char *pattern, const size_t expected_matches)
+{
+ git_strarray tag_list;
+ int error = GIT_SUCCESS;
+
+ if ((error = git_tag_list_match(&tag_list, pattern, repo)) < GIT_SUCCESS)
+ goto exit;
+
+ if (tag_list.count != expected_matches)
+ error = GIT_ERROR;
+
+exit:
+ git_strarray_free(&tag_list);
+ return error;
+}
+
+BEGIN_TEST(read2, "list all tag names from the repository matching a specified pattern")
+ git_repository *repo;
+ must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
+ must_pass(ensure_tag_pattern_match(repo, "", 3));
+ must_pass(ensure_tag_pattern_match(repo, "*", 3));
+ must_pass(ensure_tag_pattern_match(repo, "t*", 1));
+ must_pass(ensure_tag_pattern_match(repo, "*b", 2));
+ must_pass(ensure_tag_pattern_match(repo, "e", 0));
+ must_pass(ensure_tag_pattern_match(repo, "e90810b", 1));
+ must_pass(ensure_tag_pattern_match(repo, "e90810[ab]", 1));
+ git_repository_free(repo);
+END_TEST
+
#define TAGGER_NAME "Vicent Marti"
#define TAGGER_EMAIL "vicent@github.com"
@@ -222,6 +251,8 @@ END_TEST
BEGIN_SUITE(tag)
ADD_TEST(read0);
ADD_TEST(read1);
+ ADD_TEST(read2);
+
ADD_TEST(write0);
ADD_TEST(write2);
ADD_TEST(write3);