Fix warning.

This commit is contained in:
Victor Zverovich 2014-05-14 07:45:21 -07:00
parent d2e7554f74
commit c3b3c0fafe

View File

@ -27,7 +27,6 @@
#include "gtest-extra.h" #include "gtest-extra.h"
#include <cstdio>
#include <cstring> #include <cstring>
#include <algorithm> #include <algorithm>
#include <stdexcept> #include <stdexcept>
@ -63,8 +62,18 @@ class SuppressAssert {
}; };
# define SUPPRESS_ASSERT(statement) { SuppressAssert sa; statement; } # define SUPPRESS_ASSERT(statement) { SuppressAssert sa; statement; }
// Fix "secure" warning about using fopen without defining
// _CRT_SECURE_NO_WARNINGS.
std::FILE *OpenFile(const char *filename, const char *mode) {
std::FILE *f = 0;
errno = fopen_s(&f, filename, mode);
return f;
}
#define fopen OpenFile
#else #else
# define SUPPRESS_ASSERT(statement) statement # define SUPPRESS_ASSERT(statement) statement
using std::fopen;
#endif // _WIN32 #endif // _WIN32
#define EXPECT_SYSTEM_ERROR_NOASSERT(statement, error_code, message) \ #define EXPECT_SYSTEM_ERROR_NOASSERT(statement, error_code, message) \
@ -419,7 +428,7 @@ TEST(FileTest, DefaultCtor) {
} }
TEST(FileTest, OpenBufferedFileInCtor) { TEST(FileTest, OpenBufferedFileInCtor) {
FILE *fp = std::fopen("test-file", "w"); FILE *fp = fopen("test-file", "w");
std::fputs(FILE_CONTENT, fp); std::fputs(FILE_CONTENT, fp);
std::fclose(fp); std::fclose(fp);
File f("test-file", File::RDONLY); File f("test-file", File::RDONLY);