All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Seyi Kuforiji <kuforiji98@gmail.com>
Cc: git@vger.kernel.org,  ps@pks.im,  phillip.wood@dunelm.org.uk
Subject: Re: [PATCH v2 1/1] t/unit-tests: convert hash to use clar test framework
Date: Wed, 08 Jan 2025 07:35:18 -0800	[thread overview]
Message-ID: <xmqqv7upnwsp.fsf@gitster.g> (raw)
In-Reply-To: <20250108120339.225596-2-kuforiji98@gmail.com> (Seyi Kuforiji's message of "Wed, 8 Jan 2025 13:03:39 +0100")

Seyi Kuforiji <kuforiji98@gmail.com> writes:

>  CLAR_TEST_SUITES += u-ctype
> +CLAR_TEST_SUITES += u-hash
>  CLAR_TEST_SUITES += u-strvec

This is inserted in the middle, presumably because a list without
inherent ordering is by default maintained as a lexicographically
sorted list.

> diff --git a/t/meson.build b/t/meson.build
> index 602ebfe6a2..d722bc7dff 100644
> --- a/t/meson.build
> +++ b/t/meson.build
> @@ -1,6 +1,7 @@
>  clar_test_suites = [
>    'unit-tests/u-ctype.c',
>    'unit-tests/u-strvec.c',
> +  'unit-tests/u-hash.c',
>  ]

So, shouldn't we do the same here?

> diff --git a/t/unit-tests/t-hash.c b/t/unit-tests/u-hash.c
> similarity index 79%
> rename from t/unit-tests/t-hash.c
> rename to t/unit-tests/u-hash.c
> ...
>  #define TEST_HASH_STR(data, expected_sha1, expected_sha256) do { \
>  		const char *expected_hashes[] = { expected_sha1, expected_sha256 }; \
> -		TEST(check_hash_data(data, strlen(data), expected_hashes), \
> -		     "SHA1 and SHA256 (%s) works", #data); \
> -	} while (0)
> +		check_hash_data(data, strlen(data), expected_hashes); \
> +	} while(0)

Unwanted droppage of SP between "while" and "(0)".

>  /* Only works with a literal string, useful when it contains a NUL character. */
>  #define TEST_HASH_LITERAL(literal, expected_sha1, expected_sha256) do { \
>  		const char *expected_hashes[] = { expected_sha1, expected_sha256 }; \
> -		TEST(check_hash_data(literal, (sizeof(literal) - 1), expected_hashes), \
> -		     "SHA1 and SHA256 (%s) works", #literal); \
> -	} while (0)
> +		check_hash_data(literal, (sizeof(literal) - 1), expected_hashes); \
> +	} while(0)

Ditto.

> -int cmd_main(int argc UNUSED, const char **argv UNUSED)
> +void test_hash__empty_string(void)
>  {
> -	struct strbuf aaaaaaaaaa_100000 = STRBUF_INIT;
> -	struct strbuf alphabet_100000 = STRBUF_INIT;
> -
> -	strbuf_addstrings(&aaaaaaaaaa_100000, "aaaaaaaaaa", 100000);
> -	strbuf_addstrings(&alphabet_100000, "abcdefghijklmnopqrstuvwxyz", 100000);
> -
>  	TEST_HASH_STR("",
>  		"da39a3ee5e6b4b0d3255bfef95601890afd80709",
>  		"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855");
> +}
> +
> +void test_hash__single_character(void)
> +{
>  	TEST_HASH_STR("a",
>  		"86f7e437faa5a7fce15d1ddcb9eaeaea377667b8",
>  		"ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb");
> +}

OK.

I'll skip the rest as I expect they would be faithful conversions.

Thanks.


  reply	other threads:[~2025-01-08 15:35 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-07  9:19 [PATCH 0/2] t/unit-tests: convert hash tests to use clar Seyi Kuforiji
2025-01-07  9:19 ` [PATCH 1/2] t/unit-tests: match functions signature with trailing code Seyi Kuforiji
2025-01-07 18:16   ` Junio C Hamano
2025-01-07 18:41     ` Junio C Hamano
2025-01-08  6:14     ` Patrick Steinhardt
2025-01-08  8:31       ` Seyi Chamber
2025-01-08 15:27       ` Junio C Hamano
2025-01-08 16:15         ` Patrick Steinhardt
2025-01-07  9:19 ` [PATCH 2/2] t/unit-tests: convert hash to use clar test framework Seyi Kuforiji
2025-01-08 12:03 ` [PATCH v2 0/1] " Seyi Kuforiji
2025-01-08 12:03   ` [PATCH v2 1/1] " Seyi Kuforiji
2025-01-08 15:35     ` Junio C Hamano [this message]
2025-01-09  7:30       ` Seyi Chamber
2025-01-08 15:28   ` [PATCH v2 0/1] " Junio C Hamano
2025-01-09  7:21     ` Seyi Chamber
2025-01-09 14:09   ` [PATCH v3] " Seyi Kuforiji
2025-01-09 15:10     ` Patrick Steinhardt
2025-01-09 16: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=xmqqv7upnwsp.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=kuforiji98@gmail.com \
    --cc=phillip.wood@dunelm.org.uk \
    --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 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.