The reftable library comes with self tests, which are exercised as part of the usual end-to-end tests and are designed to observe the end-user visible effects of Git commands. What it exercises, however, is a better match for the unit-testing framework, merged at 8bf6fbd0 (Merge branch 'js/doc-unit-tests', 2023-12-09), which is designed to observe how low level implementation details, at the level of sequences of individual function calls, behave. Hence, port reftable/tree_test.c to the unit testing framework and improve upon the ported test. The first patch in the series is preparatory cleanup, the second patch moves the test to the unit testing framework, and the rest of the patches improve upon the ported test. Mentored-by: Patrick Steinhardt <ps@xxxxxx> Mentored-by: Christian Couder <chriscool@xxxxxxxxxxxxx> Signed-off-by: Chandra Pratap <chandrapratap3519@xxxxxxxxx> --- Changes in v6: - Fix a style issue in a comment introduced in patch 3 CI/PR: https://github.com/gitgitgadget/git/pull/1740 Chandra Pratap(5): reftable: remove unnecessary curly braces in reftable/tree.c t: move reftable/tree_test.c to the unit testing framework t-reftable-tree: split test_tree() into two sub-test t-reftable-tree: add test for non-existent key t-reftable-tree: improve the test for infix_walk() Makefile | 2 +- reftable/reftable-tests.h | 1 - reftable/tree.c | 15 +++------- reftable/tree_test.c | 60 ---------------------- t/helper/test-reftable.c | 1 - t/unit-tests/t-reftable-tree.c | 83 +++++++++++++++++++++++++++++++++++++ 6 files changed, 89 insertions(+), 73 deletions(-) Range-diff against v5: 1: 59d5c17d5e ! 1: 501ea6c05d t-reftable-tree: split test_tree() into two sub-test functions @@ t/unit-tests/t-reftable-tree.c: static void check_increasing(void *arg, void *ke size_t i = 1; - struct curry c = { 0 }; - /* pseudo-randomly insert the pointers for elements between - * values[1] and values[10] (included) in the tree. +- /* pseudo-randomly insert the pointers for elements between +- * values[1] and values[10] (included) in the tree. ++ /* Pseudo-randomly insert the pointers for elements between ++ * values[1] and values[10] (inclusive) in the tree. + */ + do { + nodes[i] = tree_search(&values[i], &root, &t_compare, 1); @@ t/unit-tests/t-reftable-tree.c: static void t_tree(void) check_pointer_eq(nodes[i], tree_search(&values[i], &root, &t_compare, 0)); } 2: c1ce79916b = 2: ecadc1833e t-reftable-tree: add test for non-existent key 3: d1a5ced526 = 3: cda7509281 t-reftable-tree: improve the test for infix_walk()