| 48 | using namespace pdal; |
| 49 | |
| 50 | TEST(FileUtilsTest, test_file_ops) |
| 51 | { |
| 52 | std::string tmp1(Support::temppath("unittest1.tmp")); |
| 53 | std::string tmp2(Support::temppath("unittest2.tmp")); |
| 54 | |
| 55 | // first, clean up from any previous test run |
| 56 | FileUtils::deleteFile(tmp1); |
| 57 | FileUtils::deleteFile(tmp2); |
| 58 | EXPECT_TRUE(FileUtils::fileExists(tmp1)==false); |
| 59 | EXPECT_TRUE(FileUtils::fileExists(tmp2)==false); |
| 60 | |
| 61 | // write test |
| 62 | std::ostream* ostr = FileUtils::createFile(tmp1); |
| 63 | *ostr << "yow"; |
| 64 | FileUtils::closeFile(ostr); |
| 65 | |
| 66 | EXPECT_EQ(FileUtils::fileExists(tmp1), true); |
| 67 | EXPECT_EQ(FileUtils::fileSize(tmp1), 3U); |
| 68 | |
| 69 | // rename test |
| 70 | FileUtils::renameFile(tmp2,tmp1); |
| 71 | EXPECT_TRUE(FileUtils::fileExists(tmp1)==false); |
| 72 | EXPECT_TRUE(FileUtils::fileExists(tmp2)==true); |
| 73 | |
| 74 | // read test |
| 75 | std::istream* istr = FileUtils::openFile(tmp2); |
| 76 | std::string yow; |
| 77 | *istr >> yow; |
| 78 | FileUtils::closeFile(istr); |
| 79 | EXPECT_TRUE(yow=="yow"); |
| 80 | |
| 81 | // delete test |
| 82 | FileUtils::deleteFile(tmp2); |
| 83 | EXPECT_TRUE(FileUtils::fileExists(tmp2)==false); |
| 84 | |
| 85 | EXPECT_THROW(FileUtils::openFile("~foo1.glob"), pdal::pdal_error); |
| 86 | EXPECT_NO_THROW(FileUtils::openFile("foo~1.glob")); |
| 87 | } |
| 88 | |
| 89 | TEST(FileUtilsTest, test_vsi) |
| 90 | { |
nothing calls this directly
no test coverage detected