MCPcopy Create free account
hub / github.com/dmlc/xgboost / TEST

Function TEST

tests/cpp/common/test_string_view.cc:12–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10
11namespace xgboost {
12TEST(StringView, Basic) {
13 StringView str{"This is a string."};
14 std::stringstream ss;
15 ss << str;
16
17 std::string res = ss.str();
18 ASSERT_EQ(str.size(), res.size());
19 ASSERT_TRUE(std::equal(res.cbegin(), res.cend(), str.cbegin()));
20
21 auto substr = str.substr(5, 2);
22 ASSERT_EQ(substr.size(), 2);
23
24 ASSERT_EQ(StringView{"is"}.size(), 2);
25 ASSERT_TRUE(substr == "is");
26 ASSERT_FALSE(substr != "is");
27 ASSERT_FALSE(substr == "foobar");
28 ASSERT_FALSE(substr == "i");
29
30 ASSERT_TRUE(std::equal(substr.crbegin(), substr.crend(), StringView{"si"}.cbegin()));
31
32 {
33 StringView empty{nullptr};
34 ASSERT_TRUE(empty.empty());
35 }
36 {
37 StringView empty{""};
38 ASSERT_TRUE(empty.empty());
39 StringView empty2{nullptr};
40 ASSERT_EQ(empty, empty2);
41 }
42}
43} // namespace xgboost

Callers

nothing calls this directly

Calls 7

substrMethod · 0.80
crbeginMethod · 0.80
crendMethod · 0.80
sizeMethod · 0.45
cbeginMethod · 0.45
cendMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected