All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "René Scharfe" <l.s.r@web.de>
Cc: Git List <git@vger.kernel.org>,
	 Chandra Pratap <chandrapratap3519@gmail.com>
Subject: Re: [PATCH 1/2] t-prio-queue: shorten array index message
Date: Mon, 18 Mar 2024 09:25:48 -0700	[thread overview]
Message-ID: <xmqqa5mvjylv.fsf@gitster.g> (raw)
In-Reply-To: <197f5ac9-7257-4caa-aa9e-041016c787f7@web.de> ("René Scharfe"'s message of "Sat, 16 Mar 2024 21:45:51 +0100")

René Scharfe <l.s.r@web.de> writes:

> If we get an unexpected result, the prio-queue unit test reports it like
> this:
>
>  # check "result[j++] == show(get)" failed at t/unit-tests/t-prio-queue.c:43
>  #    left: 5
>  #   right: 1
>  # failed at result[] index 0
>
> That last line repeats "failed" and "result" from the first line.
> Shorten it to resemble a similar one in t-ctype and also remove the
> incrementation from the first line to avoid possible distractions from
> the message of which comparison went wrong where:
>
>  # check "result[j] == show(get)" failed at t/unit-tests/t-prio-queue.c:43
>  #    left: 5
>  #   right: 1
>  #       j: 0

Very nice touch, especially the removal of ++ from the message ;-).

> Signed-off-by: René Scharfe <l.s.r@web.de>
> ---
>  t/unit-tests/t-prio-queue.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/t/unit-tests/t-prio-queue.c b/t/unit-tests/t-prio-queue.c
> index d78b002f9e..616d0fc86f 100644
> --- a/t/unit-tests/t-prio-queue.c
> +++ b/t/unit-tests/t-prio-queue.c
> @@ -31,16 +31,18 @@ static void test_prio_queue(int *input, int *result, size_t input_size)
>  			get = prio_queue_get(&pq);
>  			if (!check(peek == get))
>  				return;
> -			if(!check_int(result[j++], ==, show(get)))
> -				test_msg("failed at result[] index %d", j-1);
> +			if (!check_int(result[j], ==, show(get)))
> +				test_msg("      j: %d", j);
> +			j++;
>  			break;
>  		case DUMP:
>  			while ((peek = prio_queue_peek(&pq))) {
>  				get = prio_queue_get(&pq);
>  				if (!check(peek == get))
>  					return;
> -				if(!check_int(result[j++], ==, show(get)))
> -					test_msg("failed at result[] index %d", j-1);
> +				if (!check_int(result[j], ==, show(get)))
> +					test_msg("      j: %d", j);
> +				j++;
>  			}
>  			break;
>  		case STACK:
> --
> 2.44.0

      parent reply	other threads:[~2024-03-18 16:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-16 20:45 [PATCH 1/2] t-prio-queue: shorten array index message René Scharfe
2024-03-16 21:09 ` [PATCH 2/2] t-prio-queue: check result array bounds René Scharfe
2024-03-18 16:25 ` Junio C Hamano [this message]

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=xmqqa5mvjylv.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=chandrapratap3519@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=l.s.r@web.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.