]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t: improve the test-case for parse_names()
authorChandra Pratap <chandrapratap3519@gmail.com>
Wed, 29 May 2024 16:59:31 +0000 (22:29 +0530)
committerJunio C Hamano <gitster@pobox.com>
Thu, 30 May 2024 14:30:10 +0000 (07:30 -0700)
In the existing test-case for parse_names(), the fact that empty
lines should be ignored is not obvious because the empty line is
immediately followed by end-of-string. This can be mistaken as the
empty line getting replaced by NULL. Improve this by adding a
non-empty line after the empty one to demonstrate the intended behavior.

Mentored-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/unit-tests/t-reftable-basics.c

index 3c08218257d175c322787fb159cc890ae757bc3f..529049af128ab5d6bfc359380e3938ef0a12bcfc 100644 (file)
@@ -89,11 +89,13 @@ static void test_parse_names_normal(void)
 
 static void test_parse_names_drop_empty(void)
 {
-       char in[] = "a\n\n";
+       char in[] = "a\n\nb\n";
        char **out = NULL;
        parse_names(in, strlen(in), &out);
        check_str(out[0], "a");
-       check(!out[1]);
+       /* simply '\n' should be dropped as empty string */
+       check_str(out[1], "b");
+       check(!out[2]);
        free_names(out);
 }