#include <stdint.h>
#include "acutest.h"
#include "base.h"
#include "serene/rt/impl/pqmh.h"
Go to the source code of this file.
◆ PQ_INT
◆ PQMH_TESTS
Value:
static void test_pqmh_empty()
static void test_pqmh_peek()
static void test_pqmh_grow()
static void test_pqmh_ordering()
Definition at line 27 of file pqmh_tests.h.
27#define PQMH_TESTS(X) \
28 X("pqmh::empty", test_pqmh_empty), X("pqmh::ordering", test_pqmh_ordering), \
29 X("pqmh::peek", test_pqmh_peek), X("pqmh::grow", test_pqmh_grow)
◆ pqmh_int_less()
| bool pqmh_int_less |
( |
srn_context_t * | ctx, |
|
|
const void * | a, |
|
|
const void * | b ) |
|
static |
Definition at line 33 of file pqmh_tests.h.
33 {
35 return (intptr_t)a < (intptr_t)b;
36}
◆ test_pqmh_empty()
Definition at line 43 of file pqmh_tests.h.
43 {
46
50
54
58}
#define RELEASE_CONTEXT(x)
#define SHUTDOWN_ENGINE(mm, engine)
#define MAKE_ENGINE(mm, engine)
#define MAKE_CONTEXT(engine, x)
void pqmh_free(srn_context_t *ctx, pqmh_t *pq)
Release the backing array and reset the queue to empty.
pqmh_t pqmh_make(srn_context_t *ctx, const pqmh_control_t *ctl, size_t initial_cap)
Create an empty queue ordered by ctl, with room for initial_cap elements (a small default is used whe...
void * pqmh_peek(const pqmh_t *pq)
The highest priority element without removing it, or NULL when the queue is empty.
bool pqmh_pop(srn_context_t *ctx, pqmh_t *pq, void **out)
Remove the highest priority element into *out and return true, or return false (leaving *out untouche...
size_t pqmh_len(const pqmh_t *pq)
The number of elements currently in the queue.
static const pqmh_control_t pqmh_int_ctl
◆ test_pqmh_grow()
Definition at line 110 of file pqmh_tests.h.
110 {
113
115 enum { N = 1000 };
116 for (int i = N - 1; i >= 0; i--) {
118 }
120
121 for (int i = 0; i < N; i++) {
122 void *out = nullptr;
125 }
127
131}
void pqmh_push(srn_context_t *ctx, pqmh_t *pq, void *elem)
Insert elem, growing the backing array (doubling) if it is full.
◆ test_pqmh_ordering()
| void test_pqmh_ordering |
( |
| ) |
|
|
static |
Definition at line 61 of file pqmh_tests.h.
61 {
64
66 int in[] = {5, 1, 4, 2, 8, 3, 7, 6, 0, 9};
67 enum { N = (int)(sizeof(in) / sizeof(in[0])) };
68 for (int i = 0; i < N; i++) {
70 }
72
73 for (int i = 0; i < N; i++) {
74 void *out = nullptr;
77 }
79
83}
◆ test_pqmh_peek()
Definition at line 86 of file pqmh_tests.h.
86 {
89
94
97
98 void *out = nullptr;
102
106}
◆ pqmh_int_ctl
Definition at line 38 of file pqmh_tests.h.
static bool pqmh_int_less(srn_context_t *ctx, const void *a, const void *b)