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,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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user