]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Filter: Add tests for clists of ints and quads
authorIgor Putovny <igor.putovny@nic.cz>
Wed, 22 Apr 2026 15:16:12 +0000 (17:16 +0200)
committerOndrej Zajicek <santiago@crfreenet.org>
Thu, 23 Apr 2026 14:21:36 +0000 (16:21 +0200)
filter/test.conf

index 390d7c15806e4525142a86aae9cc2722006c20a1..8f2e4270b8ada5239a7e1184303eee31df2663a9 100644 (file)
@@ -1190,6 +1190,7 @@ clist r;
 
 bt_test_suite(t_clist_old, "Testing lists of communities (old syntax)");
 
+
 function t_clist_new()
 {
        bt_assert((10, 20).asn = 10);
@@ -1321,6 +1322,79 @@ bt_test_suite(t_clist_new, "Testing lists of communities (new syntax)");
 
 
 
+/*
+ *         Testing lists of ints
+ *         ---------------------
+ */
+
+function t_clist_int()
+{
+       clist l;
+       bt_assert(l = -empty-);
+
+       l.add(1);
+       l.add(one+one);
+       bt_assert(1 ~ l);
+       bt_assert(2 ~ l);
+       bt_assert(3 !~ l);
+
+       clist ll;
+       ll = -empty-.add(1).add(3).add(4);
+       l.add(ll);
+
+       bt_assert(format(l) = "(clist (0,1) (0,2) (0,3) (0,4))");
+
+       l.delete(1);
+       bt_assert(l = -empty-.add(2).add(3).add(4));
+
+       l.delete([2, 3]);
+       bt_assert(l = -empty-.add(4));
+
+       l = -empty-.add(1).add(2).add(3).add(4);
+
+       bt_assert(delete(l, [2, 3]) = -empty-.add(1).add(4));
+       bt_assert(delete(l, [1 .. 2]) = -empty-.add(3).add(4));
+
+       bt_assert(filter(l, [3, 4]) = -empty-.add(3).add(4));
+       bt_assert(filter(l, [1 .. 4]) = l);
+}
+
+bt_test_suite(t_clist_int, "Testing lists of ints");
+
+
+
+
+/*
+ *         Testing lists of quads
+ *         ----------------------
+ */
+
+function t_clist_quad()
+{
+       quad q = 1.2.3.4;
+       clist ql = -empty-.add(q).add(3.1.0.0).add(4.0.0.0);
+
+       bt_assert(q ~ ql);
+       bt_assert(3.1.0.0 ~ ql);
+       bt_assert(4.0.0.0 ~ ql);
+
+       bt_assert(format(ql) = "(clist (258,772) (769,0) (1024,0))");
+
+       bt_assert(delete(ql, q) = -empty-.add(3.1.0.0).add(4.0.0.0));
+       bt_assert(delete(ql, 3.1.0.0) = -empty-.add(q).add(4.0.0.0));
+       bt_assert(delete(ql, [1.2.3.4, 2.0.0.0]) = -empty-.add(3.1.0.0).add(4.0.0.0));
+       bt_assert(delete(ql, [3.0.0.0 .. 4.0.0.0]) = -empty-.add(1.2.3.4));
+
+       bt_assert(filter(ql, [1.2.3.4]) = -empty-.add(1.2.3.4));
+       bt_assert(filter(ql, [2.0.0.0, 4.0.0.0]) = -empty-.add(4.0.0.0));
+       bt_assert(filter(ql, [1.0.0.0 .. 3.1.0.0]) = -empty-.add(q).add(3.1.0.0));
+}
+
+bt_test_suite(t_clist_quad, "Testing lists of quads");
+
+
+
+
 /*
  *     Testing Extended Communities
  *     ----------------------------