Переглянути джерело

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

Sean Hunt 14 роки тому
батько
коміт
e6440c6fa2

+ 6 - 4
test/input.output/file.streams/fstreams/fstream.cons/string.pass.cpp

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