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:
parent
737a351850
commit
e6440c6fa2
@ -19,8 +19,10 @@
|
|||||||
|
|
||||||
int main()
|
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::in | std::ios_base::out
|
||||||
| std::ios_base::trunc);
|
| std::ios_base::trunc);
|
||||||
double x = 0;
|
double x = 0;
|
||||||
@ -29,9 +31,9 @@ int main()
|
|||||||
fs >> x;
|
fs >> x;
|
||||||
assert(x == 3.25);
|
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::in | std::ios_base::out
|
||||||
| std::ios_base::trunc);
|
| std::ios_base::trunc);
|
||||||
double x = 0;
|
double x = 0;
|
||||||
@ -40,5 +42,5 @@ int main()
|
|||||||
fs >> x;
|
fs >> x;
|
||||||
assert(x == 3.25);
|
assert(x == 3.25);
|
||||||
}
|
}
|
||||||
std::remove("test.dat");
|
std::remove(temp);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user