diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2010-12-06 12:52:19 +1030 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2010-12-06 12:52:19 +1030 |
commit | d208258f51ac8c3b355cd31a874dcf93099b3e98 (patch) | |
tree | 15c2d14b877c8fd753cc56e23ea1810f64f2a813 | |
parent | 637ee8aeea62bf2b406ecc53d5491219924d3bfc (diff) |
idtree: add unit test for ids around INT_MAX
This causes a SEGV on my laptop.
-rw-r--r-- | ccan/idtree/test/run-wrap.c | 22 | ||||
-rw-r--r-- | ccan/idtree/test/run.c | 2 |
2 files changed, 23 insertions, 1 deletions
diff --git a/ccan/idtree/test/run-wrap.c b/ccan/idtree/test/run-wrap.c new file mode 100644 index 00000000..6a62323d --- /dev/null +++ b/ccan/idtree/test/run-wrap.c @@ -0,0 +1,22 @@ +#include <ccan/idtree/idtree.c> +#include <ccan/tap/tap.h> +#include <limits.h> + +int main(int argc, char *argv[]) +{ + unsigned int i; + struct idtree *idtree; + + plan_tests(6); + idtree = idtree_new(NULL); + + ok1(idtree_add_above(idtree, &i, INT_MAX-1, INT_MAX) == INT_MAX-1); + ok1(idtree_add_above(idtree, &i, INT_MAX-1, INT_MAX) == INT_MAX); + ok1(idtree_add_above(idtree, &i, INT_MAX-1, INT_MAX) == -1); + + ok1(idtree_remove(idtree, INT_MAX-1) == true); + ok1(idtree_add_above(idtree, &i, INT_MAX-1, INT_MAX) == INT_MAX-1); + ok1(idtree_add_above(idtree, &i, INT_MAX-1, INT_MAX) == -1); + talloc_free(idtree); + exit(exit_status()); +} diff --git a/ccan/idtree/test/run.c b/ccan/idtree/test/run.c index bd12f4c3..99ea2daa 100644 --- a/ccan/idtree/test/run.c +++ b/ccan/idtree/test/run.c @@ -2,7 +2,7 @@ #include <ccan/tap/tap.h> #include <limits.h> -#define ALLOC_MAX 32 +#define ALLOC_MAX (2 * IDTREE_SIZE) int main(int argc, char *argv[]) { |