Commit 77ae0b97 authored by Milo Yip's avatar Milo Yip Committed by GitHub

Merge pull request #987 from sledgeh/master

Fixed #985 : Unittest failed with MinGWx64. And few small improvement…
parents 6a8f672c 6e81d49b
...@@ -69,14 +69,15 @@ static void TestFileStream() { ...@@ -69,14 +69,15 @@ static void TestFileStream() {
const char* s = "Hello World!\n"; const char* s = "Hello World!\n";
{ {
ofstream ofs(filename, ios::out | ios::binary); FileStreamType ofs(filename, ios::out | ios::binary);
BasicOStreamWrapper<ofstream> osw(ofs); BasicOStreamWrapper<FileStreamType> osw(ofs);
for (const char* p = s; *p; p++) for (const char* p = s; *p; p++)
osw.Put(*p); osw.Put(*p);
osw.Flush(); osw.Flush();
} }
fp = fopen(filename, "r"); fp = fopen(filename, "r");
ASSERT_TRUE( fp != NULL );
for (const char* p = s; *p; p++) for (const char* p = s; *p; p++)
EXPECT_EQ(*p, static_cast<char>(fgetc(fp))); EXPECT_EQ(*p, static_cast<char>(fgetc(fp)));
fclose(fp); fclose(fp);
......
...@@ -167,6 +167,7 @@ TEST(PrettyWriter, OStreamWrapper) { ...@@ -167,6 +167,7 @@ TEST(PrettyWriter, OStreamWrapper) {
TEST(PrettyWriter, FileWriteStream) { TEST(PrettyWriter, FileWriteStream) {
char filename[L_tmpnam]; char filename[L_tmpnam];
FILE* fp = TempFile(filename); FILE* fp = TempFile(filename);
ASSERT_TRUE(fp!=NULL);
char buffer[16]; char buffer[16];
FileWriteStream os(fp, buffer, sizeof(buffer)); FileWriteStream os(fp, buffer, sizeof(buffer));
PrettyWriter<FileWriteStream> writer(os); PrettyWriter<FileWriteStream> writer(os);
......
...@@ -78,7 +78,7 @@ inline Ch* StrDup(const Ch* str) { ...@@ -78,7 +78,7 @@ inline Ch* StrDup(const Ch* str) {
} }
inline FILE* TempFile(char *filename) { inline FILE* TempFile(char *filename) {
#ifdef _MSC_VER #if defined(__WIN32__) || defined(_MSC_VER)
filename = tmpnam(filename); filename = tmpnam(filename);
// For Visual Studio, tmpnam() adds a backslash in front. Remove it. // For Visual Studio, tmpnam() adds a backslash in front. Remove it.
......
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