MCPcopy Create free account
hub / github.com/apache/brpc / WritesCorrectly

Method WritesCorrectly

test/string_util_unittest.cc:1157–1167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1155class WriteIntoTest : public testing::Test {
1156 protected:
1157 static void WritesCorrectly(size_t num_chars) {
1158 std::string buffer;
1159 char kOriginal[] = "supercali";
1160 strncpy(WriteInto(&buffer, num_chars + 1), kOriginal, num_chars);
1161 // Using std::string(buffer.c_str()) instead of |buffer| truncates the
1162 // string at the first \0.
1163 EXPECT_EQ(std::string(kOriginal,
1164 std::min(num_chars, arraysize(kOriginal) - 1)),
1165 std::string(buffer.c_str()));
1166 EXPECT_EQ(num_chars, buffer.size());
1167 }
1168};
1169
1170TEST_F(WriteIntoTest, WriteInto) {

Callers

nothing calls this directly

Calls 3

WriteIntoFunction · 0.85
c_strMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected