Support/FileSystem: Add unique_file and exists implementations.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120776 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/unittests/Support/Path.cpp b/unittests/Support/Path.cpp
index a3d96ec..ecf818b 100644
--- a/unittests/Support/Path.cpp
+++ b/unittests/Support/Path.cpp
@@ -7,11 +7,13 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/PathV2.h"
 
 #include "gtest/gtest.h"
 
 using namespace llvm;
+using namespace llvm::sys;
 
 #define TEST_OUT(func, result) outs() << "    " #func ": " << result << '\n';
 
@@ -131,6 +133,22 @@
 
     outs().flush();
   }
+
+  int FileDescriptor;
+  SmallString<64> TempPath;
+  if (error_code ec = sys::fs::unique_file("%%-%%-%%-%%.temp",
+                                            FileDescriptor, TempPath))
+    ASSERT_FALSE(ec.message().c_str());
+
+  bool TempFileExists;
+  ASSERT_FALSE(sys::fs::exists(Twine(TempPath), TempFileExists));
+  EXPECT_TRUE(TempFileExists);
+
+  ::close(FileDescriptor);
+  ::remove(TempPath.begin());
+
+  ASSERT_FALSE(fs::exists(Twine(TempPath), TempFileExists));
+  EXPECT_FALSE(TempFileExists);
 }
 
 } // anonymous namespace