Re: [PATCH v2 1/1] t/unit-tests: convert hash to use clar test framework

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 8 Jan 2025 at 16:35, Junio C Hamano <gitster@xxxxxxxxx> wrote:
>
> Seyi Kuforiji <kuforiji98@xxxxxxxxx> 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?
>

Yes, we should. I'll make the necessary adjustment in the next
iteration. Thanks!

> > 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.
>

I'll make the required changes, thank you for pointing them out.

Thanks
Seyi




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux