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

Function TEST

be/src/runtime/string-search-test.cc:55–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55TEST(StringSearchTest, RegularSearch) {
56 // Basic Tests
57 EXPECT_EQ(0, TestSearch("abcdabcd", "a"));
58 EXPECT_EQ(0, TestSearch("abcdabcd", "ab"));
59 EXPECT_EQ(2, TestSearch("abcdabcd", "c"));
60 EXPECT_EQ(2, TestSearch("abcdabcd", "cd"));
61 EXPECT_EQ(-1, TestSearch("", ""));
62 EXPECT_EQ(-1, TestSearch("abc", ""));
63 EXPECT_EQ(-1, TestSearch("", "a"));
64
65 // Test single chars
66 EXPECT_EQ(0, TestSearch("a", "a"));
67 EXPECT_EQ(-1, TestSearch("a", "b"));
68 EXPECT_EQ(1, TestSearch("abc", "b"));
69
70 // Test searching in a substring of the haystack
71 EXPECT_EQ(0, TestSearch("abcabcd", "abc", 5));
72 EXPECT_EQ(-1, TestSearch("abcabcd", "abcd", 5));
73 EXPECT_EQ(-1, TestSearch("abcabcd", "abcd", 0));
74
75 // Test searching a substring of the needle in a substring of the haystack.
76 EXPECT_EQ(0, TestSearch("abcde", "abaaaaaa", 4, 2));
77 EXPECT_EQ(-1, TestSearch("abcde", "abaaaaaa", 4, 3));
78 EXPECT_EQ(-1, TestSearch("abcdabaaaaa", "abaaaaaa", 4, 3));
79 EXPECT_EQ(-1, TestSearch("abcdabaaaaa", "abaaaaaa", 4, 0));
80 EXPECT_EQ(-1, TestSearch("abcdabaaaaa", "abaaaaaa"));
81
82 // Test with needle matching the end of the substring.
83 EXPECT_EQ(4, TestSearch("abcde", "e"));
84 EXPECT_EQ(3, TestSearch("abcde", "de"));
85 EXPECT_EQ(2, TestSearch("abcdede", "cde"));
86 EXPECT_EQ(5, TestSearch("abcdacde", "cde"));
87
88 // Test correct skip_ handling, which depends on which char of the needle is
89 // the same as the last one.
90 EXPECT_EQ(2, TestSearch("ababcacac", "abcacac"));
91}
92
93TEST(StringSearchTest, ReverseSearch) {
94 // Basic Tests

Callers

nothing calls this directly

Calls 2

TestRSearchFunction · 0.85
TestSearchFunction · 0.70

Tested by

no test coverage detected