]>
git.ipfire.org Git - thirdparty/git.git/blob - t/helper/test-prio-queue.c
2 #include "prio-queue.h"
4 static int intcmp(const void *va
, const void *vb
, void *data UNUSED
)
6 const int *a
= va
, *b
= vb
;
10 static void show(int *v
)
19 int cmd__prio_queue(int argc UNUSED
, const char **argv
)
21 struct prio_queue pq
= { intcmp
};
24 if (!strcmp(*argv
, "get")) {
25 void *peek
= prio_queue_peek(&pq
);
26 void *get
= prio_queue_get(&pq
);
28 BUG("peek and get results do not match");
30 } else if (!strcmp(*argv
, "dump")) {
33 while ((peek
= prio_queue_peek(&pq
))) {
34 get
= prio_queue_get(&pq
);
36 BUG("peek and get results do not match");
39 } else if (!strcmp(*argv
, "stack")) {
42 int *v
= xmalloc(sizeof(*v
));
44 prio_queue_put(&pq
, v
);
48 clear_prio_queue(&pq
);