]> git.ozlabs.org Git - ccan/blob - ccan/idtree/test/run-wrap.c
idtree: fix right shift of signed ints
[ccan] / ccan / idtree / test / run-wrap.c
1 #include <ccan/idtree/idtree.c>
2 #include <ccan/tap/tap.h>
3 #include <limits.h>
4
5 int main(int argc, char *argv[])
6 {
7         unsigned int i;
8         struct idtree *idtree;
9
10         plan_tests(6);
11         idtree = idtree_new(NULL);
12
13         ok1(idtree_add_above(idtree, &i, INT_MAX-1, INT_MAX) == INT_MAX-1);
14         ok1(idtree_add_above(idtree, &i, INT_MAX-1, INT_MAX) == INT_MAX);
15         ok1(idtree_add_above(idtree, &i, INT_MAX-1, INT_MAX) == -1);
16
17         ok1(idtree_remove(idtree, INT_MAX-1) == true);
18         ok1(idtree_add_above(idtree, &i, INT_MAX-1, INT_MAX) == INT_MAX-1);
19         ok1(idtree_add_above(idtree, &i, INT_MAX-1, INT_MAX) == -1);
20         talloc_free(idtree);
21         exit(exit_status());
22 }