MCPcopy Index your code
hub / github.com/git/git / test_prio_queue

Function test_prio_queue

t/unit-tests/u-prio-queue.c:23–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21}
22
23static void test_prio_queue(int *input, size_t input_size,
24 int *result, size_t result_size)
25{
26 struct prio_queue pq = { intcmp };
27 size_t j = 0;
28
29 for (size_t i = 0; i < input_size; i++) {
30 void *peek, *get;
31 switch(input[i]) {
32 case GET:
33 peek = prio_queue_peek(&pq);
34 get = prio_queue_get(&pq);
35 cl_assert(peek == get);
36 cl_assert(j < result_size);
37 cl_assert_equal_i(result[j], show(get));
38 j++;
39 break;
40 case DUMP:
41 while ((peek = prio_queue_peek(&pq))) {
42 get = prio_queue_get(&pq);
43 cl_assert(peek == get);
44 cl_assert(j < result_size);
45 cl_assert_equal_i(result[j], show(get));
46 j++;
47 }
48 break;
49 case STACK:
50 pq.compare = NULL;
51 break;
52 case REVERSE:
53 prio_queue_reverse(&pq);
54 break;
55 case REPLACE:
56 peek = prio_queue_peek(&pq);
57 cl_assert(i + 1 < input_size);
58 cl_assert(input[i + 1] >= 0);
59 cl_assert(j < result_size);
60 cl_assert_equal_i(result[j], show(peek));
61 j++;
62 prio_queue_replace(&pq, &input[++i]);
63 break;
64 default:
65 prio_queue_put(&pq, &input[i]);
66 break;
67 }
68 }
69 cl_assert_equal_i(j, result_size);
70 clear_prio_queue(&pq);
71}
72
73#define TEST_INPUT(input, result) \
74 test_prio_queue(input, ARRAY_SIZE(input), result, ARRAY_SIZE(result))

Callers

nothing calls this directly

Calls 7

prio_queue_peekFunction · 0.85
prio_queue_getFunction · 0.85
prio_queue_reverseFunction · 0.85
prio_queue_replaceFunction · 0.85
prio_queue_putFunction · 0.85
clear_prio_queueFunction · 0.85
showFunction · 0.70

Tested by

no test coverage detected