23 #include <freeradius-devel/util/acutest.h>
24 #include <freeradius-devel/util/acutest_helpers.h>
25 #include <freeradius-devel/util/rand.h>
26 #include <freeradius-devel/util/rb.h>
38 return CMP(a->
num, b->num);
44 return CMP(a->
num, b->num);
65 for (i = 0; i <
n; i++) {
77 TEST_MSG(
"Checking sorted[%zu] s = %u vs n = %u", i, sorted[i].num, p->
num);
160 if (
n < 2)
return false;
162 for (i = 2; (q =
n / i) >= i; i++) {
163 if (i * q ==
n)
return false;
168 static uint32_t non_primes[] = { 1, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28,
169 30, 32, 33, 34, 35, 36, 38, 39, 40, 42, 44, 45, 46, 48, 49, 50};
185 for (i = 1; i <= 50; i++) {
#define CMP(_a, _b)
Same as CMP_PREFER_SMALLER use when you don't really care about ordering, you just want an ordering.
uint32_t fr_rand(void)
Return a 32-bit random number.
void * fr_rb_iter_init_preorder(fr_rb_iter_preorder_t *iter, fr_rb_tree_t *tree)
Initialise a pre-order iterator.
void * fr_rb_iter_init_postorder(fr_rb_iter_postorder_t *iter, fr_rb_tree_t *tree)
Initialise a post-order iterator.
void fr_rb_iter_delete_inorder(fr_rb_iter_inorder_t *iter)
Remove the current node from the tree.
void * fr_rb_iter_next_inorder(fr_rb_iter_inorder_t *iter)
Return the next node.
void * fr_rb_iter_next_preorder(fr_rb_iter_preorder_t *iter)
Return the next node.
void * fr_rb_iter_next_postorder(fr_rb_iter_postorder_t *iter)
Return the next node.
void * fr_rb_iter_init_inorder(fr_rb_iter_inorder_t *iter, fr_rb_tree_t *tree)
Initialise an in-order iterator.
#define fr_rb_inline_alloc(_ctx, _type, _field, _data_cmp, _data_free)
Allocs a red black tree.
bool fr_rb_insert(fr_rb_tree_t *tree, void const *data)
Iterator structure for in-order traversal of an rbtree.
Iterator structure for post-order traversal of an rbtree.
Iterator structure for pre-order traversal of an rbtree.
The main red black tree structure.
static int8_t fr_rb_tree_test_cmp(void const *one, void const *two)
static void test_fr_rb_iter_postorder(void)
static uint32_t non_primes[]
static uint32_t pre_output[]
static void test_fr_rb_iter_inorder(void)
static int fr_rb_qsort_cmp(void const *one, void const *two)
static uint32_t pre_post_input[]
static bool is_prime(uint32_t n)
static void test_fr_rb_iter_delete(void)
static void test_fr_rb_iter_preorder(void)
static uint32_t post_output[]