#include #include #include "lily-test.h" #include "tests.h" const char* test_mock_enqueue_dequeue_int() { lily_mock_queue_t *q = lily_queue_create(); /* enqueue A259482, for no particular reason */ lily_enqueue(q, int, 2); lily_enqueue(q, int, 6); lily_enqueue(q, int, 44); int n = 2014; lily_enqueue(q, int, n); lily_dequeue(q, int, &n); if (n != 2) return "dequeued incorrect first value"; lily_dequeue(q, int, &n); /* queue next value after already popping */ lily_enqueue(q, long, 1651377); if (n != 6) return "dequeued incorrect second value"; lily_dequeue(q, int, &n); if (n != 44) return "dequeued incorrect third value"; lily_dequeue(q, int, &n); if (n != 2014) return "dequeued incorrect fourth value"; long m; lily_dequeue(q, long, &m); if (m != 1651377) return "dequeued incorrect fifth value"; lily_queue_destroy(q); return 0; } const char* test_mock_enqueue_dequeue_heterogenous() { lily_mock_queue_t *q = lily_queue_create(); lily_enqueue(q, int, 2); lily_enqueue(q, lily_mock_queue_t *, q); lily_enqueue(q, const char *, "hello, world!"); int n; lily_dequeue(q, int, &n); if (n != 2) return "dequeued incorrect int value"; lily_mock_queue_t *p; lily_dequeue(q, lily_mock_queue_t *, &p); if (p != q) return "dequeued incorrect pointer value"; const char *str; lily_dequeue(q, const char *, &str); if (strcmp(str, "hello, world!") != 0) return "dequeued incorrect string value"; lily_queue_destroy(q); return 0; }