# HG changeset patch # User Lucas Thompson # Date 1523955830 -3600 # Node ID 0a743cd7b83da52152cb0bad26b16034f4b0434b # Parent 4437209348efcfac7ffd1fef1bb81a8451d9a2ec Write failing test for multi-selection output - line break issue between regions. diff -r 4437209348ef -r 0a743cd7b83d data/fileio/test/CSVStreamWriterTest.h --- a/data/fileio/test/CSVStreamWriterTest.h Tue Apr 17 10:03:50 2018 +0100 +++ b/data/fileio/test/CSVStreamWriterTest.h Tue Apr 17 10:03:50 2018 +0100 @@ -23,6 +23,7 @@ #include "base/ProgressReporter.h" #include "base/DataExportOptions.h" +#include "base/Selection.h" #include "../CSVStreamWriter.h" #include "../../model/test/MockWaveModel.h" @@ -247,6 +248,40 @@ }; QVERIFY( oss.str() == expectedOutput ); } + + void multipleSelectionOutput() + { + MockWaveModel mwm({ DC, DC }, 16, 4); + StubReporter reporter { []() -> bool { return false; } }; + std::ostringstream oss; + MultiSelection regions; + regions.addSelection({0, 2}); + regions.addSelection({4, 6}); + regions.addSelection({16, 18}); + const std::string expectedOutput { + "0,0,0\n" + "1,0,0\n" + "4,1,1\n" + "5,1,1\n" + "16,1,1\n" + "17,1,1" + }; + const auto wroteMultiSection = CSVStreamWriter::writeInChunks( + oss, + mwm, + regions, + &reporter, + ",", + DataExportDefaults, + 2 + ); + QVERIFY( wroteMultiSection == true ); + QVERIFY( reporter.getCallCount() == 3 ); + const std::vector expectedCallLog { 33, 66, 100 }; + QVERIFY( reporter.getPercentageLog() == expectedCallLog ); + qDebug("%s", oss.str().c_str()); + QVERIFY( oss.str() == expectedOutput ); + } }; #endif \ No newline at end of file