Ghanshyam Thakkar <shyamthakkar001@xxxxxxxxx> writes: > 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. > +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). > + 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(); > +}