t/: migrate helper/test-oidtree.c to unit-tests/t-oidtree.c
commited548408723d6e969160279398cc47f88f5700bc
authorGhanshyam Thakkar <shyamthakkar001@gmail.com>
Sat, 8 Jun 2024 16:57:09 +0000 (8 22:27 +0530)
committerJunio C Hamano <gitster@pobox.com>
Wed, 12 Jun 2024 20:33:20 +0000 (12 13:33 -0700)
treee8a9a701b8b2e30377650ffe7b28983b8eb0dbaf
parent1b76f065085811104b5f4adff001956d7e5c5d1c
t/: migrate helper/test-oidtree.c to unit-tests/t-oidtree.c

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.

To achieve this, introduce a new library called 'lib-oid.h'
exclusively for the unit tests to use. It currently mainly includes
utility to generate object_id from an arbitrary hex string
(i.e. '12a' -> '12a0000000000000000000000000000000000000'). This also
handles the hash algo selection based on GIT_TEST_DEFAULT_HASH.
This library will also be helpful when we port other unit tests such
as oid-array, oidset etc.

Helped-by: Junio C Hamano <gitster@pobox.com>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Mentored-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Signed-off-by: Ghanshyam Thakkar <shyamthakkar001@gmail.com>
[jc: small fixlets squashed in]
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Makefile
t/helper/test-oidtree.c [deleted file]
t/helper/test-tool.c
t/helper/test-tool.h
t/t0069-oidtree.sh [deleted file]
t/unit-tests/lib-oid.c [new file with mode: 0644]
t/unit-tests/lib-oid.h [new file with mode: 0644]
t/unit-tests/t-oidtree.c [new file with mode: 0644]