MCPcopy Create free account
hub / github.com/bytedance/bolt / TEST

Function TEST

bolt/type/tests/StringViewTest.cpp:40–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38using namespace bytedance::bolt;
39
40TEST(StringView, basic) {
41 std::string text = "We are stardust, we are golden...";
42 for (int32_t i = 0; i < text.size(); ++i) {
43 std::string subText(text.data(), i);
44
45 LOG(INFO) << "Testing for i = " << i << " subText = " << subText;
46 StringView view = StringView(subText.data(), subText.size());
47 EXPECT_EQ(view.size(), i);
48 EXPECT_EQ(view.isInline(), i <= StringView::kInlineSize);
49 if (view.isInline()) {
50 EXPECT_NE(view.data(), subText.data());
51 } else {
52 EXPECT_EQ(view.data(), subText.data());
53 }
54 EXPECT_EQ(view.materialize(), subText);
55 EXPECT_EQ(view.getString(), subText);
56 EXPECT_EQ(view, StringView(subText.data(), subText.size()));
57
58 std::stringstream viewAsSteam;
59 viewAsSteam << view;
60 EXPECT_EQ(subText, viewAsSteam.str());
61 }
62}
63
64TEST(StringView, comparison) {
65 // Differ in prefix.

Callers

nothing calls this directly

Calls 15

memcpyFunction · 0.85
isInlineMethod · 0.80
strMethod · 0.80
backMethod · 0.80
has_valueMethod · 0.80
linearSearchSimpleFunction · 0.70
StringViewClass · 0.50
sizeMethod · 0.45
dataMethod · 0.45
materializeMethod · 0.45
getStringMethod · 0.45
compareMethod · 0.45

Tested by

no test coverage detected