summaryrefslogtreecommitdiffhomepage
path: root/internal/pkg/table/policy_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/pkg/table/policy_test.go')
-rw-r--r--internal/pkg/table/policy_test.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/internal/pkg/table/policy_test.go b/internal/pkg/table/policy_test.go
index 7c2d7a64..9f74f32c 100644
--- a/internal/pkg/table/policy_test.go
+++ b/internal/pkg/table/policy_test.go
@@ -2771,6 +2771,35 @@ func TestParseCommunityRegexp(t *testing.T) {
assert.Equal(t, nil, err)
assert.Equal(t, true, exp.MatchString("65000:1"))
assert.Equal(t, false, exp.MatchString("65000:100"))
+
+ // test if the parseCommunityRegexp function behaves as expected
+
+ l1 := "6830:24370$"
+ r1, _ := ParseCommunityRegexp("6830:24370$")
+
+ l2 := "^6830:24370$"
+ r2, _ := ParseCommunityRegexp("^6830:24370$")
+
+ l3 := "^65001:100$"
+ r3, _ := ParseCommunityRegexp("65001:100")
+
+ l4 := "^65001:400$"
+ r4, _ := ParseCommunityRegexp("4259905936")
+
+ l5 := "^[0-9]*:300$"
+ r5, _ := ParseCommunityRegexp("^[0-9]*:300$")
+
+ l6 := "^" + strconv.Itoa(int(bgp.COMMUNITY_INTERNET)) + ":" + strconv.Itoa(int(bgp.COMMUNITY_INTERNET)) + "$"
+ r6, _ := ParseCommunityRegexp("INTERNET")
+
+ fmt.Printf("%v %v", l2, r2)
+
+ assert.Equal(t, l1, r1.String())
+ assert.Equal(t, l2, r2.String())
+ assert.Equal(t, l3, r3.String())
+ assert.Equal(t, l4, r4.String())
+ assert.Equal(t, l5, r5.String())
+ assert.Equal(t, l6, r6.String())
}
func TestLocalPrefAction(t *testing.T) {