t: improve the test-case for parse_names()

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>

Chandra Pratap committed May 29, 2024 at 22:29 UTC efa8786800618b4119536d2af8f0bbcfa86b1c04
1 file changed +4 -2
t/unit-tests/t-reftable-basics.c
+4 -2
@@ -89,11 +89,13 @@ static void test_parse_names_normal(void)
89
90 static void test_parse_names_drop_empty(void)
91 {
92 - char in[] = "a\n\n";
92 + char in[] = "a\n\nb\n";
93 char **out = NULL;
94 parse_names(in, strlen(in), &out);
95 check_str(out[0], "a");
96 - check(!out[1]);
96 + /* simply '\n' should be dropped as empty string */
97 + check_str(out[1], "b");
98 + check(!out[2]);
99 free_names(out);
100 }
101