diff options
author | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2016-11-09 19:08:25 +0100 |
---|---|---|
committer | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2016-11-09 19:09:24 +0100 |
commit | 101c5a50aa9cd46bf4b971586d78d7f9041fb656 (patch) | |
tree | bf88ad99c96a0ee1b40cfe0cc711ce03d4b80d7b | |
parent | 9b0a0ba9e671d9134b93c33ab73ccccb352acafa (diff) |
Filter: Add long community tests
Based on Pavel Tvrdik's int-test-lc branch.
-rw-r--r-- | filter/test.conf | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/filter/test.conf b/filter/test.conf index de3a3113..2ee5817a 100644 --- a/filter/test.conf +++ b/filter/test.conf @@ -279,6 +279,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 * -------------------------- */ |