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
Attachment:
signature.asc
Description: PGP signature