Do a litmus test of using tmpnam to generate safe temporary file names

for the tests that open new data files.

llvm-svn: 135422
This commit is contained in:
Alexis Hunt 2011-07-18 20:46:16 +00:00
parent 276aab5a21
commit 4c14ed75ee
1 changed files with 6 additions and 4 deletions

View File

@ -19,8 +19,10 @@
int main()
{
char temp [L_tmpnam];
tmpnam(temp);
{
std::fstream fs(std::string("test.dat"),
std::fstream fs(std::string(temp),
std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
double x = 0;
@ -29,9 +31,9 @@ int main()
fs >> x;
assert(x == 3.25);
}
std::remove("test.dat");
std::remove(temp);
{
std::wfstream fs(std::string("test.dat"),
std::wfstream fs(std::string(temp),
std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
double x = 0;
@ -40,5 +42,5 @@ int main()
fs >> x;
assert(x == 3.25);
}
std::remove("test.dat");
std::remove(temp);
}