Make all fstream tests use tmpnam if creating files, rather than

hard-coded names.

llvm-svn: 135444
This commit is contained in:
Alexis Hunt 2011-07-18 23:51:21 +00:00
parent 353404d924
commit 483cf24547
24 changed files with 205 additions and 156 deletions

View File

@ -19,10 +19,12 @@
int main()
{
char temp[L_tmpnam];
tmpnam(temp);
{
std::filebuf f;
assert(f.open("test.dat", std::ios_base::out | std::ios_base::in
| std::ios_base::trunc) != 0);
assert(f.open(temp, std::ios_base::out | std::ios_base::in
| std::ios_base::trunc) != 0);
assert(f.is_open());
assert(f.sputn("123", 3) == 3);
f.pubseekoff(1, std::ios_base::beg);
@ -33,11 +35,11 @@ int main()
assert(f2.is_open());
assert(f2.sgetc() == '2');
}
remove("test.dat");
remove(temp);
{
std::wfilebuf f;
assert(f.open("test.dat", std::ios_base::out | std::ios_base::in
| std::ios_base::trunc) != 0);
assert(f.open(temp, std::ios_base::out | std::ios_base::in
| std::ios_base::trunc) != 0);
assert(f.is_open());
assert(f.sputn(L"123", 3) == 3);
f.pubseekoff(1, std::ios_base::beg);
@ -48,5 +50,5 @@ int main()
assert(f2.is_open());
assert(f2.sgetc() == L'2');
}
remove("test.dat");
remove(temp);
}

View File

@ -20,10 +20,12 @@
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
char temp[L_tmpnam];
tmpnam(temp);
{
std::filebuf f;
assert(f.open("test.dat", std::ios_base::out | std::ios_base::in
| std::ios_base::trunc) != 0);
assert(f.open(temp, std::ios_base::out | std::ios_base::in
| std::ios_base::trunc) != 0);
assert(f.is_open());
assert(f.sputn("123", 3) == 3);
f.pubseekoff(1, std::ios_base::beg);
@ -34,11 +36,11 @@ int main()
assert(f2.is_open());
assert(f2.sgetc() == '2');
}
remove("test.dat");
remove(temp);
{
std::wfilebuf f;
assert(f.open("test.dat", std::ios_base::out | std::ios_base::in
| std::ios_base::trunc) != 0);
assert(f.open(temp, std::ios_base::out | std::ios_base::in
| std::ios_base::trunc) != 0);
assert(f.is_open());
assert(f.sputn(L"123", 3) == 3);
f.pubseekoff(1, std::ios_base::beg);
@ -49,6 +51,6 @@ int main()
assert(f2.is_open());
assert(f2.sgetc() == L'2');
}
remove("test.dat");
remove(temp);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@ -21,10 +21,12 @@
int main()
{
char temp[L_tmpnam];
tmpnam(temp);
{
std::filebuf f;
assert(f.open("test.dat", std::ios_base::out | std::ios_base::in
| std::ios_base::trunc) != 0);
assert(f.open(temp, std::ios_base::out | std::ios_base::in
| std::ios_base::trunc) != 0);
assert(f.is_open());
assert(f.sputn("123", 3) == 3);
f.pubseekoff(1, std::ios_base::beg);
@ -35,11 +37,11 @@ int main()
assert(f2.is_open());
assert(f2.sgetc() == '2');
}
remove("test.dat");
remove(temp);
{
std::wfilebuf f;
assert(f.open("test.dat", std::ios_base::out | std::ios_base::in
| std::ios_base::trunc) != 0);
assert(f.open(temp, std::ios_base::out | std::ios_base::in
| std::ios_base::trunc) != 0);
assert(f.is_open());
assert(f.sputn(L"123", 3) == 3);
f.pubseekoff(1, std::ios_base::beg);
@ -50,5 +52,5 @@ int main()
assert(f2.is_open());
assert(f2.sgetc() == L'2');
}
remove("test.dat");
remove(temp);
}

View File

@ -20,10 +20,12 @@
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
char temp[L_tmpnam];
tmpnam(temp);
{
std::filebuf f;
assert(f.open("test.dat", std::ios_base::out | std::ios_base::in
| std::ios_base::trunc) != 0);
assert(f.open(temp, std::ios_base::out | std::ios_base::in
| std::ios_base::trunc) != 0);
assert(f.is_open());
assert(f.sputn("123", 3) == 3);
f.pubseekoff(1, std::ios_base::beg);
@ -33,11 +35,11 @@ int main()
assert(f2.is_open());
assert(f2.sgetc() == '2');
}
remove("test.dat");
remove(temp);
{
std::wfilebuf f;
assert(f.open("test.dat", std::ios_base::out | std::ios_base::in
| std::ios_base::trunc) != 0);
assert(f.open(temp, std::ios_base::out | std::ios_base::in
| std::ios_base::trunc) != 0);
assert(f.is_open());
assert(f.sputn(L"123", 3) == 3);
f.pubseekoff(1, std::ios_base::beg);
@ -47,6 +49,6 @@ int main()
assert(f2.is_open());
assert(f2.sgetc() == L'2');
}
remove("test.dat");
remove(temp);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@ -16,34 +16,36 @@
int main()
{
char temp[L_tmpnam];
tmpnam(temp);
{
std::filebuf f;
assert(f.open("test.dat", std::ios_base::out) != 0);
assert(f.open(temp, std::ios_base::out) != 0);
assert(f.is_open());
assert(f.sputn("123", 3) == 3);
}
{
std::filebuf f;
assert(f.open("test.dat", std::ios_base::in) != 0);
assert(f.open(temp, std::ios_base::in) != 0);
assert(f.is_open());
assert(f.sbumpc() == '1');
assert(f.sbumpc() == '2');
assert(f.sbumpc() == '3');
}
remove("test.dat");
remove(temp);
{
std::wfilebuf f;
assert(f.open("test.dat", std::ios_base::out) != 0);
assert(f.open(temp, std::ios_base::out) != 0);
assert(f.is_open());
assert(f.sputn(L"123", 3) == 3);
}
{
std::wfilebuf f;
assert(f.open("test.dat", std::ios_base::in) != 0);
assert(f.open(temp, std::ios_base::in) != 0);
assert(f.is_open());
assert(f.sbumpc() == L'1');
assert(f.sbumpc() == L'2');
assert(f.sbumpc() == L'3');
}
remove("test.dat");
remove(temp);
}

View File

@ -19,11 +19,14 @@
int main()
{
char temp1[L_tmpnam], temp2[L_tmpnam];
tmpnam(temp1);
tmpnam(temp2);
{
std::fstream fs1("test1.dat", std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
std::fstream fs2("test2.dat", std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
std::fstream fs1(temp1, std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
std::fstream fs2(temp2, std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
fs1 << 1 << ' ' << 2;
fs2 << 2 << ' ' << 1;
fs1.seekg(0);
@ -40,13 +43,13 @@ int main()
fs2 >> i;
assert(i == 2);
}
std::remove("test1.dat");
std::remove("test2.dat");
std::remove(temp1);
std::remove(temp2);
{
std::wfstream fs1("test1.dat", std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
std::wfstream fs2("test2.dat", std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
std::wfstream fs1(temp1, std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
std::wfstream fs2(temp2, std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
fs1 << 1 << ' ' << 2;
fs2 << 2 << ' ' << 1;
fs1.seekg(0);
@ -63,6 +66,6 @@ int main()
fs2 >> i;
assert(i == 2);
}
std::remove("test1.dat");
std::remove("test2.dat");
std::remove(temp1);
std::remove(temp2);
}

View File

@ -20,9 +20,10 @@
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
char temp[L_tmpnam];
{
std::fstream fso("test.dat", std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
std::fstream fso(temp, std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
std::fstream fs;
fs = move(fso);
double x = 0;
@ -31,10 +32,10 @@ int main()
fs >> x;
assert(x == 3.25);
}
std::remove("test.dat");
std::remove(temp);
{
std::wfstream fso("test.dat", std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
std::wfstream fso(temp, std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
std::wfstream fs;
fs = move(fso);
double x = 0;
@ -43,6 +44,6 @@ int main()
fs >> x;
assert(x == 3.25);
}
std::remove("test.dat");
std::remove(temp);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@ -20,11 +20,14 @@
int main()
{
char temp1[L_tmpnam], temp2[L_tmpnam];
tmpnam(temp1);
tmpnam(temp2);
{
std::fstream fs1("test1.dat", std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
std::fstream fs2("test2.dat", std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
std::fstream fs1(temp1, std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
std::fstream fs2(temp2, std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
fs1 << 1 << ' ' << 2;
fs2 << 2 << ' ' << 1;
fs1.seekg(0);
@ -41,13 +44,13 @@ int main()
fs2 >> i;
assert(i == 2);
}
std::remove("test1.dat");
std::remove("test2.dat");
std::remove(temp1);
std::remove(temp2);
{
std::wfstream fs1("test1.dat", std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
std::wfstream fs2("test2.dat", std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
std::wfstream fs1(temp1, std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
std::wfstream fs2(temp2, std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
fs1 << 1 << ' ' << 2;
fs2 << 2 << ' ' << 1;
fs1.seekg(0);
@ -64,6 +67,6 @@ int main()
fs2 >> i;
assert(i == 2);
}
std::remove("test1.dat");
std::remove("test2.dat");
std::remove(temp1);
std::remove(temp2);
}

View File

@ -20,9 +20,11 @@
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
char temp[L_tmpnam];
tmpnam(temp);
{
std::fstream fso("test.dat", std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
std::fstream fso(temp, std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
std::fstream fs = move(fso);
double x = 0;
fs << 3.25;
@ -32,8 +34,8 @@ int main()
}
std::remove("test.dat");
{
std::wfstream fso("test.dat", std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
std::wfstream fso(temp, std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
std::wfstream fs = move(fso);
double x = 0;
fs << 3.25;
@ -41,6 +43,6 @@ int main()
fs >> x;
assert(x == 3.25);
}
std::remove("test.dat");
std::remove(temp);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@ -19,24 +19,26 @@
int main()
{
char temp[L_tmpnam];
tmpnam(temp);
{
std::fstream fs("test.dat", std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
std::fstream fs(temp, std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
double x = 0;
fs << 3.25;
fs.seekg(0);
fs >> x;
assert(x == 3.25);
}
std::remove("test.dat");
std::remove(temp);
{
std::wfstream fs("test.dat", std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
std::wfstream fs(temp, std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
double x = 0;
fs << 3.25;
fs.seekg(0);
fs >> x;
assert(x == 3.25);
}
std::remove("test.dat");
std::remove(temp);
}

View File

@ -19,7 +19,7 @@
int main()
{
char temp [L_tmpnam];
char temp[L_tmpnam];
tmpnam(temp);
{
std::fstream fs(std::string(temp),

View File

@ -19,22 +19,24 @@
int main()
{
char temp[L_tmpnam];
tmpnam(temp);
{
std::fstream fs;
assert(!fs.is_open());
fs.open("test.dat", std::ios_base::out);
fs.open(temp, std::ios_base::out);
assert(fs.is_open());
fs.close();
assert(!fs.is_open());
}
remove("test.dat");
remove(temp);
{
std::wfstream fs;
assert(!fs.is_open());
fs.open("test.dat", std::ios_base::out);
fs.open(temp, std::ios_base::out);
assert(fs.is_open());
fs.close();
assert(!fs.is_open());
}
remove("test.dat");
remove(temp);
}

View File

@ -19,11 +19,13 @@
int main()
{
char temp[L_tmpnam];
tmpnam(temp);
{
std::fstream fs;
assert(!fs.is_open());
fs.open("test.dat", std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
fs.open(temp, std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
assert(fs.is_open());
double x = 0;
fs << 3.25;
@ -31,12 +33,12 @@ int main()
fs >> x;
assert(x == 3.25);
}
std::remove("test.dat");
std::remove(temp);
{
std::wfstream fs;
assert(!fs.is_open());
fs.open("test.dat", std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
fs.open(temp, std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
assert(fs.is_open());
double x = 0;
fs << 3.25;
@ -44,5 +46,5 @@ int main()
fs >> x;
assert(x == 3.25);
}
std::remove("test.dat");
std::remove(temp);
}

View File

@ -19,11 +19,13 @@
int main()
{
char temp[L_tmpnam];
tmpnam(temp);
{
std::fstream fs;
assert(!fs.is_open());
fs.open(std::string("test.dat"), std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
fs.open(std::string(temp), std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
assert(fs.is_open());
double x = 0;
fs << 3.25;
@ -31,12 +33,12 @@ int main()
fs >> x;
assert(x == 3.25);
}
std::remove("test.dat");
std::remove(temp);
{
std::wfstream fs;
assert(!fs.is_open());
fs.open(std::string("test.dat"), std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
fs.open(std::string(temp), std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
assert(fs.is_open());
double x = 0;
fs << 3.25;
@ -44,5 +46,5 @@ int main()
fs >> x;
assert(x == 3.25);
}
std::remove("test.dat");
std::remove(temp);
}

View File

@ -19,9 +19,12 @@
int main()
{
char temp1[L_tmpnam], temp2[L_tmpnam];
tmpnam(temp1);
tmpnam(temp2);
{
std::ofstream fs1("test1.dat");
std::ofstream fs2("test2.dat");
std::ofstream fs1(temp1);
std::ofstream fs2(temp2);
fs1 << 3.25;
fs2 << 4.5;
fs1.swap(fs2);
@ -29,26 +32,26 @@ int main()
fs2 << ' ' << 4.5;
}
{
std::ifstream fs("test1.dat");
std::ifstream fs(temp1);
double x = 0;
fs >> x;
assert(x == 3.25);
fs >> x;
assert(x == 4.5);
}
remove("test1.dat");
remove(temp1);
{
std::ifstream fs("test2.dat");
std::ifstream fs(temp2);
double x = 0;
fs >> x;
assert(x == 4.5);
fs >> x;
assert(x == 3.25);
}
remove("test2.dat");
remove(temp2);
{
std::wofstream fs1("test1.dat");
std::wofstream fs2("test2.dat");
std::wofstream fs1(temp1);
std::wofstream fs2(temp2);
fs1 << 3.25;
fs2 << 4.5;
fs1.swap(fs2);
@ -56,21 +59,21 @@ int main()
fs2 << ' ' << 4.5;
}
{
std::wifstream fs("test1.dat");
std::wifstream fs(temp1);
double x = 0;
fs >> x;
assert(x == 3.25);
fs >> x;
assert(x == 4.5);
}
remove("test1.dat");
remove(temp1);
{
std::wifstream fs("test2.dat");
std::wifstream fs(temp2);
double x = 0;
fs >> x;
assert(x == 4.5);
fs >> x;
assert(x == 3.25);
}
remove("test2.dat");
remove(temp2);
}

View File

@ -20,31 +20,33 @@
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
char temp[L_tmpnam];
tmpnam(temp);
{
std::ofstream fso("test.dat");
std::ofstream fso(temp);
std::ofstream fs;
fs = move(fso);
fs << 3.25;
}
{
std::ifstream fs("test.dat");
std::ifstream fs(temp);
double x = 0;
fs >> x;
assert(x == 3.25);
}
remove("test.dat");
remove(temp);
{
std::wofstream fso("test.dat");
std::wofstream fso(temp);
std::wofstream fs;
fs = move(fso);
fs << 3.25;
}
{
std::wifstream fs("test.dat");
std::wifstream fs(temp);
double x = 0;
fs >> x;
assert(x == 3.25);
}
remove("test.dat");
remove(temp);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@ -20,9 +20,12 @@
int main()
{
char temp1[L_tmpnam], temp2[L_tmpnam];
tmpnam(temp1);
tmpnam(temp2);
{
std::ofstream fs1("test1.dat");
std::ofstream fs2("test2.dat");
std::ofstream fs1(temp1);
std::ofstream fs2(temp2);
fs1 << 3.25;
fs2 << 4.5;
swap(fs1, fs2);
@ -30,26 +33,26 @@ int main()
fs2 << ' ' << 4.5;
}
{
std::ifstream fs("test1.dat");
std::ifstream fs(temp1);
double x = 0;
fs >> x;
assert(x == 3.25);
fs >> x;
assert(x == 4.5);
}
remove("test1.dat");
remove(temp1);
{
std::ifstream fs("test2.dat");
std::ifstream fs(temp2);
double x = 0;
fs >> x;
assert(x == 4.5);
fs >> x;
assert(x == 3.25);
}
remove("test2.dat");
remove(temp2);
{
std::wofstream fs1("test1.dat");
std::wofstream fs2("test2.dat");
std::wofstream fs1(temp1);
std::wofstream fs2(temp2);
fs1 << 3.25;
fs2 << 4.5;
swap(fs1, fs2);
@ -57,21 +60,21 @@ int main()
fs2 << ' ' << 4.5;
}
{
std::wifstream fs("test1.dat");
std::wifstream fs(temp1);
double x = 0;
fs >> x;
assert(x == 3.25);
fs >> x;
assert(x == 4.5);
}
remove("test1.dat");
remove(temp1);
{
std::wifstream fs("test2.dat");
std::wifstream fs(temp2);
double x = 0;
fs >> x;
assert(x == 4.5);
fs >> x;
assert(x == 3.25);
}
remove("test2.dat");
remove(temp2);
}

View File

@ -20,29 +20,31 @@
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
char temp[L_tmpnam];
tmpnam(temp);
{
std::ofstream fso("test.dat");
std::ofstream fso(temp);
std::ofstream fs = move(fso);
fs << 3.25;
}
{
std::ifstream fs("test.dat");
std::ifstream fs(temp);
double x = 0;
fs >> x;
assert(x == 3.25);
}
remove("test.dat");
remove(temp);
{
std::wofstream fso("test.dat");
std::wofstream fso(temp);
std::wofstream fs = move(fso);
fs << 3.25;
}
{
std::wifstream fs("test.dat");
std::wifstream fs(temp);
double x = 0;
fs >> x;
assert(x == 3.25);
}
remove("test.dat");
remove(temp);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@ -19,26 +19,28 @@
int main()
{
char temp[L_tmpnam];
tmpnam(temp);
{
std::ofstream fs("test.dat");
std::ofstream fs(temp);
fs << 3.25;
}
{
std::ifstream fs("test.dat");
std::ifstream fs(temp);
double x = 0;
fs >> x;
assert(x == 3.25);
}
remove("test.dat");
remove(temp);
{
std::wofstream fs("test.dat");
std::wofstream fs(temp);
fs << 3.25;
}
{
std::wifstream fs("test.dat");
std::wifstream fs(temp);
double x = 0;
fs >> x;
assert(x == 3.25);
}
remove("test.dat");
remove(temp);
}

View File

@ -19,26 +19,28 @@
int main()
{
char temp[L_tmpnam];
tmpnam(temp);
{
std::ofstream fs(std::string("test.dat"));
std::ofstream fs((std::string(temp)));
fs << 3.25;
}
{
std::ifstream fs(std::string("test.dat"));
std::ifstream fs((std::string(temp)));
double x = 0;
fs >> x;
assert(x == 3.25);
}
remove("test.dat");
remove(temp);
{
std::wofstream fs(std::string("test.dat"));
std::wofstream fs((std::string(temp)));
fs << 3.25;
}
{
std::wifstream fs(std::string("test.dat"));
std::wifstream fs((std::string(temp)));
double x = 0;
fs >> x;
assert(x == 3.25);
}
remove("test.dat");
remove(temp);
}

View File

@ -19,22 +19,24 @@
int main()
{
char temp[L_tmpnam];
tmpnam(temp);
{
std::ofstream fs;
assert(!fs.is_open());
fs.open("test.dat");
fs.open(temp);
assert(fs.is_open());
fs.close();
assert(!fs.is_open());
}
remove("test.dat");
remove(temp);
{
std::wofstream fs;
assert(!fs.is_open());
fs.open("test.dat");
fs.open(temp);
assert(fs.is_open());
fs.close();
assert(!fs.is_open());
}
remove("test.dat");
remove(temp);
}

View File

@ -19,38 +19,40 @@
int main()
{
char temp[L_tmpnam];
tmpnam(temp);
{
std::ofstream fs;
assert(!fs.is_open());
char c = 'a';
fs << c;
assert(fs.fail());
fs.open("test.dat");
fs.open(temp);
assert(fs.is_open());
fs << c;
}
{
std::ifstream fs("test.dat");
std::ifstream fs(temp);
char c = 0;
fs >> c;
assert(c == 'a');
}
remove("test.dat");
remove(temp);
{
std::wofstream fs;
assert(!fs.is_open());
wchar_t c = L'a';
fs << c;
assert(fs.fail());
fs.open("test.dat");
fs.open(temp);
assert(fs.is_open());
fs << c;
}
{
std::wifstream fs("test.dat");
std::wifstream fs(temp);
wchar_t c = 0;
fs >> c;
assert(c == L'a');
}
remove("test.dat");
remove(temp);
}

View File

@ -19,38 +19,40 @@
int main()
{
char temp[L_tmpnam];
tmpnam(temp);
{
std::ofstream fs;
assert(!fs.is_open());
char c = 'a';
fs << c;
assert(fs.fail());
fs.open(std::string("test.dat"));
fs.open(std::string(temp));
assert(fs.is_open());
fs << c;
}
{
std::ifstream fs("test.dat");
std::ifstream fs(temp);
char c = 0;
fs >> c;
assert(c == 'a');
}
remove("test.dat");
remove(temp);
{
std::wofstream fs;
assert(!fs.is_open());
wchar_t c = L'a';
fs << c;
assert(fs.fail());
fs.open(std::string("test.dat"));
fs.open(std::string(temp));
assert(fs.is_open());
fs << c;
}
{
std::wifstream fs("test.dat");
std::wifstream fs(temp);
wchar_t c = 0;
fs >> c;
assert(c == L'a');
}
remove("test.dat");
remove(temp);
}

View File

@ -19,16 +19,18 @@
int main()
{
char temp[L_tmpnam];
tmpnam(temp);
{
std::ofstream fs("test.dat");
std::ofstream fs(temp);
std::filebuf* fb = fs.rdbuf();
assert(fb->sputc('r') == 'r');
}
remove("test.dat");
remove(temp);
{
std::wofstream fs("test.dat");
std::wofstream fs(temp);
std::wfilebuf* fb = fs.rdbuf();
assert(fb->sputc(L'r') == L'r');
}
remove("test.dat");
remove(temp);
}