| 25 | } // namespace |
| 26 | |
| 27 | UNIT_TEST(CSVReaderSmoke) |
| 28 | { |
| 29 | auto const fileName = "test.csv"; |
| 30 | ScopedFile sf(fileName, kCSV1); |
| 31 | { |
| 32 | FileReader fileReader(sf.GetFullPath()); |
| 33 | coding::CSVReader reader(fileReader, false /* hasHeader */); |
| 34 | auto const file = reader.ReadAll(); |
| 35 | TEST_EQUAL(file.size(), 2, ()); |
| 36 | Row const firstRow = {"a", "b", "c", "d"}; |
| 37 | TEST_EQUAL(file[0], firstRow, ()); |
| 38 | Row const secondRow = {"e", "f", "g h"}; |
| 39 | TEST_EQUAL(file[1], secondRow, ()); |
| 40 | } |
| 41 | { |
| 42 | FileReader fileReader(sf.GetFullPath()); |
| 43 | coding::CSVReader reader(fileReader, true /* hasHeader */); |
| 44 | auto const file = reader.ReadAll(); |
| 45 | TEST_EQUAL(file.size(), 1, ()); |
| 46 | Row const headerRow = {"a", "b", "c", "d"}; |
| 47 | TEST_EQUAL(reader.GetHeader(), headerRow, ()); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | UNIT_TEST(CSVReaderReadLine) |
| 52 | { |