0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 01:31:55 +00:00

Filter: Add long community tests

Based on Pavel Tvrdik's int-test-lc branch.
This commit is contained in:
Ondrej Zajicek (work) 2016-11-09 19:08:25 +01:00
parent 9b0a0ba9e6
commit 101c5a50aa

View File

@ -278,6 +278,71 @@ bt_test_suite(t_extended_community_list, "Testing extended communities and lists
/*
* Testing Long Communities
* ------------------------
*/
function mktrip(int a)
{
return (a, 2*a, 3*a);
}
function t_long_community_list()
lclist ll;
lclist ll2;
{
ll = --- empty ---;
ll = add(ll, (ten, 20, 30));
ll = add(ll, (1000, 2000, 3000));
ll = add(ll, mktrip(100000));
print "LC list (10, 20, 30) (1000, 2000, 3000) (100000, 200000, 300000)";
print ll;
bt_assert(ll.len = 3);
bt_assert(ll = add(add(add(---empty---, (10, 20, 30)), (1000, 2000, 3000)), (100000, 200000, 300000)));
bt_assert(mktrip(1000) ~ ll);
bt_assert(mktrip(100) !~ ll);
bt_assert(ll ~ [(5,10,15), (10,20,30)]);
bt_assert(ll ~ [(10,15..25,*)]);
bt_assert(ll ~ [(ten, *, *)]);
bt_assert(ll !~ [(5,10,15), (10,21,30)]);
bt_assert(ll !~ [(10,21..25,*)]);
bt_assert(ll !~ [(11, *, *)]);
ll2 = filter(ll, [(5..15, *, *), (100000, 500..500000, *)]);
bt_assert(ll2 = add(add(---empty---, (10, 20, 30)), (100000, 200000, 300000)));
ll = --- empty ---;
ll = add(ll, (10, 10, 10));
ll = add(ll, (20, 20, 20));
ll = add(ll, (30, 30, 30));
ll2 = --- empty ---;
ll2 = add(ll2, (20, 20, 20));
ll2 = add(ll2, (30, 30, 30));
ll2 = add(ll2, (40, 40, 40));
print "lclist A (10,20,30): ", ll;
print "lclist B (30,40,50): ", ll2;
print "lclist A union B: ", add(ll, ll2);
bt_assert(add(ll, ll2) = add(add(add(add(---empty---, (10,10,10)), (20,20,20)), (30,30,30)), (40,40,40)));
print "lclist A isect B: ", filter(ll, ll2);
bt_assert(filter(ll, ll2) = add(add(---empty---, (20, 20, 20)), (30, 30, 30)));
print "lclist A \ B: ", delete(ll, ll2);
bt_assert(delete(ll, ll2) = add(---empty---, (10, 10, 10)));
}
bt_test_suite(t_long_community_list, "Testing long communities and lists");
/*
* Testing defined() function
* --------------------------