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

Function TEST

bolt/vector/tests/ToStringUtilityTest.cpp:47–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45
46namespace {
47TEST(ToStringUtil, stringifyTruncatedElementList) {
48 const auto indexAsString = [](std::stringstream& ss, vector_size_t i) {
49 ss << folly::to<std::string>(i);
50 };
51
52 // no item
53 EXPECT_EQ(
54 stringifyTruncatedElementList(0, 0, 0, ", ", indexAsString), "<empty>");
55 // exact item
56 EXPECT_EQ(
57 stringifyTruncatedElementList(0, 5, 5, ", ", indexAsString),
58 "5 elements starting at 0 {0, 1, 2, 3, 4}");
59 // more items
60 EXPECT_EQ(
61 stringifyTruncatedElementList(1, 3, 2, ", ", indexAsString),
62 "3 elements starting at 1 {1, 2, ...}");
63 // less items
64 EXPECT_EQ(
65 stringifyTruncatedElementList(1, 3, 5, ", ", indexAsString),
66 "3 elements starting at 1 {1, 2, 3}");
67 // zero limit.
68 EXPECT_EQ(
69 stringifyTruncatedElementList(1, 5, 0, ", ", indexAsString),
70 "5 elements starting at 1 {...}");
71 // different delimiter
72 EXPECT_EQ(
73 stringifyTruncatedElementList(0, 3, 5, "<delimiter>", indexAsString),
74 "3 elements starting at 0 {0<delimiter>1<delimiter>2}");
75}
76} // namespace
77} // namespace bytedance::bolt

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected