t / helper / test-prio-queue.con commit push tests: use spaces in interpolated string (253b3d4)
   1#include "test-tool.h"
   2#include "cache.h"
   3#include "prio-queue.h"
   4
   5static int intcmp(const void *va, const void *vb, void *data)
   6{
   7        const int *a = va, *b = vb;
   8        return *a - *b;
   9}
  10
  11static void show(int *v)
  12{
  13        if (!v)
  14                printf("NULL\n");
  15        else
  16                printf("%d\n", *v);
  17        free(v);
  18}
  19
  20int cmd__prio_queue(int argc, const char **argv)
  21{
  22        struct prio_queue pq = { intcmp };
  23
  24        while (*++argv) {
  25                if (!strcmp(*argv, "get"))
  26                        show(prio_queue_get(&pq));
  27                else if (!strcmp(*argv, "dump")) {
  28                        int *v;
  29                        while ((v = prio_queue_get(&pq)))
  30                               show(v);
  31                }
  32                else {
  33                        int *v = malloc(sizeof(*v));
  34                        *v = atoi(*argv);
  35                        prio_queue_put(&pq, v);
  36                }
  37        }
  38
  39        return 0;
  40}