| 43 | using namespace pdal; |
| 44 | |
| 45 | TEST(VSITest, test_tells) |
| 46 | { |
| 47 | int bufSize = 2; |
| 48 | Support::Tempfile temp(true); |
| 49 | std::string tmp = temp.filename(); |
| 50 | EXPECT_TRUE(FileUtils::fileExists(tmp)==false); |
| 51 | |
| 52 | // write test |
| 53 | VSI::VSIOStream* ostr = new VSI::VSIOStream( |
| 54 | tmp, std::ios::out | std::ios::binary, bufSize); |
| 55 | |
| 56 | *ostr << "TEST"; |
| 57 | EXPECT_EQ(ostr->tellp(), 4); |
| 58 | *ostr << "12345"; |
| 59 | EXPECT_EQ(ostr->tellp(), 9); |
| 60 | delete ostr; |
| 61 | |
| 62 | EXPECT_EQ(FileUtils::fileExists(tmp), true); |
| 63 | EXPECT_EQ(FileUtils::fileSize(tmp), 9U); |
| 64 | |
| 65 | // read test |
| 66 | VSI::VSIIStream* istr = new VSI::VSIIStream( |
| 67 | tmp, std::ios::in | std::ios::binary, bufSize); |
| 68 | auto _ = istr->get(); |
| 69 | EXPECT_EQ(istr->tellg(), 1); |
| 70 | char str[4]; |
| 71 | istr->get(str, 4); |
| 72 | EXPECT_EQ(istr->tellg(), 4); |
| 73 | EXPECT_EQ(std::string(str), "EST"); |
| 74 | std::string s; |
| 75 | *istr >> s; |
| 76 | EXPECT_EQ(s, "12345"); |
| 77 | EXPECT_EQ(istr->tellg(), -1); // EoF |
| 78 | delete istr; |
| 79 | } |
| 80 | |
| 81 | TEST(VSITest, test_seeks_small_buffer) |
| 82 | { |
nothing calls this directly
no test coverage detected