Skip to content

Commit

Permalink
fix: add glob_match() test cases from Go to Python
Browse files Browse the repository at this point in the history
Signed-off-by: sallycaoyu <[email protected]>
  • Loading branch information
sallycaoyu committed Nov 21, 2021
1 parent 1b0f0c4 commit 658d3bb
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/util/test_builtin_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,20 @@ def test_glob_match(self):
self.assertFalse(util.glob_match_func("/prefix/subprefix/foobar", "*/foo*"))
self.assertFalse(util.glob_match_func("/prefix/subprefix/foobar", "*/foo/*"))

def test_glob_match2(self):
# add missing tests from Go to Python
self.assertFalse(util.glob_match_func("/foo", "*/foo")) # different from Go
self.assertFalse(util.glob_match_func("/foo", "*/foo*")) # different from Go
self.assertFalse(util.glob_match_func("/foo", "*/foo/*"))
self.assertFalse(util.glob_match_func("/foo/bar", "*/foo"))
self.assertFalse(util.glob_match_func("/foo/bar", "*/foo*"))
self.assertFalse(
util.glob_match_func("/foo/bar", "*/foo/*")
) # different from Go
self.assertFalse(util.glob_match_func("/foobar", "*/foo"))
self.assertFalse(util.glob_match_func("/foobar", "*/foo*")) # different from Go
self.assertFalse(util.glob_match_func("/foobar", "*/foo/*"))

def test_ip_match(self):
self.assertTrue(util.ip_match_func("192.168.2.123", "192.168.2.0/24"))
self.assertFalse(util.ip_match_func("192.168.2.123", "192.168.3.0/24"))
Expand Down

0 comments on commit 658d3bb

Please sign in to comment.