MCPcopy Create free account
hub / github.com/catboost/catboost / Y_UNIT_TEST

Function Y_UNIT_TEST

util/string/strspn_ut.cpp:6–27  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4
5Y_UNIT_TEST_SUITE(TStrSpnTest) {
6 Y_UNIT_TEST(FindFirstOf) {
7 const TString s("some text!");
8
9 UNIT_ASSERT_EQUAL(TCompactStrSpn("mos").FindFirstOf(s.begin(), s.end()), s.begin());
10 UNIT_ASSERT_EQUAL(TCompactStrSpn("mos").FindFirstOf(s.c_str()), s.begin());
11
12 UNIT_ASSERT_EQUAL(TCompactStrSpn("xt").FindFirstOf(s.begin(), s.end()), s.begin() + 5);
13 UNIT_ASSERT_EQUAL(TCompactStrSpn("xt").FindFirstOf(s.c_str()), s.begin() + 5);
14
15 UNIT_ASSERT_EQUAL(TCompactStrSpn(".?!").FindFirstOf(s.begin(), s.end()), s.end() - 1);
16 UNIT_ASSERT_EQUAL(TCompactStrSpn(".?!").FindFirstOf(s.c_str()), s.end() - 1);
17
18 UNIT_ASSERT_EQUAL(TCompactStrSpn("abc").FindFirstOf(s.begin(), s.end()), s.end());
19 UNIT_ASSERT_EQUAL(TCompactStrSpn("abc").FindFirstOf(s.c_str()), s.end());
20
21 // Must be const. If not, non-const begin() will clone the shared empty string
22 // and the next assertion will possibly use invalidated end iterator.
23 const TString empty;
24
25 UNIT_ASSERT_EQUAL(TCompactStrSpn("abc").FindFirstOf(empty.begin(), empty.end()), empty.end());
26 UNIT_ASSERT_EQUAL(TCompactStrSpn("abc").FindFirstOf(empty.c_str()), empty.end());
27 }
28
29 Y_UNIT_TEST(FindFirstNotOf) {
30 const TString s("abacabaxyz");

Callers

nothing calls this directly

Calls 7

FindFirstNotOfMethod · 0.80
FindFirstOfMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
c_strMethod · 0.45
rbeginMethod · 0.45
rendMethod · 0.45

Tested by

no test coverage detected