| 7 | #include <gtest/gtest.h> |
| 8 | |
| 9 | static void Expect(int NumColumns, const char *const *ppColumns, const char *pExpected) |
| 10 | { |
| 11 | CTestInfo Info; |
| 12 | |
| 13 | IOHANDLE File = io_open(Info.m_aFilename, IOFLAG_WRITE); |
| 14 | ASSERT_TRUE(File); |
| 15 | CsvWrite(File, NumColumns, ppColumns); |
| 16 | io_close(File); |
| 17 | |
| 18 | char aBuf[1024]; |
| 19 | File = io_open(Info.m_aFilename, IOFLAG_READ); |
| 20 | ASSERT_TRUE(File); |
| 21 | int Read = io_read(File, aBuf, sizeof(aBuf)); |
| 22 | io_close(File); |
| 23 | fs_remove(Info.m_aFilename); |
| 24 | |
| 25 | ASSERT_TRUE(Read >= 1); |
| 26 | Read -= 1; |
| 27 | ASSERT_EQ(aBuf[Read], '\n'); |
| 28 | aBuf[Read] = 0; |
| 29 | |
| 30 | #if defined(CONF_FAMILY_WINDOWS) |
| 31 | ASSERT_TRUE(Read >= 1); |
| 32 | Read -= 1; |
| 33 | ASSERT_EQ(aBuf[Read], '\r'); |
| 34 | aBuf[Read] = 0; |
| 35 | #endif |
| 36 | |
| 37 | for(int i = 0; i < Read; i++) |
| 38 | { |
| 39 | EXPECT_NE(aBuf[i], 0); |
| 40 | } |
| 41 | EXPECT_STREQ(aBuf, pExpected); |
| 42 | } |
| 43 | |
| 44 | TEST(Csv, Simple) |
| 45 | { |