File ctor should take StringPiece.
[folly.git] / folly / test / FileTest.cpp
index 613982d0be9f209f9205bea5fab813fd0f615106..3a120c54c68637dc8986002337ccabe7a4bd7ccd 100644 (file)
@@ -55,6 +55,15 @@ TEST(File, Simple) {
   }
 }
 
+TEST(File, SimpleStringPiece) {
+  char buf = 'x';
+  File f(StringPiece("/etc/hosts"));
+  EXPECT_NE(-1, f.fd());
+  EXPECT_EQ(1, ::read(f.fd(), &buf, 1));
+  f.close();
+  EXPECT_EQ(-1, f.fd());
+}
+
 TEST(File, OwnsFd) {
   // Wrap a file descriptor, make sure that ownsFd works
   // We'll test that the file descriptor is closed by closing the writing