From: Karthik Nayak <karthik.188@gmail.com>
To: Chandra Pratap <chandrapratap3519@gmail.com>, git@vger.kernel.org
Cc: karthik188@gmail.com, Patrick Steinhardt <ps@pks.im>,
Christian Couder <chriscool@tuxfamily.org>
Subject: Re: [PATCH 06/11] t-reftable-record: add ref tests for reftable_record_is_deletion()
Date: Tue, 25 Jun 2024 04:14:49 -0500 [thread overview]
Message-ID: <CAOLa=ZSKcpOVv8wcDpe8mgtu53aWrCKG+scMqNix_BfBrT=KkA@mail.gmail.com> (raw)
In-Reply-To: <20240621115708.3626-7-chandrapratap3519@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3115 bytes --]
Chandra Pratap <chandrapratap3519@gmail.com> writes:
> reftable_record_is_deletion() is a function defined in
> reftable/record.{c, h} that determines whether a record is of
> type deletion or not. In the current testing setup, this function
> is left untested for all the four record types (ref, log, obj, index).
>
> Add tests for this function in the case of ref records.
>
> 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-record.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/t/unit-tests/t-reftable-record.c b/t/unit-tests/t-reftable-record.c
> index 1f9c830631..cbc2ce93b2 100644
> --- a/t/unit-tests/t-reftable-record.c
> +++ b/t/unit-tests/t-reftable-record.c
> @@ -108,6 +108,7 @@ static void test_reftable_ref_record_roundtrip(void)
> for (int i = REFTABLE_REF_DELETION; i < REFTABLE_NR_REF_VALUETYPES; i++) {
> struct reftable_record in = {
> .type = BLOCK_TYPE_REF,
> + .u.ref.value_type = i,
> };
> struct reftable_record out = { .type = BLOCK_TYPE_REF };
> struct strbuf key = STRBUF_INIT;
> @@ -121,15 +122,19 @@ static void test_reftable_ref_record_roundtrip(void)
> in.u.ref.value_type = i;
> switch (i) {
> case REFTABLE_REF_DELETION:
> + check(reftable_record_is_deletion(&in));
> break;
> case REFTABLE_REF_VAL1:
> + check(!reftable_record_is_deletion(&in));
> set_hash(in.u.ref.value.val1, 1);
> break;
> case REFTABLE_REF_VAL2:
> + check(!reftable_record_is_deletion(&in));
> set_hash(in.u.ref.value.val2.value, 1);
> set_hash(in.u.ref.value.val2.target_value, 2);
> break;
> case REFTABLE_REF_SYMREF:
> + check(!reftable_record_is_deletion(&in));
> in.u.ref.value.symref = xstrdup("target");
> break;
> }
I think it might be easier to follow if we just move this outside the
switch, perhaps something like:
diff --git a/t/unit-tests/t-reftable-record.c b/t/unit-tests/t-reftable-record.c
index d480cc438a..5cb910f6be 100644
--- a/t/unit-tests/t-reftable-record.c
+++ b/t/unit-tests/t-reftable-record.c
@@ -139,19 +139,15 @@ static void test_reftable_ref_record_roundtrip(void)
in.u.ref.value_type = i;
switch (i) {
case REFTABLE_REF_DELETION:
- check(reftable_record_is_deletion(&in));
break;
case REFTABLE_REF_VAL1:
- check(!reftable_record_is_deletion(&in));
set_hash(in.u.ref.value.val1, 1);
break;
case REFTABLE_REF_VAL2:
- check(!reftable_record_is_deletion(&in));
set_hash(in.u.ref.value.val2.value, 1);
set_hash(in.u.ref.value.val2.target_value, 2);
break;
case REFTABLE_REF_SYMREF:
- check(!reftable_record_is_deletion(&in));
in.u.ref.value.symref = xstrdup("target");
break;
}
@@ -159,6 +155,7 @@ static void test_reftable_ref_record_roundtrip(void)
test_copy(&in);
+ check_int(reftable_record_is_deletion(&in), ==, i == REFTABLE_REF_DELETION);
check_int(reftable_record_val_type(&in), ==, i);
reftable_record_key(&in, &key);
> --
> 2.45.2.404.g9eaef5822c
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 690 bytes --]
next prev parent reply other threads:[~2024-06-25 9:14 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-21 5:46 [GSoC][PATCH 0/11] t: port reftable/record_test.c to the unit testing framework Chandra Pratap
2024-06-21 5:47 ` [PATCH 01/11] t: move " Chandra Pratap
2024-06-21 5:47 ` [PATCH 02/11] t-reftable-record: add reftable_record_cmp() tests for log records Chandra Pratap
2024-06-21 5:47 ` [PATCH 03/11] t-reftable-record: add comparison tests for ref records Chandra Pratap
2024-06-21 5:47 ` [PATCH 04/11] t-reftable-record: add comparison tests for index records Chandra Pratap
2024-06-21 5:47 ` [PATCH 05/11] t-reftable-record: add comparison tests for obj records Chandra Pratap
2024-06-21 5:47 ` [PATCH 06/11] t-reftable-record: add reftable_record_is_deletion() test for ref records Chandra Pratap
2024-06-21 5:47 ` [PATCH 07/11] t-reftable-record: add reftable_record_is_deletion() test for log records Chandra Pratap
2024-06-21 5:47 ` [PATCH 08/11] t-reftable-record: add reftable_record_is_deletion() test for obj records Chandra Pratap
2024-06-21 5:47 ` [PATCH 09/11] t-reftable-record: add reftable_record_is_deletion() test for index records Chandra Pratap
2024-06-21 5:47 ` [PATCH 10/11] t-reftable-record: add tests for reftable_ref_record_compare_name() Chandra Pratap
2024-06-21 5:47 ` [PATCH 11/11] t-reftable-record: add tests for reftable_log_record_compare_key() Chandra Pratap
2024-06-21 6:09 ` [GSoC][PATCH 0/11] t: port reftable/record_test.c to the unit testing framework Chandra Pratap
2024-06-21 11:50 ` Chandra Pratap
2024-06-21 11:50 ` [PATCH 01/11] t: move " Chandra Pratap
2024-06-25 8:26 ` Karthik Nayak
2024-06-25 13:12 ` Chandra Pratap
2024-06-26 11:52 ` Karthik Nayak
2024-06-26 12:57 ` Chandra Pratap
2024-06-26 14:24 ` Han-Wen Nienhuys
2024-06-21 11:50 ` [PATCH 02/11] t-reftable-record: add reftable_record_cmp() tests for log records Chandra Pratap
2024-06-25 8:36 ` Karthik Nayak
2024-06-21 11:50 ` [PATCH 03/11] t-reftable-record: add comparison tests for ref records Chandra Pratap
2024-06-21 11:50 ` [PATCH 04/11] t-reftable-record: add comparison tests for index records Chandra Pratap
2024-06-21 11:51 ` [PATCH 05/11] t-reftable-record: add comparison tests for obj records Chandra Pratap
2024-06-21 11:51 ` [PATCH 06/11] t-reftable-record: add ref tests for reftable_record_is_deletion() Chandra Pratap
2024-06-25 9:14 ` Karthik Nayak [this message]
2024-06-25 17:31 ` Eric Sunshine
2024-06-26 11:35 ` Karthik Nayak
2024-06-21 11:51 ` [PATCH 07/11] t-reftable-record: add log " Chandra Pratap
2024-06-21 11:51 ` [PATCH 08/11] t-reftable-record: add obj " Chandra Pratap
2024-06-21 11:51 ` [PATCH 09/11] t-reftable-record: add index " Chandra Pratap
2024-06-25 9:19 ` Karthik Nayak
2024-06-25 14:11 ` Chandra Pratap
2024-06-26 11:59 ` Karthik Nayak
2024-06-21 11:51 ` [PATCH 10/11] t-reftable-record: add tests for reftable_ref_record_compare_name() Chandra Pratap
2024-06-25 9:26 ` Karthik Nayak
2024-06-25 13:45 ` Chandra Pratap
2024-06-21 11:51 ` [PATCH 11/11] t-reftable-record: add tests for reftable_log_record_compare_key() Chandra Pratap
2024-06-25 9:26 ` Karthik Nayak
2024-06-25 9:32 ` [GSoC][PATCH 0/11] t: port reftable/record_test.c to the unit testing framework Karthik Nayak
2024-06-28 6:19 ` [GSoC][PATCH v3 " Chandra Pratap
2024-06-28 6:19 ` [PATCH v3 01/11] t: move " Chandra Pratap
2024-06-30 16:24 ` Karthik Nayak
2024-06-28 6:19 ` [PATCH v3 02/11] t-reftable-record: add reftable_record_cmp() tests for log records Chandra Pratap
2024-06-28 6:19 ` [PATCH v3 03/11] t-reftable-record: add comparison tests for ref records Chandra Pratap
2024-06-28 6:19 ` [PATCH v3 04/11] t-reftable-record: add comparison tests for index records Chandra Pratap
2024-06-28 6:19 ` [PATCH v3 05/11] t-reftable-record: add comparison tests for obj records Chandra Pratap
2024-06-28 6:19 ` [PATCH v3 06/11] t-reftable-record: add ref tests for reftable_record_is_deletion() Chandra Pratap
2024-06-28 6:19 ` [PATCH v3 07/11] t-reftable-record: add log " Chandra Pratap
2024-06-28 6:19 ` [PATCH v3 08/11] t-reftable-record: add obj " Chandra Pratap
2024-06-28 6:19 ` [PATCH v3 09/11] t-reftable-record: add index " Chandra Pratap
2024-06-28 6:19 ` [PATCH v3 10/11] t-reftable-record: add tests for reftable_ref_record_compare_name() Chandra Pratap
2024-06-30 18:59 ` Karthik Nayak
2024-07-01 7:26 ` Chandra Pratap
2024-07-01 9:51 ` Karthik Nayak
2024-07-01 13:17 ` Chandra Pratap
2024-06-28 6:19 ` [PATCH v3 11/11] t-reftable-record: add tests for reftable_log_record_compare_key() Chandra Pratap
2024-06-30 19:11 ` Karthik Nayak
2024-06-30 19:12 ` [GSoC][PATCH v3 0/11] t: port reftable/record_test.c to the unit testing framework Karthik Nayak
2024-07-02 7:22 ` [GSoC][PATCH v4 0/11] t: port reftable/record_test.c to the unit testing framework framework Chandra Pratap
2024-07-02 7:22 ` [PATCH v4 01/11] t: move reftable/record_test.c to the unit testing framework Chandra Pratap
2024-07-02 7:22 ` [PATCH v4 02/11] t-reftable-record: add reftable_record_cmp() tests for log records Chandra Pratap
2024-07-02 7:22 ` [PATCH v4 03/11] t-reftable-record: add comparison tests for ref records Chandra Pratap
2024-07-02 7:22 ` [PATCH v4 04/11] t-reftable-record: add comparison tests for index records Chandra Pratap
2024-07-02 7:22 ` [PATCH v4 05/11] t-reftable-record: add comparison tests for obj records Chandra Pratap
2024-07-02 7:22 ` [PATCH v4 06/11] t-reftable-record: add ref tests for reftable_record_is_deletion() Chandra Pratap
2024-07-02 7:22 ` [PATCH v4 07/11] t-reftable-record: add log " Chandra Pratap
2024-07-02 7:22 ` [PATCH v4 08/11] t-reftable-record: add obj " Chandra Pratap
2024-07-02 7:22 ` [PATCH v4 09/11] t-reftable-record: add index " Chandra Pratap
2024-07-02 7:22 ` [PATCH v4 10/11] t-reftable-record: add tests for reftable_ref_record_compare_name() Chandra Pratap
2024-07-02 7:22 ` [PATCH v4 11/11] t-reftable-record: add tests for reftable_log_record_compare_key() Chandra Pratap
2024-07-02 10:55 ` [GSoC][PATCH v4 0/11] t: port reftable/record_test.c to the unit testing framework framework Karthik Nayak
2024-07-02 15:14 ` 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='CAOLa=ZSKcpOVv8wcDpe8mgtu53aWrCKG+scMqNix_BfBrT=KkA@mail.gmail.com' \
--to=karthik.188@gmail.com \
--cc=chandrapratap3519@gmail.com \
--cc=chriscool@tuxfamily.org \
--cc=git@vger.kernel.org \
--cc=karthik188@gmail.com \
--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).