diff --git a/nest/a-set_test.c b/nest/a-set_test.c new file mode 100644 index 00000000..0c8d0a1a --- /dev/null +++ b/nest/a-set_test.c @@ -0,0 +1,139 @@ +/* + * BIRD -- Set/Community-list Operations Tests + * + * (c) 2015 CZ.NIC z.s.p.o. + * + * Can be freely distributed and used under the terms of the GNU GPL. + */ + +#include "test/birdtest.h" +#include "test/bt-utils.h" + +#include "nest/route.h" +#include "nest/attrs.h" +#include "lib/resource.h" + +#define SET_SIZE 10 +static struct adata *set_sequence; /* <0; SET_SIZE) */ +static struct adata *set_sequence_same; /* <0; SET_SIZE) */ +static struct adata *set_sequence_higher; /* length = 4 * SET_SIZE_FOR_FORMAT_OUTPUT; /* dirty */ + bt_assert(int_set_format(set_sequence, 0, 0, buf, BUFFER_SIZE) == 0); + bt_assert(strcmp(buf, "0.0.0.9 0.0.0.8 0.0.0.7 0.0.0.6 0.0.0.5 0.0.0.4 0.0.0.3 0.0.0.2 0.0.0.1 0.0.0.0") == 0); + + bzero(buf, BUFFER_SIZE); + bt_assert(int_set_format(set_sequence, 0, 2, buf, BUFFER_SIZE) == 0); + bt_assert(strcmp(buf, "0.0.0.7 0.0.0.6 0.0.0.5 0.0.0.4 0.0.0.3 0.0.0.2 0.0.0.1 0.0.0.0") == 0); + + bzero(buf, BUFFER_SIZE); + bt_assert(int_set_format(set_sequence, 1, 0, buf, BUFFER_SIZE) == 0); + bt_assert(strcmp(buf, "(0,9) (0,8) (0,7) (0,6) (0,5) (0,4) (0,3) (0,2) (0,1) (0,0)") == 0); + + rfree(lp); + return BT_SUCCESS; +} + + +int +main(int argc, char *argv[]) +{ + bt_init(argc, argv); + + bt_test_suite(t_set_int_contains, "Testing sets of integers: contains, get"); + bt_test_suite(t_set_int_format, "Testing sets of integers: format"); + bt_test_suite(t_set_int_union, "Testing sets of integers: union"); + + return bt_end(); +}