Subject: Re: [GSoC][PATCH 6/6] t-reftable-pq: add tests for merged_iter_pqueue_top()

From: Patrick Steinhardt <[email-masked]>
Date: Thu, 6 Jun 2024 13:49:04 +0200

On Thu, Jun 06, 2024 at 01:10:50PM +0530, Chandra Pratap wrote:
> @@ -59,7 +66,6 @@ static void test_pq_record(void)
>  	merged_iter_pqueue_release(&pq);
>  }
>  
> -
>  static void test_pq_index(void)
>  {
>  	struct merged_iter_pqueue pq = { 0 };

Ah, you drop the newline here. This should probably be part of the
preceding commit.

> @@ -98,10 +106,49 @@ static void test_pq_index(void)
>  	merged_iter_pqueue_release(&pq);
>  }
>  
> +static void test_merged_iter_pqueue_top(void)
> +{
> +	struct merged_iter_pqueue pq = { 0 };
> +	struct reftable_record recs[14];
> +	size_t N = ARRAY_SIZE(recs), i;
> +
> +	for (i = 0; i < N; i++) {
> +		reftable_record_init(&recs[i], BLOCK_TYPE_REF);
> +		recs[i].u.ref.refname = xstrdup("refs/heads/master");
> +	}
> +
> +	for (i = 0; i < N; i++) {
> +		struct pq_entry e = {
> +			.rec = &recs[i],
> +			.index = i,
> +		};
> +
> +		merged_iter_pqueue_add(&pq, &e);
> +		merged_iter_pqueue_check(&pq);
> +	}
> +
> +	while (!merged_iter_pqueue_is_empty(pq)) {
> +		struct pq_entry top = merged_iter_pqueue_top(pq);
> +		struct pq_entry e = merged_iter_pqueue_remove(&pq);
> +
> +		merged_iter_pqueue_check(&pq);
> +		check(pq_entry_equal(&top, &e));

Do we also want to check that `top` is equal to the expected entry in
`recs`?

Patrick