git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [GSoC][PATCH v2] t/: migrate helper/test-oidtree.c to unit-tests/t-oidtree.c

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 10, 2024, 16:40 UTC
Message-ID
<xmqqed944uq7.fsf@gitster.g>
In-Reply-To
<20240608165731.29467-1-shyamthakkar001@gmail.com>
Ghanshyam Thakkar <shyamthakkar001@gmail.com> writes:
Show 7 quoted lines
> helper/test-oidtree.c along with t0069-oidtree.sh test the oidtree.h
> library, which is a wrapper around crit-bit tree. Migrate them to
> the unit testing framework for better debugging and runtime
> performance. Along with the migration, add an extra check for
> oidtree_each() test, which showcases how multiple expected matches can
> be given to check_each() helper.
> ...
Use "LAST_ARG_MUST_BE_NULL" here, probably.
Show 10 quoted lines
> +static void check_each(struct oidtree *ot, char *query, ...)
> +{
> +	struct object_id oid;
> +	struct expected_hex_iter hex_iter = { .expected_hexes = STRVEC_INIT,
> ...
> +static void t_each(struct oidtree *ot)
> +{
> +	FILL_TREE(ot, "f", "9", "8", "123", "321", "320", "a", "b", "c", "d", "e");
> +	check_each(ot, "12300", "123", NULL);
> +	check_each(ot, "3211", NULL); /* should not reach callback */

This one truly checks that the callback is never called with this version, which is way better than the previous one (or the original).

Show 11 quoted lines
> +	check_each(ot, "3210", "321", NULL);
> +	check_each(ot, "32100", "321", NULL);
> +	check_each(ot, "32", "320", "321", NULL);
> +}
> +
> +int cmd_main(int argc UNUSED, const char **argv UNUSED)
> +{
> +	TEST(setup(t_contains), "oidtree insert and contains works");
> +	TEST(setup(t_each), "oidtree each works");
> +	return test_done();
> +}
Previous: Ghanshyam ThakkarNext: Ghanshyam Thakkar
Message 9 of 14 in “t/: migrate helper/test-oidtree.c to unit-tests/t-oidtree.c”
  1. Ghanshyam ThakkarJun 5, 2024
  2. Junio C HamanoJun 6, 2024
  3. Ghanshyam ThakkarJun 6, 2024
  4. Christian CouderJun 7, 2024
  5. Christian CouderJun 7, 2024
  6. Christian CouderJun 7, 2024
  7. Junio C HamanoJun 7, 2024
  8. [GSoC][PATCH v2] t/: migrate helper/test-oidtree.c to unit-tests/t-oidtree.cGhanshyam Thakkar, Jun 8, 2024
  9. Junio C HamanoJun 10, 2024
  10. Ghanshyam ThakkarJun 10, 2024
  11. Junio C HamanoJun 10, 2024
  12. Ghanshyam ThakkarJun 10, 2024
  13. Junio C HamanoJun 10, 2024
  14. Ghanshyam ThakkarJun 10, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.