2 Copyright 2020 Google LLC
4 Use of this source code is governed by a BSD-style
5 license that can be found in the LICENSE file or at
6 https://developers.google.com/open-source/licenses/bsd
13 #include "test_framework.h"
14 #include "reftable-tests.h"
16 static int test_compare(const void *a
, const void *b
)
18 return (char *)a
- (char *)b
;
25 static void check_increasing(void *arg
, void *key
)
27 struct curry
*c
= arg
;
29 EXPECT(test_compare(c
->last
, key
) < 0);
34 static void test_tree(void)
36 struct tree_node
*root
= NULL
;
38 void *values
[11] = { NULL
};
39 struct tree_node
*nodes
[11] = { NULL
};
41 struct curry c
= { NULL
};
43 nodes
[i
] = tree_search(values
+ i
, &root
, &test_compare
, 1);
47 for (i
= 1; i
< ARRAY_SIZE(nodes
); i
++) {
48 EXPECT(values
+ i
== nodes
[i
]->key
);
50 tree_search(values
+ i
, &root
, &test_compare
, 0));
53 infix_walk(root
, check_increasing
, &c
);
57 int tree_test_main(int argc
, const char *argv
[])