]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Filter: Add long community tests
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Wed, 9 Nov 2016 18:08:25 +0000 (19:08 +0100)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Wed, 9 Nov 2016 18:09:24 +0000 (19:09 +0100)
Based on Pavel Tvrdik's int-test-lc branch.

filter/test.conf

index de3a31130aa076c8b3340859fcaaf34f03cd39a8..2ee5817a74d8ddf33b917235daf2b283b5872308 100644 (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
  *     --------------------------