Re: [PATCH v2 6/6] t-reftable-stack: add test for stack iterators
On Fri, Aug 23, 2024 at 05:18:51PM +0530, Chandra Pratap wrote:
Show 40 quoted lines
> diff --git a/t/unit-tests/t-reftable-stack.c b/t/unit-tests/t-reftable-stack.c
> index 51339a9939..5b1ecacd70 100644
> --- a/t/unit-tests/t-reftable-stack.c
> +++ b/t/unit-tests/t-reftable-stack.c
> @@ -550,6 +550,85 @@ static void t_reftable_stack_add(void)
> clear_dir(dir);
> }
>
> +static void t_reftable_stack_iterator(void)
> +{
> + struct reftable_write_options opts = { 0 };
> + struct reftable_stack *st = NULL;
> + char *dir = get_tmp_dir(__LINE__);
> + struct reftable_ref_record refs[10] = { 0 };
> + struct reftable_log_record logs[10] = { 0 };
> + struct reftable_iterator it = { 0 };
> + size_t N = ARRAY_SIZE(refs), i;
> + int err;
> +
> + err = reftable_new_stack(&st, dir, &opts);
> + check(!err);
> +
> + for (i = 0; i < N; i++) {
> + refs[i].refname = xstrfmt("branch%02"PRIuMAX, (uintmax_t)i);
> + refs[i].update_index = i + 1;
> + refs[i].value_type = REFTABLE_REF_VAL1;
> + set_test_hash(refs[i].value.val1, i);
> +
> + logs[i].refname = xstrfmt("branch%02"PRIuMAX, (uintmax_t)i);
> + logs[i].update_index = i + 1;
> + logs[i].value_type = REFTABLE_LOG_UPDATE;
> + logs[i].value.update.email = xstrdup("johndoe@invalid");
> + logs[i].value.update.message = xstrdup("commit\n");
> + set_test_hash(logs[i].value.update.new_hash, i);
> + }
> +
> + for (i = 0; i < N; i++) {
> + err = reftable_stack_add(st, &write_test_ref, &refs[i]);
> + check(!err);
> + }Nit: you re-add the ampersands before the function pointers here, which
basically reintroduces the pattern you got rid of in the second patch.
Patrick