Added conditional GCC5 test for file mocking
This commit is contained in:
parent
d58fc1598a
commit
af835bb95e
1 changed files with 15 additions and 0 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue