Commit a81dc61a authored by Tom Jackson's avatar Tom Jackson Committed by facebook-github-bot-9

Add byLine tests for empty cases

Summary: It works fine, this proves it.

Reviewed By: @yfeldblum, @​jkron

Differential Revision: D2509771

fb-gh-sync-id: 28805a1e1db433d3d9a44b9d33f81e30333e44ab
parent d26a3806
......@@ -30,20 +30,30 @@ using std::vector;
TEST(FileGen, ByLine) {
auto collect = eachTo<std::string>() | as<vector>();
test::TemporaryFile file("ByLine");
static const std::string lines(
const std::string cases[] = {
"Hello world\n"
"This is the second line\n"
"\n"
"\n"
"a few empty lines above\n"
"incomplete last line");
EXPECT_EQ(lines.size(), write(file.fd(), lines.data(), lines.size()));
"incomplete last line",
auto expected = from({lines}) | resplit('\n') | collect;
auto found = byLine(file.path().c_str()) | collect;
"complete last line\n",
EXPECT_TRUE(expected == found);
"\n",
"",
};
for (auto& lines : cases) {
test::TemporaryFile file("ByLine");
EXPECT_EQ(lines.size(), write(file.fd(), lines.data(), lines.size()));
auto expected = from({lines}) | resplit('\n') | collect;
auto found = byLine(file.path().c_str()) | collect;
EXPECT_EQ(expected, found) << "For Input: '" << lines << "'";
}
}
class FileGenBufferedTest : public ::testing::TestWithParam<int> { };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment