diff options
| author | Junio C Hamano <gitster@pobox.com> | 2018-11-18 18:23:52 +0900 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2018-11-18 18:23:52 +0900 |
| commit | 62ca33e02a4ea93dd59538ac986a082430253b27 (patch) | |
| tree | b5f5af9c87a64536f0e7ada9e0066e4f5d29af4e /t/helper/test-prio-queue.c | |
| parent | d166e6afe5f257217836ef24a73764eba390c58d (diff) | |
| parent | 561b583749b7428f1790f03164d0d0e75be71d7b (diff) | |
| download | git-62ca33e02a4ea93dd59538ac986a082430253b27.tar.gz | |
Merge branch 'ds/reachable-topo-order'
The revision walker machinery learned to take advantage of the
commit generation numbers stored in the commit-graph file.
* ds/reachable-topo-order:
t6012: make rev-list tests more interesting
revision.c: generation-based topo-order algorithm
commit/revisions: bookkeeping before refactoring
revision.c: begin refactoring --topo-order logic
test-reach: add rev-list tests
test-reach: add run_three_modes method
prio-queue: add 'peek' operation
Diffstat (limited to 't/helper/test-prio-queue.c')
| -rw-r--r-- | t/helper/test-prio-queue.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/t/helper/test-prio-queue.c b/t/helper/test-prio-queue.c index 9807b649b1..5bc9c46ea5 100644 --- a/t/helper/test-prio-queue.c +++ b/t/helper/test-prio-queue.c @@ -22,14 +22,24 @@ int cmd__prio_queue(int argc, const char **argv) struct prio_queue pq = { intcmp }; while (*++argv) { - if (!strcmp(*argv, "get")) - show(prio_queue_get(&pq)); - else if (!strcmp(*argv, "dump")) { - int *v; - while ((v = prio_queue_get(&pq))) - show(v); - } - else { + if (!strcmp(*argv, "get")) { + void *peek = prio_queue_peek(&pq); + void *get = prio_queue_get(&pq); + if (peek != get) + BUG("peek and get results do not match"); + show(get); + } else if (!strcmp(*argv, "dump")) { + void *peek; + void *get; + while ((peek = prio_queue_peek(&pq))) { + get = prio_queue_get(&pq); + if (peek != get) + BUG("peek and get results do not match"); + show(get); + } + } else if (!strcmp(*argv, "stack")) { + pq.compare = NULL; + } else { int *v = malloc(sizeof(*v)); *v = atoi(*argv); prio_queue_put(&pq, v); |
