| 1155 | class 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 | |
| 1170 | TEST_F(WriteIntoTest, WriteInto) { |