Make all fstream tests use tmpnam if creating files, rather than
hard-coded names. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@135444 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user