comparison data/fileio/test/CSVStreamWriterTest.h @ 1446:0a743cd7b83d streaming-csv-writer

Write failing test for multi-selection output - line break issue between regions.
author Lucas Thompson <dev@lucas.im>
date Tue, 17 Apr 2018 10:03:50 +0100
parents 04caefd35391
children 8305d442d1f7
comparison
equal deleted inserted replaced
1445:4437209348ef 1446:0a743cd7b83d
21 #include <sstream> 21 #include <sstream>
22 #include <functional> 22 #include <functional>
23 23
24 #include "base/ProgressReporter.h" 24 #include "base/ProgressReporter.h"
25 #include "base/DataExportOptions.h" 25 #include "base/DataExportOptions.h"
26 #include "base/Selection.h"
26 #include "../CSVStreamWriter.h" 27 #include "../CSVStreamWriter.h"
27 #include "../../model/test/MockWaveModel.h" 28 #include "../../model/test/MockWaveModel.h"
28 29
29 namespace 30 namespace
30 { 31 {
245 "18,1,1\n" 246 "18,1,1\n"
246 "19,1,1" 247 "19,1,1"
247 }; 248 };
248 QVERIFY( oss.str() == expectedOutput ); 249 QVERIFY( oss.str() == expectedOutput );
249 } 250 }
251
252 void multipleSelectionOutput()
253 {
254 MockWaveModel mwm({ DC, DC }, 16, 4);
255 StubReporter reporter { []() -> bool { return false; } };
256 std::ostringstream oss;
257 MultiSelection regions;
258 regions.addSelection({0, 2});
259 regions.addSelection({4, 6});
260 regions.addSelection({16, 18});
261 const std::string expectedOutput {
262 "0,0,0\n"
263 "1,0,0\n"
264 "4,1,1\n"
265 "5,1,1\n"
266 "16,1,1\n"
267 "17,1,1"
268 };
269 const auto wroteMultiSection = CSVStreamWriter::writeInChunks(
270 oss,
271 mwm,
272 regions,
273 &reporter,
274 ",",
275 DataExportDefaults,
276 2
277 );
278 QVERIFY( wroteMultiSection == true );
279 QVERIFY( reporter.getCallCount() == 3 );
280 const std::vector<int> expectedCallLog { 33, 66, 100 };
281 QVERIFY( reporter.getPercentageLog() == expectedCallLog );
282 qDebug("%s", oss.str().c_str());
283 QVERIFY( oss.str() == expectedOutput );
284 }
250 }; 285 };
251 286
252 #endif 287 #endif