Add ChangeToTempDir to TestUtil
[folly.git] / folly / experimental / test / TestUtilTest.cpp
index eee1515a5020f4e9a1ba2758b0ae83d10ff31aaf..4239c94c394a5b152a3970b253f118c32a5c0bfe 100644 (file)
@@ -100,6 +100,15 @@ TEST(TemporaryDirectory, DeleteOnDestruction) {
   testTemporaryDirectory(TemporaryDirectory::Scope::DELETE_ON_DESTRUCTION);
 }
 
+TEST(ChangeToTempDir, ChangeDir) {
+  auto pwd1 = fs::current_path();
+  {
+    ChangeToTempDir d;
+    EXPECT_NE(pwd1, fs::current_path());
+  }
+  EXPECT_EQ(pwd1, fs::current_path());
+}
+
 int main(int argc, char *argv[]) {
   testing::InitGoogleTest(&argc, argv);
   gflags::ParseCommandLineFlags(&argc, &argv, true);