Skip to content
Snippets Groups Projects
Commit a6cc5bca authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add missing tests for OFStream (append mode)

parent b35ad808
Branches
No related tags found
1 merge request!199Integrate checkpointing
......@@ -42,10 +42,40 @@ TEST_CASE("OFStream", "[language]")
std::string content = file_content;
REQUIRE(content == "foo3 bar\n");
}
std::filesystem::remove(filename);
// Ensures that the file is closed after this line
std::make_shared<OFStream>(filename, true) << "new content\n";
if (parallel::rank() == 0) {
REQUIRE(std::filesystem::is_regular_file(filename));
std::ifstream is(filename);
char file_content[21];
int count = 0;
for (size_t i = 0; i < 21; ++i) {
char c = is.get();
file_content[i] = c;
if (c == '\n') {
count++;
if (count == 2) {
file_content[i + 1] = '\0';
REQUIRE(i == 20);
c = is.get();
REQUIRE(is.eof());
break;
}
}
}
std::string content = file_content;
REQUIRE(content == "foo3 bar\nnew content\n");
}
std::filesystem::remove(filename);
REQUIRE(not std::filesystem::exists(filename));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment