MCPcopy Create free account
hub / github.com/apache/impala / TEST

Function TEST

be/src/gutil/strings/string_util-test.cc:25–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23namespace kudu {
24
25TEST(StringUtilTest, MatchPatternTest) {
26 EXPECT_TRUE(MatchPattern("www.google.com", "*.com"));
27 EXPECT_TRUE(MatchPattern("www.google.com", "*"));
28 EXPECT_FALSE(MatchPattern("www.google.com", "www*.g*.org"));
29 EXPECT_TRUE(MatchPattern("Hello", "H?l?o"));
30 EXPECT_FALSE(MatchPattern("www.google.com", "http://*)"));
31 EXPECT_FALSE(MatchPattern("www.msn.com", "*.COM"));
32 EXPECT_TRUE(MatchPattern("Hello*1234", "He??o\\*1*"));
33 EXPECT_FALSE(MatchPattern("", "*.*"));
34 EXPECT_TRUE(MatchPattern("", "*"));
35 EXPECT_TRUE(MatchPattern("", "?"));
36 EXPECT_TRUE(MatchPattern("", ""));
37 EXPECT_FALSE(MatchPattern("Hello", ""));
38 EXPECT_TRUE(MatchPattern("Hello*", "Hello*"));
39 // Stop after a certain recursion depth.
40 EXPECT_FALSE(MatchPattern("123456789012345678", "?????????????????*"));
41
42 // Test UTF8 matching.
43 EXPECT_TRUE(MatchPattern("heart: \xe2\x99\xa0", "*\xe2\x99\xa0"));
44 EXPECT_TRUE(MatchPattern("heart: \xe2\x99\xa0.", "heart: ?."));
45 EXPECT_TRUE(MatchPattern("hearts: \xe2\x99\xa0\xe2\x99\xa0", "*"));
46 // Invalid sequences should be handled as a single invalid character.
47 EXPECT_TRUE(MatchPattern("invalid: \xef\xbf\xbe", "invalid: ?"));
48 // If the pattern has invalid characters, it shouldn't match anything.
49 EXPECT_FALSE(MatchPattern("\xf4\x90\x80\x80", "\xf4\x90\x80\x80"));
50
51 // This test verifies that consecutive wild cards are collapsed into 1
52 // wildcard (when this doesn't occur, MatchPattern reaches it's maximum
53 // recursion depth).
54 EXPECT_TRUE(MatchPattern("Hello" ,
55 "He********************************o")) ;
56}
57
58} // namespace kudu

Callers

nothing calls this directly

Calls 1

MatchPatternFunction · 0.85

Tested by

no test coverage detected