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

for the tests that open new data files.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@135422 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Sean Hunt 2011-07-18 20:46:16 +00:00
parent 737a351850
commit e6440c6fa2

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);
}