| 7 | #include <gtest/gtest.h> |
| 8 | |
| 9 | void TestFileLineReaderRaw(const char *pWritten, unsigned WrittenLength, std::initializer_list<const char *> pReads, bool ExpectSuccess, bool WriteBom) |
| 10 | { |
| 11 | CTestInfo Info; |
| 12 | IOHANDLE File = io_open(Info.m_aFilename, IOFLAG_WRITE); |
| 13 | ASSERT_TRUE(File); |
| 14 | if(WriteBom) |
| 15 | { |
| 16 | constexpr const unsigned char UTF8_BOM[] = {0xEF, 0xBB, 0xBF}; |
| 17 | EXPECT_EQ(io_write(File, UTF8_BOM, sizeof(UTF8_BOM)), sizeof(UTF8_BOM)); |
| 18 | } |
| 19 | EXPECT_EQ(io_write(File, pWritten, WrittenLength), WrittenLength); |
| 20 | EXPECT_FALSE(io_close(File)); |
| 21 | |
| 22 | CLineReader LineReader; |
| 23 | const bool ActualSuccess = LineReader.OpenFile(io_open(Info.m_aFilename, IOFLAG_READ)); |
| 24 | ASSERT_EQ(ActualSuccess, ExpectSuccess); |
| 25 | if(ActualSuccess) |
| 26 | { |
| 27 | for(const char *pRead : pReads) |
| 28 | { |
| 29 | const char *pReadLine = LineReader.Get(); |
| 30 | ASSERT_TRUE(pReadLine) << "Line reader returned less lines than expected"; |
| 31 | EXPECT_STREQ(pReadLine, pRead) << "Line reader returned unexpected line"; |
| 32 | } |
| 33 | EXPECT_FALSE(LineReader.Get()) << "Line reader returned more lines than expected"; |
| 34 | } |
| 35 | |
| 36 | fs_remove(Info.m_aFilename); |
| 37 | } |
| 38 | |
| 39 | void TestFileLineReaderRaw(const char *pWritten, unsigned WrittenLength, std::initializer_list<const char *> pReads, bool ExpectSuccess) |
| 40 | { |