@@ -1029,12 +1029,14 @@ def test_category(self):
10291029 self .assertTrue (tm .match (vCategory (["foobar" ])))
10301030 self .assertFalse (tm .match (vCategory (["fobar" ])))
10311031 self .assertTrue (tm .match_indexes ({None : [b"foobar,blah" ]}))
1032- self .assertFalse (tm .match_indexes ({None : [b"foobarblah" ]}))
1032+ # With substring matching, "foobar" is found in "foobarblah"
1033+ self .assertTrue (tm .match_indexes ({None : [b"foobarblah" ]}))
10331034
10341035 def test_unknown_type (self ):
10351036 tm = TextMatcher ("dontknow" , "foobar" )
10361037 self .assertFalse (tm .match (object ()))
1037- self .assertFalse (tm .match_indexes ({None : [b"foobarblah" ]}))
1038+ # With substring matching, "foobar" is found in "foobarblah"
1039+ self .assertTrue (tm .match_indexes ({None : [b"foobarblah" ]}))
10381040
10391041 def test_unknown_collation (self ):
10401042 self .assertRaises (
@@ -1045,6 +1047,18 @@ def test_unknown_collation(self):
10451047 collation = "i;blah" ,
10461048 )
10471049
1050+ def test_substring_match (self ):
1051+ # Test that text matching uses substring search as per RFC
1052+ tm = TextMatcher ("summary" , "bar" )
1053+ self .assertTrue (tm .match (vText ("foobar" )))
1054+ self .assertTrue (tm .match (vText ("bar" )))
1055+ self .assertTrue (tm .match (vText ("barbaz" )))
1056+ self .assertTrue (tm .match (vText ("foobarbaz" )))
1057+ self .assertFalse (tm .match (vText ("foo" )))
1058+ self .assertFalse (tm .match (vText ("ba" )))
1059+ # Test case insensitive substring match
1060+ self .assertTrue (tm .match (vText ("FOOBAR" )))
1061+
10481062
10491063class ApplyTimeRangeVeventTests (unittest .TestCase ):
10501064 def _tzify (self , dt ):
0 commit comments