Fixes unit testing on Visual Studio.
tmpnam() in VS prepends backslash in the path.
This commit is contained in:
parent
23056abad1
commit
4d94a8057d
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
/bin/*
|
||||
/build/*.exe
|
||||
/build/gmake
|
||||
/build/vs*/
|
||||
/thirdparty/lib
|
||||
/intermediate
|
@ -85,7 +85,7 @@ protected:
|
||||
template <typename FileEncoding, typename MemoryEncoding>
|
||||
void TestEncodedOutputStream(const char* expectedFilename, bool putBOM) {
|
||||
char filename[L_tmpnam];
|
||||
tmpnam(filename);
|
||||
TempFilename(filename);
|
||||
|
||||
FILE *fp = fopen(filename, "wb");
|
||||
char buffer[16];
|
||||
@ -114,7 +114,7 @@ protected:
|
||||
|
||||
void TestAutoUTFOutputStream(UTFType type, bool putBOM, const char *expectedFilename) {
|
||||
char filename[L_tmpnam];
|
||||
tmpnam(filename);
|
||||
TempFilename(filename);
|
||||
|
||||
FILE *fp = fopen(filename, "wb");
|
||||
char buffer[16];
|
||||
|
@ -70,7 +70,7 @@ TEST_F(FileStreamTest, FileReadStream) {
|
||||
|
||||
TEST_F(FileStreamTest, FileWriteStream) {
|
||||
char filename[L_tmpnam];
|
||||
tmpnam(filename);
|
||||
TempFilename(filename);
|
||||
|
||||
FILE *fp = fopen(filename, "wb");
|
||||
char buffer[65536];
|
||||
|
@ -30,4 +30,13 @@ inline Ch* StrDup(const Ch* str) {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
inline void TempFilename(char *filename) {
|
||||
tmpnam(filename);
|
||||
|
||||
// For Visual Studio, tmpnam() adds a backslash in front. Remove it.
|
||||
if (filename[0] == '\\')
|
||||
for (int i = 0; filename[i] != '\0'; i++)
|
||||
filename[i] = filename[i + 1];
|
||||
}
|
||||
|
||||
#endif // UNITTEST_H_
|
||||
|
Loading…
x
Reference in New Issue
Block a user