Mercurial > hg > svcore
comparison data/fileio/test/CSVStreamWriterTest.h @ 1833:21c792334c2e sensible-delimited-data-strings
Rewrite all the DelimitedDataString stuff so as to return vectors of individual cell strings rather than having the classes add the delimiters themselves. Rename accordingly to names based on StringExport. Take advantage of this in the CSV writer code so as to properly quote cells that contain delimiter characters.
author | Chris Cannam |
---|---|
date | Fri, 03 Apr 2020 17:11:05 +0100 |
parents | 0d89abd631ac |
children | 735b0ccd3f4a |
comparison
equal
deleted
inserted
replaced
1832:7c92c644db20 | 1833:21c792334c2e |
---|---|
92 { | 92 { |
93 MockWaveModel mwm({ DC, DC }, 16, 4); | 93 MockWaveModel mwm({ DC, DC }, 16, 4); |
94 | 94 |
95 std::ostringstream oss; | 95 std::ostringstream oss; |
96 const auto result = CSVStreamWriter::writeInChunks(oss, mwm); | 96 const auto result = CSVStreamWriter::writeInChunks(oss, mwm); |
97 | |
97 QVERIFY( oss.str() == getExpectedString() ); | 98 QVERIFY( oss.str() == getExpectedString() ); |
98 QVERIFY( result ); | 99 QVERIFY( result ); |
99 } | 100 } |
100 | 101 |
101 void callsReporterCorrectTimes() | 102 void callsReporterCorrectTimes() |
301 startFrame += 8; | 302 startFrame += 8; |
302 } | 303 } |
303 // qDebug("Create Expected Output\n"); | 304 // qDebug("Create Expected Output\n"); |
304 | 305 |
305 // NB. removed end line break | 306 // NB. removed end line break |
306 const auto expectedOutput = | 307 QString expectedOutput; |
307 notes.toDelimitedDataString(",", {}, 0, notes.getEndFrame()) | 308 auto rows = notes.toStringExportRows({}, 0, notes.getEndFrame()); |
308 .trimmed(); | 309 for (auto row: rows) { |
310 expectedOutput += StringBits::joinDelimited(row, ",") + "\n"; | |
311 } | |
312 expectedOutput = expectedOutput.trimmed(); | |
309 | 313 |
310 StubReporter reporter { []() -> bool { return false; } }; | 314 StubReporter reporter { []() -> bool { return false; } }; |
311 std::ostringstream oss; | 315 std::ostringstream oss; |
312 // qDebug("End frame: %lld", (long long int)notes.getEndFrame()); | 316 // qDebug("End frame: %lld", (long long int)notes.getEndFrame()); |
313 // qDebug("Write streaming\n"); | 317 // qDebug("Write streaming\n"); |