git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chandra Pratap <chandrapratap3519@gmail.com>
To: git@vger.kernel.org
Cc: Chandra Pratap <chandrapratap3519@gmail.com>,
	Patrick Steinhardt <ps@pks.im>,
	Christian Couder <chriscool@tuxfamily.org>
Subject: [GSoC][PATCH v3 5/5] t: improve the test-case for parse_names()
Date: Wed, 29 May 2024 22:29:31 +0530	[thread overview]
Message-ID: <20240529171439.18271-6-chandrapratap3519@gmail.com> (raw)
In-Reply-To: <20240529171439.18271-1-chandrapratap3519@gmail.com>

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>
---
 t/unit-tests/t-reftable-basics.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/t/unit-tests/t-reftable-basics.c b/t/unit-tests/t-reftable-basics.c
index 3c08218257..529049af12 100644
--- a/t/unit-tests/t-reftable-basics.c
+++ b/t/unit-tests/t-reftable-basics.c
@@ -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);
 }
 
-- 
2.45.GIT


  parent reply	other threads:[~2024-05-29 17:15 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <--in-reply-to=20240528113856.8348-1-chandrapratap3519@gmail.com>
2024-05-29  6:55 ` [GSoC][PATCH v2 0/4] t: port reftable/basics_test.c to the unit testing Chandra Pratap
2024-05-29  6:55   ` [GSoC][PATCH v2 1/4] t: move reftable/basics_test.c to the unit testing framework Chandra Pratap
2024-05-29  6:55   ` [GSoC][PATCH v2 2/4] t: move tests from reftable/stack_test.c to the new unit test Chandra Pratap
2024-05-29  6:55   ` [GSoC][PATCH v2 3/4] t: move tests from reftable/record_test.c " Chandra Pratap
2024-05-29  9:30     ` Patrick Steinhardt
2024-05-29 22:38       ` Junio C Hamano
2024-05-29  6:55   ` [GSoC][PATCH v2 4/4] t: add test for put_be16() and improve test-case for parse_names() Chandra Pratap
2024-05-29  9:30     ` Patrick Steinhardt
2024-05-29  9:29   ` [GSoC][PATCH v2 0/4] t: port reftable/basics_test.c to the unit testing Patrick Steinhardt
2024-05-29 16:59   ` [GSoC][PATCH v3 " Chandra Pratap
2024-05-29 16:59     ` [GSoC][PATCH v3 1/5] t: move reftable/basics_test.c to the unit testing framework Chandra Pratap
2024-05-29 16:59     ` [GSoC][PATCH v3 2/5] t: move tests from reftable/stack_test.c to the new unit test Chandra Pratap
2024-05-29 16:59     ` [GSoC][PATCH v3 3/5] t: move tests from reftable/record_test.c " Chandra Pratap
2024-05-29 16:59     ` [GSoC][PATCH v3 4/5] t: add test for put_be16() Chandra Pratap
2024-05-29 16:59     ` Chandra Pratap [this message]
2024-05-30  4:35     ` [GSoC][PATCH v3 0/4] t: port reftable/basics_test.c to the unit testing Patrick Steinhardt
2024-05-30  7:52       ` Christian Couder
2024-05-30 14:33         ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240529171439.18271-6-chandrapratap3519@gmail.com \
    --to=chandrapratap3519@gmail.com \
    --cc=chriscool@tuxfamily.org \
    --cc=git@vger.kernel.org \
    --cc=ps@pks.im \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).