Junio C Hamano <gitster@xxxxxxxxx> writes: > I forgot to examine the contents of the tests themselves. > ... FYI: taking them all together, here is what I tentatively queued on top of what was posted as v3 before I start doing today's integration cycle. Thanks. ----- >8 ----- Subject: [PATCH] SQUASH??? --- t/unit-tests/t-prio-queue.c | 57 ++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/t/unit-tests/t-prio-queue.c b/t/unit-tests/t-prio-queue.c index 0b826b463e..3014a67ac2 100644 --- a/t/unit-tests/t-prio-queue.c +++ b/t/unit-tests/t-prio-queue.c @@ -22,44 +22,43 @@ static int show(int *v) static int test_prio_queue(int *input, int *result) { struct prio_queue pq = { intcmp }; - int i = 0; + int i, val; - while (*input) { - int *val = input++; + for (i = 0; (val = *input); input++) { void *peek, *get; - switch(*val) { - case GET: - peek = prio_queue_peek(&pq); + switch (val) { + case GET: + peek = prio_queue_peek(&pq); + get = prio_queue_get(&pq); + if (peek != get) + BUG("peek and get results don't match"); + result[i++] = show(get); + break; + case DUMP: + while ((peek = prio_queue_peek(&pq))) { get = prio_queue_get(&pq); if (peek != get) BUG("peek and get results don't match"); result[i++] = show(get); - break; - case DUMP: - while ((peek = prio_queue_peek(&pq))) { - get = prio_queue_get(&pq); - if (peek != get) - BUG("peek and get results don't match"); - result[i++] = show(get); - } - break; - case STACK: - pq.compare = NULL; - break; - case REVERSE: - prio_queue_reverse(&pq); - break; - default: - prio_queue_put(&pq, val); - break; + } + break; + case STACK: + pq.compare = NULL; + break; + case REVERSE: + prio_queue_reverse(&pq); + break; + default: + prio_queue_put(&pq, input); + break; } } clear_prio_queue(&pq); return 0; } -#define BASIC_INPUT 1, 2, 3, 4, 5, 5, DUMP -#define BASIC_EXPECTED 1, 2, 3, 4, 5, 5 +#define BASIC_INPUT 2, 6, 3, 10, 9, 5, 7, 4, 5, 8, 1, DUMP +#define BASIC_EXPECTED 1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 10 #define MIXED_PUT_GET_INPUT 6, 2, 4, GET, 5, 3, GET, GET, 1, DUMP #define MIXED_PUT_GET_EXPECTED 2, 3, 4, 1, 5, 6 @@ -67,8 +66,8 @@ static int test_prio_queue(int *input, int *result) #define EMPTY_QUEUE_INPUT 1, 2, GET, GET, GET, 1, 2, GET, GET, GET #define EMPTY_QUEUE_EXPECTED 1, 2, MISSING, 1, 2, MISSING -#define STACK_INPUT STACK, 1, 5, 4, 6, 2, 3, DUMP -#define STACK_EXPECTED 3, 2, 6, 4, 5, 1 +#define STACK_INPUT STACK, 8, 1, 5, 4, 6, 2, 3, DUMP +#define STACK_EXPECTED 3, 2, 6, 4, 5, 1, 8 #define REVERSE_STACK_INPUT STACK, 1, 2, 3, 4, 5, 6, REVERSE, DUMP #define REVERSE_STACK_EXPECTED 1, 2, 3, 4, 5, 6 @@ -76,7 +75,7 @@ static int test_prio_queue(int *input, int *result) #define TEST_INPUT(INPUT, EXPECTED, name) \ static void test_##name(void) \ { \ - int input[] = {INPUT}; \ + int input[] = {INPUT, 0}; \ int expected[] = {EXPECTED}; \ int result[ARRAY_SIZE(expected)]; \ test_prio_queue(input, result); \ -- 2.43.0-367-g186b115d30