test: improve badname verification test The name of the `write_invalid_filename` function suggests that we _want_ to write an invalid filename. Rename the function to show that we expect to _fail_ to write the invalid filename.
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 44 45 46 47 48 49
diff --git a/tests/index/tests.c b/tests/index/tests.c
index 1164cba..5193194 100644
--- a/tests/index/tests.c
+++ b/tests/index/tests.c
@@ -599,7 +599,7 @@ static void replace_char(char *str, char in, char out)
*c = out;
}
-static void write_invalid_filename(git_repository *repo, const char *fn_orig)
+static void assert_write_fails(git_repository *repo, const char *fn_orig)
{
git_index *index;
git_oid expected;
@@ -672,13 +672,13 @@ void test_index_tests__write_invalid_filename(void)
cl_git_pass(git_repository_init(&repo, "./invalid", 0));
- write_invalid_filename(repo, ".git/hello");
- write_invalid_filename(repo, ".GIT/hello");
- write_invalid_filename(repo, ".GiT/hello");
- write_invalid_filename(repo, "./.git/hello");
- write_invalid_filename(repo, "./foo");
- write_invalid_filename(repo, "./bar");
- write_invalid_filename(repo, "foo/../bar");
+ assert_write_fails(repo, ".git/hello");
+ assert_write_fails(repo, ".GIT/hello");
+ assert_write_fails(repo, ".GiT/hello");
+ assert_write_fails(repo, "./.git/hello");
+ assert_write_fails(repo, "./foo");
+ assert_write_fails(repo, "./bar");
+ assert_write_fails(repo, "foo/../bar");
git_repository_free(repo);
@@ -696,10 +696,10 @@ void test_index_tests__honors_protect_filesystems(void)
cl_repo_set_bool(repo, "core.protectHFS", true);
cl_repo_set_bool(repo, "core.protectNTFS", true);
- write_invalid_filename(repo, ".git./hello");
- write_invalid_filename(repo, ".git\xe2\x80\xad/hello");
- write_invalid_filename(repo, "git~1/hello");
- write_invalid_filename(repo, ".git\xe2\x81\xaf/hello");
+ assert_write_fails(repo, ".git./hello");
+ assert_write_fails(repo, ".git\xe2\x80\xad/hello");
+ assert_write_fails(repo, "git~1/hello");
+ assert_write_fails(repo, ".git\xe2\x81\xaf/hello");
git_repository_free(repo);