summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2023-03-27 11:58:42 +0100
committerGitHub <noreply@github.com>2023-03-27 11:58:42 +0100
commit2f20fe8869d7a1df7c9b7a9e2939c1a20533c6dc (patch)
tree30ce5a7c31f5463e8d143d4f90468e35b82d1f7f /tests
parent9bfad74dc029f163f296d09df56a42b97a38f4c1 (diff)
parente25f9a9bb85e062aeff3d0713e35dd1ad31962d3 (diff)
downloadlibgit2-2f20fe8869d7a1df7c9b7a9e2939c1a20533c6dc.tar.gz
Merge pull request #6505 from libgit2/ethomson/extension_madness
repo: don't allow repeated extensions
Diffstat (limited to 'tests')
-rw-r--r--tests/libgit2/core/opts.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/tests/libgit2/core/opts.c b/tests/libgit2/core/opts.c
index 486ff58c6..1aa095adf 100644
--- a/tests/libgit2/core/opts.c
+++ b/tests/libgit2/core/opts.c
@@ -50,9 +50,9 @@ void test_core_opts__extensions_add(void)
cl_git_pass(git_libgit2_opts(GIT_OPT_GET_EXTENSIONS, &out));
cl_assert_equal_sz(out.count, 3);
- cl_assert_equal_s("noop", out.strings[0]);
- cl_assert_equal_s("objectformat", out.strings[1]);
- cl_assert_equal_s("foo", out.strings[2]);
+ cl_assert_equal_s("foo", out.strings[0]);
+ cl_assert_equal_s("noop", out.strings[1]);
+ cl_assert_equal_s("objectformat", out.strings[2]);
git_strarray_dispose(&out);
}
@@ -66,9 +66,26 @@ void test_core_opts__extensions_remove(void)
cl_git_pass(git_libgit2_opts(GIT_OPT_GET_EXTENSIONS, &out));
cl_assert_equal_sz(out.count, 3);
- cl_assert_equal_s("objectformat", out.strings[0]);
- cl_assert_equal_s("bar", out.strings[1]);
- cl_assert_equal_s("baz", out.strings[2]);
+ cl_assert_equal_s("bar", out.strings[0]);
+ cl_assert_equal_s("baz", out.strings[1]);
+ cl_assert_equal_s("objectformat", out.strings[2]);
+
+ git_strarray_dispose(&out);
+}
+
+void test_core_opts__extensions_uniq(void)
+{
+ const char *in[] = { "foo", "noop", "bar", "bar", "foo", "objectformat" };
+ git_strarray out = { 0 };
+
+ cl_git_pass(git_libgit2_opts(GIT_OPT_SET_EXTENSIONS, in, ARRAY_SIZE(in)));
+ cl_git_pass(git_libgit2_opts(GIT_OPT_GET_EXTENSIONS, &out));
+
+ cl_assert_equal_sz(out.count, 4);
+ cl_assert_equal_s("bar", out.strings[0]);
+ cl_assert_equal_s("foo", out.strings[1]);
+ cl_assert_equal_s("noop", out.strings[2]);
+ cl_assert_equal_s("objectformat", out.strings[3]);
git_strarray_dispose(&out);
}