]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
filter/test.conf: Reorder tests
authorPavel Tvrdik <pawel.tvrdik@gmail.com>
Wed, 16 Nov 2016 12:46:08 +0000 (13:46 +0100)
committerPavel Tvrdik <pawel.tvrdik@gmail.com>
Wed, 16 Nov 2016 12:46:43 +0000 (13:46 +0100)
Tests are sorted from trivial tests to more complex tests

filter/test.conf

index a350e0fbce75e22000f1c090689394b38a229741..c926092cb04418a9a802833c8a81099a077b25ac 100644 (file)
@@ -29,357 +29,347 @@ function onef(int a)
 
 
 /*
- *     Testing empty lists/paths
- *     -------------------------
+ *     Testing defined() function
+ *     --------------------------
  */
 
-function t_empty()
+function test_undef(int a)
+int b;
 {
-       bt_assert(+empty+ = +empty+);
-       bt_assert(+empty+ != -empty-);
-       bt_assert(+empty+ != --empty--);
+       if a = 3 then {
+               b = 4;
+               bt_assert(defined(b));
+       }
+       else {
+               bt_assert(!defined(b));
+       }
+}
 
-       bt_assert(-empty- = -empty-);
-       bt_assert(-empty- != --empty--);
+function t_define()
+int i;
+{
+       test_undef(2);
+       test_undef(3);
+       test_undef(2);
 
-       bt_assert(--empty-- = --empty--);
+       bt_assert(defined(1));
+       bt_assert(defined(1.2.3.4));
 }
 
-bt_test_suite(t_empty, "Testing +empty+, -empty-, --empty--");
+bt_test_suite(t_define, "Testing defined() function");
 
 
 
 
 /*
- *     Testing Paths
- *     -------------
+ *      Testing calling functions
+ *      -------------------------
  */
 
-function mkpath(int a; int b)
+function callme(int arg1; int arg2)
+int i;
 {
-       return [= a b 3 2 1 =];
+       case arg1 {
+       1, 42: return 42;
+       else: return arg1 * arg2;
+       }
+
+       return 0;
 }
 
-function t_path()
-bgpmask pm1;
-bgpmask pm2;
-bgppath p2;
+function fifteen()
 {
-       pm1 =  / 4 3 2 1 /;
-       pm2 = [= 4 3 2 1 =];
+       return 15;
+}
 
-       p2 = prepend( + empty +, 1 );
-       p2 = prepend( p2, 2 );
-       p2 = prepend( p2, 3 );
-       p2 = prepend( p2, 4 );
+function t_call_function()
+{
+       bt_assert(fifteen() = 15);
 
-       bt_assert(format(p2) = "(path 4 3 2 1)");
-       bt_assert(p2.len = 4);
-       bt_assert(p2 ~ pm1);
-       bt_assert(p2 ~ pm2);
-       bt_assert(3 ~ p2);
-       bt_assert(p2 ~ [2, 10..20]);
-       bt_assert(p2 ~ [4, 10..20]);
+       bt_assert(callme(1, 2) = 42);
+       bt_assert(callme(42, 2) = 42);
 
-       p2 = prepend(p2, 5);
-       bt_assert(p2 !~ pm1);
-       bt_assert(p2 !~ pm2);
-       bt_assert(10 !~ p2);
-       bt_assert(p2 !~ [8, ten..(2*ten)]);
-       bt_assert(p2 ~  / ? 4 3 2 1 /);
-       bt_assert(p2 ~ [= * 4 3 * 1 =]);
-       bt_assert(p2 ~ [= (3+2) (2*2) 3 2 1 =]);
-       bt_assert(p2 ~ mkpath(5, 4));
+       bt_assert(callme(2, 2) = 4);
+       bt_assert(callme(3, 2) = 6);
+       bt_assert(callme(4, 4) = 16);
+       bt_assert(callme(7, 2) = 14);
+}
 
-       bt_assert(p2.len = 5);
-       bt_assert(p2.first = 5);
-       bt_assert(p2.last = 1);
+bt_test_suite(t_call_function, "Testing calling functions");
 
-       bt_assert(p2.len = 5);
-       bt_assert(delete(p2, 3) = prepend(prepend(prepend(prepend(+empty+, 1), 2), 4), 5));
-       bt_assert(filter(p2, [1..3]) = prepend(prepend(prepend(+empty+, 1), 2), 3));
 
-       pm1 = [= 1 2 * 3 4 5 =];
-       p2 = prepend( + empty +, 5 );
-       p2 = prepend( p2, 4 );
-       p2 = prepend( p2, 3 );
-       p2 = prepend( p2, 3 );
-       p2 = prepend( p2, 2 );
-       p2 = prepend( p2, 1 );
 
-       bt_assert(p2 ~ pm1);
-       bt_assert(delete(p2, 3) = prepend(prepend(prepend(prepend(+empty+, 5), 4), 2), 1));
-       bt_assert(delete(p2, [4..5]) = prepend(prepend(prepend(prepend(+empty+, 3), 3), 2), 1));
+
+/*
+ *     Test including another config file
+ *     ----------------------------------
+ */
+
+function t_include()
+int i;
+{
+  i = 1;
+  include "test.conf.inc";
+  bt_assert(i = 42);
 }
 
-bt_test_suite(t_path, "Testing paths");
+bt_test_suite(t_include, "Testing including another config file");
 
 
 
 
 /*
- *     Testing Community List
- *     ----------------------
+ *     Testing boolean expressions
+ *     ---------------------------
  */
 
-define p23 = (2, 3);
-
-function t_community_list()
-clist l;
-clist l2;
+function t_bool()
+bool b;
 {
-       /* XXX: add((x,y)) works as prepend */
+       b = true;
+       bt_assert(b);
+       bt_assert(!!b);
 
-       l = - empty -;
-       bt_assert(l !~ [(*,*)]);
-       bt_assert((l ~ [(*,*)]) != (l !~ [(*,*)]));
+       bt_assert(format(true)  = "TRUE");
+       bt_assert(format(false) = "FALSE");
 
-       l = add( l, (one,2) );
-       bt_assert(l ~ [(*,*)]);
-       l = add( l, (2,one+2) );
-       bt_assert(format(l) = "(clist (1,2) (2,3))");
+       if ( b = true ) then
+               bt_assert(b);
+       else
+               bt_assert(false);
 
-       bt_assert((2,3) ~ l);
-       bt_assert(l ~ [(1,*)]);
-       bt_assert(l ~ [p23]);
-       bt_assert(l ~ [(2,2..3)]);
-       bt_assert(l ~ [(1,1..2)]);
-       bt_assert(l ~ [(1,1)..(1,2)]);
+       bt_assert(true && true);
+       bt_assert(true || false);
+       bt_assert(! false && ! false && true);
+       bt_assert(1 < 2 && 1 != 3);
+       bt_assert(true && true && ! false);
+       bt_assert(true || 1+"a");
+       bt_assert(!(false && 1+"a"));
+       bt_assert(!(true && false));
+}
 
-       l = add(l, (2,5));
-       l = add(l, (5,one));
-       l = add(l, (6,one));
-       l = add(l, (one,one));
-       l = delete(l, [(5,1),(6,one),(one,1)]);
-       l = delete(l, [(5,one),(6,one)]);
-       l = filter(l, [(1,*)]);
-       bt_assert(l = add(-empty-, (1,2)));
+bt_test_suite(t_bool, "Testing boolean expressions");
 
-       bt_assert((2,3) !~ l);
-       bt_assert(l !~ [(2,*)]);
-       bt_assert(l !~ [(one,3..6)]);
-       bt_assert(l ~ [(*,*)]);
 
-       l = add(l, (3,one));
-       l = add(l, (one+one+one,one+one));
-       l = add(l, (3,3));
-       l = add(l, (3,4));
-       l = add(l, (3,5));
-       l2 = filter(l, [(3,*)]);
-       l = delete(l, [(3,2..4)]);
-       bt_assert(l = add(add(add(-empty-, (1,2)), (3,1)), (3,5)));
-       bt_assert(l.len = 3);
 
-       l = add(l, (3,2));
-       l = add(l, (4,5));
-       bt_assert(l = add(add(add(add(add(-empty-, (1,2)), (3,1)), (3,5)), (3,2)), (4,5)));
 
-       bt_assert(l.len = 5);
-       bt_assert(l ~ [(*,2)]);
-       bt_assert(l ~ [(*,5)]);
-       bt_assert(l ~ [(*, one)]);
-       bt_assert(l !~ [(*,3)]);
-       bt_assert(l !~ [(*,(one+6))]);
-       bt_assert(l !~ [(*, (one+one+one))]);
+/*
+ *     Testing integers
+ *     ----------------
+ */
 
-       l = delete(l, [(*,(one+onef(3)))]);
-       l = delete(l, [(*,(4+one))]);
-       bt_assert(l = add(-empty-, (3,1)));
+define four = 4;
+define xyzzy = (120+10);
+define '1a-a1' = (xyzzy-100);
 
-       l = delete(l, [(*,(onef(5)))]);
-       bt_assert(l = -empty-);
+function t_int()
+int i;
+{
+       bt_assert(xyzzy = 130);
+       bt_assert('1a-a1' = 30);
 
-       l2 = add(l2, (3,6));
-       l = filter(l2, [(3,1..4)]);
-       l2 = filter(l2, [(3,3..6)]);
+       i = four;
+       i = 12*100 + 60/2 + i;
+       i = (i + 0);
+       bt_assert(i = 1234);
 
-       #  lclist A (10,20,30)
-       bt_assert(format(l) = "(clist (3,1) (3,2) (3,3) (3,4))");
-       bt_assert(l = add(add(add(add(-empty-, (3,1)), (3,2)), (3,3)), (3,4)));
+       bt_assert(format(i) = "1234");
 
-       #  lclist B (30,40,50)
-       bt_assert(format(l2) = "(clist (3,3) (3,4) (3,5) (3,6))");
-       bt_assert(l2 = add(add(add(add(-empty-, (3,3)), (3,4)), (3,5)), (3,6)));
+       if (i = 4) then
+               bt_assert(false);
+       else
+               bt_assert(true);
 
-       #  lclist A union B
-       bt_assert(format(add(l, l2)) = "(clist (3,1) (3,2) (3,3) (3,4) (3,5) (3,6))");
-       bt_assert(add(l, l2) = add(add(add(add(add(add(-empty-, (3,1)), (3,2)), (3,3)), (3,4)), (3,5)), (3,6)));
+       if !(i = 3) then
+               bt_assert(true);
+       else
+               bt_assert(false);
 
-       #  lclist A isect B
-       bt_assert(format(filter(l, l2)) = "(clist (3,3) (3,4))");
-       bt_assert(filter(l, l2) = add(add(-empty-, (3,3)), (3,4)));
+       if 1234 = i then
+               bt_assert(true);
+       else
+               bt_assert(false);
 
-       #  lclist A \ B
-       bt_assert(format(delete(l, l2)) = "(clist (3,1) (3,2))");
-       bt_assert(delete(l, l2) = add(add(-empty-, (3,1)), (3,2)));
+       if 1 <= 1 then
+               bt_assert(true);
+       else
+               bt_assert(false);
+
+       if 1234 < 1234 then
+               bt_assert(false);
+       else
+               bt_assert(true);
+
+       i = 4200000000;
+       bt_assert(i = 4200000000);
+       bt_assert(i > 4100000000);
+       bt_assert(!(i > 4250000000));
+
+       bt_assert(1 = 1);
+       bt_assert(!(1 != 1));
+
+       bt_assert(1 != 2);
+       bt_assert(1 <= 2);
+
+       bt_assert(1 != "a");
+       bt_assert(1 != (0,1));
 }
 
-bt_test_suite(t_community_list, "Testing communities and lists");
+bt_test_suite(t_int, "Testing integers");
 
 
 
 
 /*
- *     Testing Extended Community List
- *     -------------------------------
- */
-
-function t_extended_community_list()
-eclist el;
-eclist el2;
-{
-       el = -- empty --;
-       el = add(el, (rt, 10, 20));
-       el = add(el, (ro, 10.20.30.40, 100));
-       el = add(el, (ro, 11.21.31.41.mask(16), 200));
-
-       bt_assert(format(el) = "(eclist (rt, 10, 20) (ro, 10.20.30.40, 100) (ro, 11.21.0.0, 200))");
-       bt_assert(el.len = 3);
-       el = delete(el, (rt, 10, 20));
-       el = delete(el, (rt, 10, 30));
-       bt_assert(el = add(add(--empty--, (ro, 10.20.30.40, 100)), (ro, 11.21.0.0, 200)));
-       el = add(el, (unknown 2, ten, 1));
-       el = add(el, (unknown 5, ten, 1));
-       el = add(el, (rt, ten, one+one));
-       el = add(el, (rt, 10, 3));
-       el = add(el, (rt, 10, 4));
-       el = add(el, (rt, 10, 5));
-       el = add(el, (generic, 0x2000a, 3*ten));
-       el = delete(el, [(rt, 10, 2..ten)]);
-       bt_assert(el = add(add(add(add(add(--empty--, (ro, 10.20.30.40, 100)), (ro, 11.21.0.0, 200)), (rt, 10, 1)), (unknown 5, 10, 1)), (rt, 10, 30)));
-
-       el = filter(el, [(rt, 10, *)]);
-       bt_assert(el = add(add(--empty--, (rt, 10, 1)), (rt, 10, 30)));
-       bt_assert((rt, 10, 1) ~ el);
-       bt_assert(el ~ [(rt, 10, ten..40)]);
-       bt_assert((rt, 10, 20) !~ el);
-       bt_assert((ro, 10.20.30.40, 100) !~ el);
-       bt_assert(el !~ [(rt, 10, 35..40)]);
-       bt_assert(el !~ [(ro, 10, *)]);
+ *     Testing sets of integers
+ *     ------------------------
+ */
 
-       el = add(el, (rt, 10, 40));
-       el2 = filter(el, [(rt, 10, 20..40)] );
-       el2 = add(el2, (rt, 10, 50));
+define is1 = [ one, (2+1), (6-one), 8, 11, 15, 17, 19];
+define is2 = [(17+2), 17, 15, 11, 8, 5, 3, 2];
+define is3 = [5, 17, 2, 11, 8, 15, 3, 19];
 
-       #  eclist A (1,30,40)
-       bt_assert(format(el) = "(eclist (rt, 10, 1) (rt, 10, 30) (rt, 10, 40))");
-       bt_assert(el = add(add(add(--empty--, (rt, 10, 1)), (rt, 10, 30)), (rt, 10, 40)));
+function t_int_set()
+int set is;
+{
+       bt_assert(1 ~ [1,2,3]);
+       bt_assert(5 ~ [1..20]);
+       bt_assert(2 ~ [ 1, 2, 3 ]);
+       bt_assert(5 ~ [ 4 .. 7 ]);
+       bt_assert(1 !~ [ 2, 3, 4 ]);
 
-       #  eclist B (30,40,50)
-       bt_assert(format(el2) = "(eclist (rt, 10, 30) (rt, 10, 40) (rt, 10, 50))");
-       bt_assert(el2 = add(add(add(--empty--, (rt, 10, 30)), (rt, 10, 40)), (rt, 10, 50)));
+       is = [ 2, 3, 4, 7..11 ];
+       bt_assert(10 ~ is);
+       bt_assert(5 !~ is);
 
-       #  eclist A union B
-       bt_assert(format(add(el2, el)) = "(eclist (rt, 10, 30) (rt, 10, 40) (rt, 10, 50) (rt, 10, 1))");
-       bt_assert(add(el2, el) =  add(add(add(add(--empty--, (rt, 10, 30)), (rt, 10, 40)), (rt, 10, 50)), (rt, 10, 1)));
+       bt_assert(1 ~ is1);
+       bt_assert(3 ~ is1);
+       bt_assert(5 ~ is1);
+       bt_assert((one+2) ~ is1);
+       bt_assert(2 ~ is2);
+       bt_assert(2 ~ is3);
+       bt_assert(4 !~ is1);
+       bt_assert(4 !~ is2);
+       bt_assert(4 !~ is3);
+       bt_assert(10 !~ is1);
+       bt_assert(10 !~ is2);
+       bt_assert(10 !~ is3);
+       bt_assert(15 ~ is1);
+       bt_assert(15 ~ is2);
+       bt_assert(15 ~ is3);
+       bt_assert(18 !~ is1);
+       bt_assert(18 !~ is2);
+       bt_assert(18 !~ is3);
+       bt_assert(19 ~ is1);
+       bt_assert(19 ~ is2);
+       bt_assert(19 ~ is3);
+       bt_assert(20 !~ is1);
+       bt_assert(20 !~ is2);
+       bt_assert(20 !~ is3);
 
-       #  eclist A isect B
-       bt_assert(format(filter(el, el2)) = "(eclist (rt, 10, 30) (rt, 10, 40))");
-       bt_assert(filter(el, el2) = add(add(--empty--, (rt, 10, 30)), (rt, 10, 40)));
+       bt_assert([1,2] != [1,3]);
+       bt_assert([1,4..10,20] = [1,4..10,20]);
 
-       #  eclist A \ B
-       bt_assert(format(delete(el, el2)) = "(eclist (rt, 10, 1))");
-       bt_assert(delete(el, el2) = add(--empty--, (rt, 10, 1)));
+       bt_assert(format([ 1, 2, 1, 1, 1, 3, 4, 1, 1, 1, 5 ]) = "[1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5]");
 }
 
-bt_test_suite(t_extended_community_list, "Testing extended communities and lists");
+bt_test_suite(t_int_set, "Testing sets of integers");
 
 
 
 
 /*
- *     Testing Long Communities
- *     ------------------------
+ *     Testing string matching
+ *     -----------------------
  */
 
-function mktrip(int a)
+function t_string()
+string st;
 {
-       return (a, 2*a, 3*a);
+       st = "Hello";
+       bt_assert(format(st) = "Hello");
+       bt_assert(st ~ "Hell*");
+       bt_assert(st ~ "?ello");
+       bt_assert(st ~ "Hello");
+       bt_assert(st ~ "Hell?");
+       bt_assert(st !~ "ell*");
 }
 
-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));
-       bt_assert(format(ll) = "(lclist (10, 20, 30) (1000, 2000, 3000) (100000, 200000, 300000))");
-       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)));
+bt_test_suite(t_string, "Testing string matching");
 
-       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));
 
-       bt_assert(format(ll) = "(lclist (10, 10, 10) (20, 20, 20) (30, 30, 30))");
-       bt_assert(format(ll2) = "(lclist (20, 20, 20) (30, 30, 30) (40, 40, 40))");
 
-       bt_assert(format(add(ll, ll2)) = "(lclist (10, 10, 10) (20, 20, 20) (30, 30, 30) (40, 40, 40))");
-       bt_assert(add(ll, ll2) = add(add(add(add(---empty---, (10,10,10)), (20,20,20)), (30,30,30)), (40,40,40)));
+/*
+ *     Testing pairs
+ *     -------------
+ */
 
-       bt_assert(format(filter(ll, ll2)) = "(lclist (20, 20, 20) (30, 30, 30))");
-       bt_assert(filter(ll, ll2) = add(add(---empty---, (20, 20, 20)), (30, 30, 30)));
+function 'mkpair-a'(int a)
+{
+       return (1, a);
+}
 
-       bt_assert(format(delete(ll, ll2)) = "(lclist (10, 10, 10))");
-       bt_assert(delete(ll, ll2) = add(---empty---, (10, 10, 10)));
+function t_pair()
+pair pp;
+{
+       pp = (1, 2);
+       bt_assert((1,2) = pp);
+       bt_assert((1,1+1) = pp);
+       bt_assert('mkpair-a'(2) = pp);
+       bt_assert((1,2) = (1,1+1));
+       bt_assert(((1,2) < (2,2)));
+       bt_assert(!((1,1) > (1,1)));
 }
 
-bt_test_suite(t_long_community_list, "Testing long communities and lists");
+bt_test_suite(t_pair, "Testing pairs");
 
 
 
 
 /*
- *     Testing defined() function
- *     --------------------------
+ *     Testing sets of pairs
+ *     ---------------------
  */
 
-function test_undef(int a)
-int b;
-{
-       if a = 3 then {
-               b = 4;
-               bt_assert(defined(b));
-       }
-       else {
-               bt_assert(!defined(b));
-       }
-}
-
-function t_define()
-int i;
+function t_pair_set()
+pair pp;
+pair set ps;
 {
-       test_undef(2);
-       test_undef(3);
-       test_undef(2);
+       pp = (1, 2);
+       ps = [(1,(one+one)), (3,4)..(4,8), (5,*), (6,3..6)];
+       bt_assert(format(ps) = "[(1,2), (3,4)..(4,8), (5,0)..(5,65535), (6,3)..(6,6)]");
+       bt_assert(pp ~ ps);
+       bt_assert((3,5) ~ ps);
+       bt_assert((4,1) ~ ps);
+       bt_assert((5,4) ~ ps);
+       bt_assert((5,65535) ~ ps);
+       bt_assert((6,4) ~ ps);
+       bt_assert((3, 10000) ~ ps);
+       bt_assert((3,3) !~ ps);
+       bt_assert((4,9) !~ ps);
+       bt_assert((4,65535) !~ ps);
+       bt_assert((6,2) !~ ps);
+       bt_assert((6,6+one) !~ ps);
+       bt_assert(((one+6),2) !~ ps);
+       bt_assert((1,1) !~ ps);
 
-       bt_assert(defined(1));
-       bt_assert(defined(1.2.3.4));
+       ps = [(20..150, 200..300), (50100..50200, 1000..50000), (*, 5+5)];
+       bt_assert((100,200) ~ ps);
+       bt_assert((150,300) ~ ps);
+       bt_assert((50180,1200) ~ ps);
+       bt_assert((50110,49000) ~ ps);
+       bt_assert((0,10) ~ ps);
+       bt_assert((64000,10) ~ ps);
+       bt_assert((20,199) !~ ps);
+       bt_assert((151,250) !~ ps);
+       bt_assert((50050,2000) !~ ps);
+       bt_assert((50150,50050) !~ ps);
+       bt_assert((10,9) !~ ps);
+       bt_assert((65535,11) !~ ps);
 }
 
-bt_test_suite(t_define, "Testing defined() function");
+bt_test_suite(t_pair_set, "Testing sets of pairs");
 
 
 
@@ -422,544 +412,540 @@ bt_test_suite(t_quad_set, "Testing sets of quads");
 
 
 /*
- *     Testing Extended Communities
- *     ----------------------------
+ *     Testing ip address
+ *     ------------------
  */
 
-function t_ec()
-ec cc;
-{
-       cc = (rt, 12345, 200000);
-       bt_assert(format(cc) = "(rt, 12345, 200000)");
+define onetwo = 1.2.3.4;
 
-       bt_assert(cc = (rt, 12345, 200000));
-       bt_assert(cc < (rt, 12345, 200010));
-       bt_assert(cc != (rt, 12346, 200000));
-       bt_assert(cc != (ro, 12345, 200000));
-       bt_assert(!(cc > (rt, 12345, 200010)));
+function t_ip()
+ip p;
+{
+       p = 127.1.2.3;
+       bt_assert(p.mask(8) = 127.0.0.0);
+       bt_assert(1.2.3.4 = 1.2.3.4);
+       bt_assert(1.2.3.4 = onetwo);
+       bt_assert(format(p) = "127.1.2.3");
 
-       bt_assert(format((ro, 100000, 20000)) = "(ro, 100000, 20000)");
+       p = ::fffe:6:c0c:936d:88c7:35d3;
+       bt_assert(format(p) = "::fffe:6:c0c:936d:88c7:35d3");
 }
 
-bt_test_suite(t_ec, "Testing Extended Communities");
+bt_test_suite(t_ip, "Testing ip address");
 
 
 
 
 /*
- *     Testing sets of Extended Communities
- *     ------------------------------------
+ *     Testing sets of ip address
+ *     --------------------------
  */
 
-define ecs2 = [(rt, ten, (one+onef(0))*10), (ro, 100000, 100..200), (rt, 12345, *)];
+define ip1222 = 1.2.2.2;
 
-function t_ec_set()
-ec set ecs;
+function t_ip_set()
+ip set ips;
 {
-       ecs = [(rt, ten, (one+onef(0))*10), (ro, 100000, 100..200), (rt, 12345, *)];
-       bt_assert(format(ecs)  = "[(rt, 10, 20), (rt, 12345, 0)..(rt, 12345, 4294967295), (ro, 100000, 100)..(ro, 100000, 200)]");
-       bt_assert(format(ecs2) = "[(rt, 10, 20), (rt, 12345, 0)..(rt, 12345, 4294967295), (ro, 100000, 100)..(ro, 100000, 200)]");
+       ips = [ 1.1.1.0 .. 1.1.1.255, ip1222];
+       bt_assert(format(ips) = "[1.1.1.0..1.1.1.255, 1.2.2.2]");
+       bt_assert(1.1.1.0 ~ ips);
+       bt_assert(1.1.1.100 ~ ips);
+       bt_assert(1.2.2.2 ~ ips);
+       bt_assert(1.1.0.255 !~ ips);
+       bt_assert(1.1.2.0  !~ ips);
+       bt_assert(1.2.2.3 !~ ips);
+       bt_assert(192.168.1.1 !~ ips);
 
-       bt_assert((rt, 10, 20) ~ ecs);
-       bt_assert((ro, 100000, 100) ~ ecs);
-       bt_assert((ro, 100000, 128) ~ ecs);
-       bt_assert((ro, 100000, 200) ~ ecs);
-       bt_assert((rt, 12345, 0) ~ ecs);
-       bt_assert((rt, 12345, 200000) ~ ecs);
-       bt_assert((rt, 12345, 4000000) ~ ecs);
-       bt_assert((ro, 10, 20) !~ ecs);
-       bt_assert((rt, 10, 21) !~ ecs);
-       bt_assert((ro, 100000, 99) !~ ecs);
-       bt_assert((ro, 12345, 10) !~ ecs);
-       bt_assert((rt, 12346, 0) !~ ecs);
-       bt_assert((ro, 0.1.134.160, 150) !~ ecs);
+       bt_assert(1.2.3.4 !~ [ 1.2.3.3, 1.2.3.5 ]);
+       bt_assert(1.2.3.4 ~ [ 1.2.3.3..1.2.3.5 ]);
 }
 
-bt_test_suite(t_ec_set, "Testing sets of Extended Communities");
+bt_test_suite(t_ip_set, "Testing sets of ip address");
 
 
 
 
 /*
- *     Testing integers
- *     ----------------
+ *     Testing enums
+ *     -------------
  */
 
-define four = 4;
-define xyzzy = (120+10);
-define '1a-a1' = (xyzzy-100);
-
-function t_int()
-int i;
+function t_enum()
 {
-       bt_assert(xyzzy = 130);
-       bt_assert('1a-a1' = 30);
-
-       i = four;
-       i = 12*100 + 60/2 + i;
-       i = (i + 0);
-       bt_assert(i = 1234);
-
-       if (i = 4) then
-               bt_assert(false);
-       else
-               bt_assert(true);
-
-       if !(i = 3) then
-               bt_assert(true);
-       else
-               bt_assert(false);
-
-       if 1234 = i then
-               bt_assert(true);
-       else
-               bt_assert(false);
-
-       if 1 <= 1 then
-               bt_assert(true);
-       else
-               bt_assert(false);
-
-       if 1234 < 1234 then
-               bt_assert(false);
-       else
-               bt_assert(true);
-
-       i = 4200000000;
-       bt_assert(i = 4200000000);
-       bt_assert(i > 4100000000);
-       bt_assert(!(i > 4250000000));
-
-       bt_assert(1 = 1);
-       bt_assert(!(1 != 1));
-
-       bt_assert(1 != 2);
-       bt_assert(1 <= 2);
-
-       bt_assert(1 != "a");
-       bt_assert(1 != (0,1));
+       bt_assert(format(RTS_DUMMY)  = "(enum 30)0");           /* XXX */
+       bt_assert(format(RTS_STATIC) = "(enum 30)1");           /* XXX */
+       bt_assert(RTS_STATIC ~ [RTS_STATIC, RTS_DEVICE]);
+       bt_assert(RTS_BGP !~ [RTS_STATIC, RTS_DEVICE]);
 }
 
-bt_test_suite(t_int, "Testing integers");
+bt_test_suite(t_enum, "Testing enums");
 
 
 
 
 /*
- *     Testing sets of integers
- *     ------------------------
+ *     Testing prefixes
+ *     ----------------
  */
 
-define is1 = [ one, (2+1), (6-one), 8, 11, 15, 17, 19];
-define is2 = [(17+2), 17, 15, 11, 8, 5, 3, 2];
-define is3 = [5, 17, 2, 11, 8, 15, 3, 19];
+define netdoc = 2001:db8::/32;
 
-function t_int_set()
-int set is;
+function t_prefix()
+prefix px;
 {
-       bt_assert(1 ~ [1,2,3]);
-       bt_assert(5 ~ [1..20]);
-       bt_assert(2 ~ [ 1, 2, 3 ]);
-       bt_assert(5 ~ [ 4 .. 7 ]);
-       bt_assert(1 !~ [ 2, 3, 4 ]);
-
-       is = [ 2, 3, 4, 7..11 ];
-       bt_assert(10 ~ is);
-       bt_assert(5 !~ is);
-
-       bt_assert(1 ~ is1);
-       bt_assert(3 ~ is1);
-       bt_assert(5 ~ is1);
-       bt_assert((one+2) ~ is1);
-       bt_assert(2 ~ is2);
-       bt_assert(2 ~ is3);
-       bt_assert(4 !~ is1);
-       bt_assert(4 !~ is2);
-       bt_assert(4 !~ is3);
-       bt_assert(10 !~ is1);
-       bt_assert(10 !~ is2);
-       bt_assert(10 !~ is3);
-       bt_assert(15 ~ is1);
-       bt_assert(15 ~ is2);
-       bt_assert(15 ~ is3);
-       bt_assert(18 !~ is1);
-       bt_assert(18 !~ is2);
-       bt_assert(18 !~ is3);
-       bt_assert(19 ~ is1);
-       bt_assert(19 ~ is2);
-       bt_assert(19 ~ is3);
-       bt_assert(20 !~ is1);
-       bt_assert(20 !~ is2);
-       bt_assert(20 !~ is3);
-
-       bt_assert([1,2] != [1,3]);
-       bt_assert([1,4..10,20] = [1,4..10,20]);
+       px = 1.2.0.0/18;
+       bt_assert(format(px) = "1.2.0.0/18");
+       bt_assert(192.168.0.0/16 ~ 192.168.0.0/16);
+       bt_assert(192.168.0.0/17 ~ 192.168.0.0/16);
+       bt_assert(192.168.254.0/24 ~ 192.168.0.0/16);
+       bt_assert(netdoc ~ 2001::/16);
+       bt_assert(192.168.0.0/15 !~ 192.168.0.0/16);
+       bt_assert(192.160.0.0/17 !~ 192.168.0.0/16);
+       bt_assert(px !~ netdoc);
 
-       bt_assert(format([ 1, 2, 1, 1, 1, 3, 4, 1, 1, 1, 5 ]) = "[1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5]");
+       bt_assert(1.2.3.4 ~ 1.0.0.0/8);
+       bt_assert(1.0.0.0/8 ~ 1.0.0.0/8);
 }
 
-bt_test_suite(t_int_set, "Testing sets of integers");
+bt_test_suite(t_prefix, "Testing prefixes");
 
 
 
 
 /*
- *     Testing ip address
- *     ------------------
+ *     Testing prefix sets
+ *     -------------------
  */
 
-define onetwo = 1.2.3.4;
+define net10 = 10.0.0.0/8;
+define pxs2 = [ 10.0.0.0/16{8,12}, 20.0.0.0/16{24,28} ];
 
-function t_ip()
-ip p;
+function test_pxset(prefix set pxs)
 {
-       p = 127.1.2.3;
-       bt_assert(p.mask(8) = 127.0.0.0);
-       bt_assert(1.2.3.4 = 1.2.3.4);
-       bt_assert(1.2.3.4 = onetwo);
-       bt_assert(format(onetwo) = "1.2.3.4");
-}
+       bt_assert(net10  ~ pxs);
+       bt_assert(10.0.0.0/10  ~ pxs);
+       bt_assert(10.0.0.0/12 ~ pxs);
+       bt_assert(20.0.0.0/24 ~ pxs);
+       bt_assert(20.0.40.0/24 ~ pxs);
+       bt_assert(20.0.0.0/26 ~ pxs);
+       bt_assert(20.0.100.0/26 ~ pxs);
+       bt_assert(20.0.0.0/28 ~ pxs);
+       bt_assert(20.0.255.0/28 ~ pxs);
 
-bt_test_suite(t_ip, "Testing ip address");
+       bt_assert(10.0.0.0/7 !~ pxs);
+       bt_assert(10.0.0.0/13 !~ pxs);
+       bt_assert(10.0.0.0/16 !~ pxs);
+       bt_assert(20.0.0.0/16 !~ pxs);
+       bt_assert(20.0.0.0/23 !~ pxs);
+       bt_assert(20.0.0.0/29 !~ pxs);
+       bt_assert(11.0.0.0/10 !~ pxs);
+       bt_assert(20.1.0.0/26 !~ pxs);
 
+       bt_assert(1.0.0.0/8 ~ [ 1.0.0.0/8+ ]);
+       bt_assert(1.0.0.0/9 !~ [ 1.0.0.0/8- ]);
+       bt_assert(1.2.0.0/17 !~ [ 1.0.0.0/8{ 15 , 16 } ]);
 
+       bt_assert([ 10.0.0.0/8{ 15 , 17 } ] = [ 10.0.0.0/8{ 15 , 17 } ]);
+}
 
+function t_prefix_set()
+prefix set pxs;
+{
+       pxs = [ 1.2.0.0/16, 1.4.0.0/16+];
+       bt_assert(format(pxs) = "[1.2.0.0/112{::0.1.0.0}, 1.4.0.0/112{::0.1.255.255}]");
+       bt_assert(1.2.0.0/16 ~ pxs);
+       bt_assert(1.4.0.0/16 ~ pxs);
+       bt_assert(1.4.0.0/18 ~ pxs);
+       bt_assert(1.4.0.0/32 ~ pxs);
+       bt_assert(1.1.0.0/16 !~ pxs);
+       bt_assert(1.3.0.0/16 !~ pxs);
+       bt_assert(1.2.0.0/15 !~ pxs);
+       bt_assert(1.2.0.0/17 !~ pxs);
+       bt_assert(1.2.0.0/32 !~ pxs);
+       bt_assert(1.4.0.0/15 !~ pxs);
 
-/*
- *     Testing sets of ip address
- *     --------------------------
- */
+       test_pxset(pxs2);
+       test_pxset([ 10.0.0.0/16{8,12}, 20.0.0.0/16{24,28} ]);
 
-function t_ip_set()
-{
-       bt_assert(1.2.3.4 !~ [ 1.2.3.3, 1.2.3.5 ]);
-       bt_assert(1.2.3.4 ~ [ 1.2.3.3..1.2.3.5 ]);
+       bt_assert(1.2.0.0/16 ~ [ 1.0.0.0/8{ 15 , 17 } ]);
+       bt_assert([ 10.0.0.0/8{ 15 , 17 } ] != [ 11.0.0.0/8{ 15 , 17 } ]);
 }
 
-bt_test_suite(t_ip_set, "Testing sets of ip address");
+bt_test_suite(t_prefix_set, "Testing prefix sets");
 
 
 
 
 /*
- *     Testing enums
- *     -------------
+ *     Testing Paths
+ *     -------------
  */
 
-function t_enum()
+function mkpath(int a; int b)
 {
-       bt_assert(format(RTS_DUMMY)  = "(enum 30)0");           /* XXX */
-       bt_assert(format(RTS_STATIC) = "(enum 30)1");           /* XXX */
-       bt_assert(RTS_STATIC ~ [RTS_STATIC, RTS_DEVICE]);
-       bt_assert(RTS_BGP !~ [RTS_STATIC, RTS_DEVICE]);
+       return [= a b 3 2 1 =];
 }
 
-bt_test_suite(t_enum, "Testing enums");
+function t_path()
+bgpmask pm1;
+bgpmask pm2;
+bgppath p2;
+{
+       pm1 =  / 4 3 2 1 /;
+       pm2 = [= 4 3 2 1 =];
 
+       bt_assert(+empty+ = +empty+);
+       bt_assert(10 !~ +empty+);
 
+       p2 = prepend( + empty +, 1 );
+       p2 = prepend( p2, 2 );
+       p2 = prepend( p2, 3 );
+       p2 = prepend( p2, 4 );
 
+       bt_assert(format(p2) = "(path 4 3 2 1)");
+       bt_assert(p2.len = 4);
+       bt_assert(p2 ~ pm1);
+       bt_assert(p2 ~ pm2);
+       bt_assert(3 ~ p2);
+       bt_assert(p2 ~ [2, 10..20]);
+       bt_assert(p2 ~ [4, 10..20]);
 
-/*
- *     Testing pairs
- *     -------------
- */
+       p2 = prepend(p2, 5);
+       bt_assert(p2 !~ pm1);
+       bt_assert(p2 !~ pm2);
+       bt_assert(10 !~ p2);
+       bt_assert(p2 !~ [8, ten..(2*ten)]);
+       bt_assert(p2 ~  / ? 4 3 2 1 /);
+       bt_assert(p2 ~ [= * 4 3 * 1 =]);
+       bt_assert(p2 ~ [= (3+2) (2*2) 3 2 1 =]);
+       bt_assert(p2 ~ mkpath(5, 4));
 
-function 'mkpair-a'(int a)
-{
-       return (1, a);
-}
+       bt_assert(p2.len = 5);
+       bt_assert(p2.first = 5);
+       bt_assert(p2.last = 1);
 
-function t_pair()
-pair pp;
-{
-       pp = (1, 2);
-       bt_assert((1,2) = pp);
-       bt_assert((1,1+1) = pp);
-       bt_assert('mkpair-a'(2) = pp);
-       bt_assert((1,2) = (1,1+1));
-       bt_assert(((1,2) < (2,2)));
-       bt_assert(!((1,1) > (1,1)));
+       bt_assert(p2.len = 5);
+       bt_assert(delete(p2, 3) = prepend(prepend(prepend(prepend(+empty+, 1), 2), 4), 5));
+       bt_assert(filter(p2, [1..3]) = prepend(prepend(prepend(+empty+, 1), 2), 3));
+
+       pm1 = [= 1 2 * 3 4 5 =];
+       p2 = prepend( + empty +, 5 );
+       p2 = prepend( p2, 4 );
+       p2 = prepend( p2, 3 );
+       p2 = prepend( p2, 3 );
+       p2 = prepend( p2, 2 );
+       p2 = prepend( p2, 1 );
+
+       bt_assert(p2 ~ pm1);
+       bt_assert(delete(p2, 3) = prepend(prepend(prepend(prepend(+empty+, 5), 4), 2), 1));
+       bt_assert(delete(p2, [4..5]) = prepend(prepend(prepend(prepend(+empty+, 3), 3), 2), 1));
 }
 
-bt_test_suite(t_pair, "Testing pairs");
+bt_test_suite(t_path, "Testing paths");
 
 
 
 
 /*
- *     Testing sets of pairs
- *     ---------------------
+ *     Testing Community List
+ *     ----------------------
  */
 
-function t_pair_set()
-pair pp;
-pair set ps;
+define p23 = (2, 3);
+
+function t_clist()
+clist l;
+clist l2;
 {
-       pp = (1, 2);
-       ps = [(1,(one+one)), (3,4)..(4,8), (5,*), (6,3..6)];
-       bt_assert(format(ps) = "[(1,2), (3,4)..(4,8), (5,0)..(5,65535), (6,3)..(6,6)]");
-       bt_assert(pp ~ ps);
-       bt_assert((3,5) ~ ps);
-       bt_assert((4,1) ~ ps);
-       bt_assert((5,4) ~ ps);
-       bt_assert((5,65535) ~ ps);
-       bt_assert((6,4) ~ ps);
-       bt_assert((3, 10000) ~ ps);
-       bt_assert((3,3) !~ ps);
-       bt_assert((4,9) !~ ps);
-       bt_assert((4,65535) !~ ps);
-       bt_assert((6,2) !~ ps);
-       bt_assert((6,6+one) !~ ps);
-       bt_assert(((one+6),2) !~ ps);
-       bt_assert((1,1) !~ ps);
+       l = - empty -;
+       bt_assert(l !~ [(*,*)]);
+       bt_assert((l ~ [(*,*)]) != (l !~ [(*,*)]));
 
-       ps = [(20..150, 200..300), (50100..50200, 1000..50000), (*, 5+5)];
-       bt_assert((100,200) ~ ps);
-       bt_assert((150,300) ~ ps);
-       bt_assert((50180,1200) ~ ps);
-       bt_assert((50110,49000) ~ ps);
-       bt_assert((0,10) ~ ps);
-       bt_assert((64000,10) ~ ps);
-       bt_assert((20,199) !~ ps);
-       bt_assert((151,250) !~ ps);
-       bt_assert((50050,2000) !~ ps);
-       bt_assert((50150,50050) !~ ps);
-       bt_assert((10,9) !~ ps);
-       bt_assert((65535,11) !~ ps);
-}
+       bt_assert(-empty- = -empty-);
 
-bt_test_suite(t_pair_set, "Testing sets of pairs");
+       l = add( l, (one,2) );
+       bt_assert(l ~ [(*,*)]);
+       l = add( l, (2,one+2) );
+       bt_assert(format(l) = "(clist (1,2) (2,3))");
 
+       bt_assert((2,3) ~ l);
+       bt_assert(l ~ [(1,*)]);
+       bt_assert(l ~ [p23]);
+       bt_assert(l ~ [(2,2..3)]);
+       bt_assert(l ~ [(1,1..2)]);
+       bt_assert(l ~ [(1,1)..(1,2)]);
 
+       l = add(l, (2,5));
+       l = add(l, (5,one));
+       l = add(l, (6,one));
+       l = add(l, (one,one));
+       l = delete(l, [(5,1),(6,one),(one,1)]);
+       l = delete(l, [(5,one),(6,one)]);
+       l = filter(l, [(1,*)]);
+       bt_assert(l = add(-empty-, (1,2)));
 
+       bt_assert((2,3) !~ l);
+       bt_assert(l !~ [(2,*)]);
+       bt_assert(l !~ [(one,3..6)]);
+       bt_assert(l ~ [(*,*)]);
 
-/*
- *     Testing string matching
- *     -----------------------
- */
+       l = add(l, (3,one));
+       l = add(l, (one+one+one,one+one));
+       l = add(l, (3,3));
+       l = add(l, (3,4));
+       l = add(l, (3,5));
+       l2 = filter(l, [(3,*)]);
+       l = delete(l, [(3,2..4)]);
+       bt_assert(l = add(add(add(-empty-, (1,2)), (3,1)), (3,5)));
+       bt_assert(l.len = 3);
 
-function t_string()
-string st;
-{
-       st = "Hello";
-       bt_assert(format(st) = "Hello");
-       bt_assert(st ~ "Hell*");
-       bt_assert(st ~ "?ello");
-       bt_assert(st ~ "Hello");
-       bt_assert(st ~ "Hell?");
-       bt_assert(st !~ "ell*");
-}
+       l = add(l, (3,2));
+       l = add(l, (4,5));
+       bt_assert(l = add(add(add(add(add(-empty-, (1,2)), (3,1)), (3,5)), (3,2)), (4,5)));
 
-bt_test_suite(t_string, "Testing string matching");
+       bt_assert(l.len = 5);
+       bt_assert(l ~ [(*,2)]);
+       bt_assert(l ~ [(*,5)]);
+       bt_assert(l ~ [(*, one)]);
+       bt_assert(l !~ [(*,3)]);
+       bt_assert(l !~ [(*,(one+6))]);
+       bt_assert(l !~ [(*, (one+one+one))]);
 
+       l = delete(l, [(*,(one+onef(3)))]);
+       l = delete(l, [(*,(4+one))]);
+       bt_assert(l = add(-empty-, (3,1)));
 
+       l = delete(l, [(*,(onef(5)))]);
+       bt_assert(l = -empty-);
 
+       l2 = add(l2, (3,6));
+       l = filter(l2, [(3,1..4)]);
+       l2 = filter(l2, [(3,3..6)]);
 
-/*
- *     Testing boolean expressions
- *     ---------------------------
- */
+       #  lclist A (10,20,30)
+       bt_assert(format(l) = "(clist (3,1) (3,2) (3,3) (3,4))");
+       bt_assert(l = add(add(add(add(-empty-, (3,1)), (3,2)), (3,3)), (3,4)));
 
-function t_bool()
-bool b;
-{
-       b = true;
-       bt_assert(b);
-       bt_assert(!!b);
+       #  lclist B (30,40,50)
+       bt_assert(format(l2) = "(clist (3,3) (3,4) (3,5) (3,6))");
+       bt_assert(l2 = add(add(add(add(-empty-, (3,3)), (3,4)), (3,5)), (3,6)));
 
-       if ( b = true ) then
-               bt_assert(b);
-       else
-               bt_assert(false);
+       #  lclist A union B
+       bt_assert(format(add(l, l2)) = "(clist (3,1) (3,2) (3,3) (3,4) (3,5) (3,6))");
+       bt_assert(add(l, l2) = add(add(add(add(add(add(-empty-, (3,1)), (3,2)), (3,3)), (3,4)), (3,5)), (3,6)));
 
-       bt_assert(true && true);
-       bt_assert(true || false);
-       bt_assert(! false && ! false && true);
-       bt_assert(1 < 2 && 1 != 3);
-       bt_assert(true && true && ! false);
-       bt_assert(true || 1+"a");
-       bt_assert(!(false && 1+"a"));
-       bt_assert(!(true && false));
+       #  lclist A isect B
+       bt_assert(format(filter(l, l2)) = "(clist (3,3) (3,4))");
+       bt_assert(filter(l, l2) = add(add(-empty-, (3,3)), (3,4)));
+
+       #  lclist A \ B
+       bt_assert(format(delete(l, l2)) = "(clist (3,1) (3,2))");
+       bt_assert(delete(l, l2) = add(add(-empty-, (3,1)), (3,2)));
 }
 
-bt_test_suite(t_bool, "Testing boolean expressions");
+bt_test_suite(t_clist, "Testing lists of communities");
 
 
 
 
 /*
- *     Testing prefixes
- *     ----------------
+ *     Testing Extended Communities
+ *     ----------------------------
  */
 
-define netdoc = 2001:db8::/32;
-
-function t_prefix()
-prefix px;
+function t_ec()
+ec cc;
 {
-       px = 1.2.0.0/18;
-       bt_assert(format(px) = "1.2.0.0/18");
-       bt_assert(192.168.0.0/16 ~ 192.168.0.0/16);
-       bt_assert(192.168.0.0/17 ~ 192.168.0.0/16);
-       bt_assert(192.168.254.0/24 ~ 192.168.0.0/16);
-       bt_assert(netdoc ~ 2001::/16);
-       bt_assert(192.168.0.0/15 !~ 192.168.0.0/16);
-       bt_assert(192.160.0.0/17 !~ 192.168.0.0/16);
-       bt_assert(px !~ netdoc);
+       cc = (rt, 12345, 200000);
+       bt_assert(format(cc) = "(rt, 12345, 200000)");
 
-       bt_assert(1.2.3.4 ~ 1.0.0.0/8);
-       bt_assert(1.0.0.0/8 ~ 1.0.0.0/8);
+       bt_assert(cc = (rt, 12345, 200000));
+       bt_assert(cc < (rt, 12345, 200010));
+       bt_assert(cc != (rt, 12346, 200000));
+       bt_assert(cc != (ro, 12345, 200000));
+       bt_assert(!(cc > (rt, 12345, 200010)));
+
+       bt_assert(format((ro, 100000, 20000)) = "(ro, 100000, 20000)");
 }
 
-bt_test_suite(t_prefix, "Testing prefixes");
+bt_test_suite(t_ec, "Testing extended communities");
 
 
 
 
 /*
- *     Testing prefix sets
- *     -------------------
+ *     Testing Extended Community List
+ *     -------------------------------
  */
 
-define net10 = 10.0.0.0/8;
-define pxs2 = [ 10.0.0.0/16{8,12}, 20.0.0.0/16{24,28} ];
-
-function test_pxset(prefix set pxs)
+function t_eclist()
+eclist el;
+eclist el2;
 {
-       bt_assert(net10  ~ pxs);
-       bt_assert(10.0.0.0/10  ~ pxs);
-       bt_assert(10.0.0.0/12 ~ pxs);
-       bt_assert(20.0.0.0/24 ~ pxs);
-       bt_assert(20.0.40.0/24 ~ pxs);
-       bt_assert(20.0.0.0/26 ~ pxs);
-       bt_assert(20.0.100.0/26 ~ pxs);
-       bt_assert(20.0.0.0/28 ~ pxs);
-       bt_assert(20.0.255.0/28 ~ pxs);
+       el = -- empty --;
+       el = add(el, (rt, 10, 20));
+       el = add(el, (ro, 10.20.30.40, 100));
+       el = add(el, (ro, 11.21.31.41.mask(16), 200));
 
-       bt_assert(10.0.0.0/7 !~ pxs);
-       bt_assert(10.0.0.0/13 !~ pxs);
-       bt_assert(10.0.0.0/16 !~ pxs);
-       bt_assert(20.0.0.0/16 !~ pxs);
-       bt_assert(20.0.0.0/23 !~ pxs);
-       bt_assert(20.0.0.0/29 !~ pxs);
-       bt_assert(11.0.0.0/10 !~ pxs);
-       bt_assert(20.1.0.0/26 !~ pxs);
+       bt_assert(--empty-- = --empty--);
+       bt_assert(((rt, 10, 20)) !~ --empty--);
 
-       bt_assert(1.0.0.0/8 ~ [ 1.0.0.0/8+ ]);
-       bt_assert(1.0.0.0/9 !~ [ 1.0.0.0/8- ]);
-       bt_assert(1.2.0.0/17 !~ [ 1.0.0.0/8{ 15 , 16 } ]);
+       bt_assert(format(el) = "(eclist (rt, 10, 20) (ro, 10.20.30.40, 100) (ro, 11.21.0.0, 200))");
+       bt_assert(el.len = 3);
+       el = delete(el, (rt, 10, 20));
+       el = delete(el, (rt, 10, 30));
+       bt_assert(el = add(add(--empty--, (ro, 10.20.30.40, 100)), (ro, 11.21.0.0, 200)));
+       el = add(el, (unknown 2, ten, 1));
+       el = add(el, (unknown 5, ten, 1));
+       el = add(el, (rt, ten, one+one));
+       el = add(el, (rt, 10, 3));
+       el = add(el, (rt, 10, 4));
+       el = add(el, (rt, 10, 5));
+       el = add(el, (generic, 0x2000a, 3*ten));
+       el = delete(el, [(rt, 10, 2..ten)]);
+       bt_assert(el = add(add(add(add(add(--empty--, (ro, 10.20.30.40, 100)), (ro, 11.21.0.0, 200)), (rt, 10, 1)), (unknown 5, 10, 1)), (rt, 10, 30)));
 
-       bt_assert([ 10.0.0.0/8{ 15 , 17 } ] = [ 10.0.0.0/8{ 15 , 17 } ]);
-}
+       el = filter(el, [(rt, 10, *)]);
+       bt_assert(el = add(add(--empty--, (rt, 10, 1)), (rt, 10, 30)));
+       bt_assert((rt, 10, 1) ~ el);
+       bt_assert(el ~ [(rt, 10, ten..40)]);
+       bt_assert((rt, 10, 20) !~ el);
+       bt_assert((ro, 10.20.30.40, 100) !~ el);
+       bt_assert(el !~ [(rt, 10, 35..40)]);
+       bt_assert(el !~ [(ro, 10, *)]);
 
-function t_prefix_sets()
-prefix set pxs;
-{
-       pxs = [ 1.2.0.0/16, 1.4.0.0/16+];
-       bt_assert(format(pxs) = "[1.2.0.0/112{::0.1.0.0}, 1.4.0.0/112{::0.1.255.255}]");
-       bt_assert(1.2.0.0/16 ~ pxs);
-       bt_assert(1.4.0.0/16 ~ pxs);
-       bt_assert(1.4.0.0/18 ~ pxs);
-       bt_assert(1.4.0.0/32 ~ pxs);
-       bt_assert(1.1.0.0/16 !~ pxs);
-       bt_assert(1.3.0.0/16 !~ pxs);
-       bt_assert(1.2.0.0/15 !~ pxs);
-       bt_assert(1.2.0.0/17 !~ pxs);
-       bt_assert(1.2.0.0/32 !~ pxs);
-       bt_assert(1.4.0.0/15 !~ pxs);
+       el = add(el, (rt, 10, 40));
+       el2 = filter(el, [(rt, 10, 20..40)] );
+       el2 = add(el2, (rt, 10, 50));
 
-       test_pxset(pxs2);
-       test_pxset([ 10.0.0.0/16{8,12}, 20.0.0.0/16{24,28} ]);
+       #  eclist A (1,30,40)
+       bt_assert(format(el) = "(eclist (rt, 10, 1) (rt, 10, 30) (rt, 10, 40))");
+       bt_assert(el = add(add(add(--empty--, (rt, 10, 1)), (rt, 10, 30)), (rt, 10, 40)));
 
-       bt_assert(1.2.0.0/16 ~ [ 1.0.0.0/8{ 15 , 17 } ]);
-       bt_assert([ 10.0.0.0/8{ 15 , 17 } ] != [ 11.0.0.0/8{ 15 , 17 } ]);
+       #  eclist B (30,40,50)
+       bt_assert(format(el2) = "(eclist (rt, 10, 30) (rt, 10, 40) (rt, 10, 50))");
+       bt_assert(el2 = add(add(add(--empty--, (rt, 10, 30)), (rt, 10, 40)), (rt, 10, 50)));
+
+       #  eclist A union B
+       bt_assert(format(add(el2, el)) = "(eclist (rt, 10, 30) (rt, 10, 40) (rt, 10, 50) (rt, 10, 1))");
+       bt_assert(add(el2, el) =  add(add(add(add(--empty--, (rt, 10, 30)), (rt, 10, 40)), (rt, 10, 50)), (rt, 10, 1)));
+
+       #  eclist A isect B
+       bt_assert(format(filter(el, el2)) = "(eclist (rt, 10, 30) (rt, 10, 40))");
+       bt_assert(filter(el, el2) = add(add(--empty--, (rt, 10, 30)), (rt, 10, 40)));
+
+       #  eclist A \ B
+       bt_assert(format(delete(el, el2)) = "(eclist (rt, 10, 1))");
+       bt_assert(delete(el, el2) = add(--empty--, (rt, 10, 1)));
 }
 
-bt_test_suite(t_prefix_sets, "Testing prefix sets");
+bt_test_suite(t_eclist, "Testing lists of extended communities");
 
 
 
 
 /*
- *     Testing IP sets
- *     ---------------
+ *     Testing sets of Extended Communities
+ *     ------------------------------------
  */
 
-define ip1222 = 1.2.2.2;
+define ecs2 = [(rt, ten, (one+onef(0))*10), (ro, 100000, 100..200), (rt, 12345, *)];
 
-function t_ip_sets()
-ip set ips;
+function t_ec_set()
+ec set ecs;
 {
-       ips = [ 1.1.1.0 .. 1.1.1.255, ip1222];
-       bt_assert(format(ips) = "[1.1.1.0..1.1.1.255, 1.2.2.2]");
-       bt_assert(1.1.1.0 ~ ips);
-       bt_assert(1.1.1.100 ~ ips);
-       bt_assert(1.2.2.2 ~ ips);
-       bt_assert(1.1.0.255 !~ ips);
-       bt_assert(1.1.2.0  !~ ips);
-       bt_assert(1.2.2.3 !~ ips);
-       bt_assert(192.168.1.1 !~ ips);
+       ecs = [(rt, ten, (one+onef(0))*10), (ro, 100000, 100..200), (rt, 12345, *)];
+       bt_assert(format(ecs)  = "[(rt, 10, 20), (rt, 12345, 0)..(rt, 12345, 4294967295), (ro, 100000, 100)..(ro, 100000, 200)]");
+       bt_assert(format(ecs2) = "[(rt, 10, 20), (rt, 12345, 0)..(rt, 12345, 4294967295), (ro, 100000, 100)..(ro, 100000, 200)]");
+
+       bt_assert((rt, 10, 20) ~ ecs);
+       bt_assert((ro, 100000, 100) ~ ecs);
+       bt_assert((ro, 100000, 128) ~ ecs);
+       bt_assert((ro, 100000, 200) ~ ecs);
+       bt_assert((rt, 12345, 0) ~ ecs);
+       bt_assert((rt, 12345, 200000) ~ ecs);
+       bt_assert((rt, 12345, 4000000) ~ ecs);
+       bt_assert((ro, 10, 20) !~ ecs);
+       bt_assert((rt, 10, 21) !~ ecs);
+       bt_assert((ro, 100000, 99) !~ ecs);
+       bt_assert((ro, 12345, 10) !~ ecs);
+       bt_assert((rt, 12346, 0) !~ ecs);
+       bt_assert((ro, 0.1.134.160, 150) !~ ecs);
 }
 
-bt_test_suite(t_ip_sets, "Testing IP sets");
+bt_test_suite(t_ec_set, "Testing sets of extended communities");
 
 
 
 
 /*
- *      Testing calling functions
- *      -------------------------
+ *     Testing Long Communities
+ *     ------------------------
  */
 
-function callme(int arg1; int arg2)
-int i;
+function mktrip(int a)
 {
-       case arg1 {
-       1, 42: return 42;
-       else: return arg1 * arg2;
-       }
-
-       return 0;
+       return (a, 2*a, 3*a);
 }
 
-function fifteen()
+function t_lclist()
+lclist ll;
+lclist ll2;
 {
-       return 15;
-}
+       bt_assert(---empty--- = ---empty---);
+       bt_assert((10, 20, 30) !~ ---empty---);
 
-function t_call_function()
-{
-       bt_assert(fifteen() = 15);
+       ll = --- empty ---;
+       ll = add(ll, (ten, 20, 30));
+       ll = add(ll, (1000, 2000, 3000));
+       ll = add(ll, mktrip(100000));
+       bt_assert(format(ll) = "(lclist (10, 20, 30) (1000, 2000, 3000) (100000, 200000, 300000))");
+       bt_assert(ll.len = 3);
+       bt_assert(ll = add(add(add(---empty---, (10, 20, 30)), (1000, 2000, 3000)), (100000, 200000, 300000)));
 
-       bt_assert(callme(1, 2) = 42);
-       bt_assert(callme(42, 2) = 42);
+       bt_assert(mktrip(1000) ~ ll);
+       bt_assert(mktrip(100) !~ ll);
 
-       bt_assert(callme(2, 2) = 4);
-       bt_assert(callme(3, 2) = 6);
-       bt_assert(callme(4, 4) = 16);
-       bt_assert(callme(7, 2) = 14);
-}
+       bt_assert(ll ~ [(5,10,15), (10,20,30)]);
+       bt_assert(ll ~ [(10,15..25,*)]);
+       bt_assert(ll ~ [(ten, *, *)]);
 
-bt_test_suite(t_call_function, "Testing calling functions");
+       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));
 
+       bt_assert(format(ll) = "(lclist (10, 10, 10) (20, 20, 20) (30, 30, 30))");
+       bt_assert(format(ll2) = "(lclist (20, 20, 20) (30, 30, 30) (40, 40, 40))");
 
-/*
- *     Test including another config file
- *     ----------------------------------
- */
+       bt_assert(format(add(ll, ll2)) = "(lclist (10, 10, 10) (20, 20, 20) (30, 30, 30) (40, 40, 40))");
+       bt_assert(add(ll, ll2) = add(add(add(add(---empty---, (10,10,10)), (20,20,20)), (30,30,30)), (40,40,40)));
 
-function t_include()
-int i;
-{
-  i = 1;
-  include "test.conf.inc";
-  bt_assert(i = 42);
+       bt_assert(format(filter(ll, ll2)) = "(lclist (20, 20, 20) (30, 30, 30))");
+       bt_assert(filter(ll, ll2) = add(add(---empty---, (20, 20, 20)), (30, 30, 30)));
+
+       bt_assert(format(delete(ll, ll2)) = "(lclist (10, 10, 10))");
+       bt_assert(delete(ll, ll2) = add(---empty---, (10, 10, 10)));
 }
 
-bt_test_suite(t_include, "Test including another config file");
+bt_test_suite(t_lclist, "Testing lists of long communities");
+
+
+
 
+/* t_lc_set */