Added conditional GCC5 test for file mocking

This commit is contained in:
Snaipe 2015-09-15 19:45:57 +02:00
parent d58fc1598a
commit af835bb95e

View file

@ -5,6 +5,7 @@
// set a timeout for I/O tests
TestSuite(redirect, .timeout = 0.1);
#if __GNUC__ >= 5
Test(redirect, mock) {
auto fmock = criterion::mock_file();
@ -16,6 +17,20 @@ Test(redirect, mock) {
cr_assert_eq(contents, "Hello");
}
#endif
Test(redirect, mock_c) {
std::FILE* fmock = cr_mock_file_size(4096);
std::fprintf(fmock, "Hello");
std::fflush(fmock);
std::rewind(fmock);
char contents[sizeof ("Hello")] = {0};
fgets(contents, sizeof (contents), fmock);
cr_assert_str_eq(contents, "Hello");
}
Test(redirect, stdout_) {
cr_redirect_stdout();