comparison data/fileio/test/CSVStreamWriterTest.h @ 1438:09c2ba31a711 streaming-csv-writer

Formatting and naming changes more in line with SV conventions.
author Lucas Thompson <dev@lucas.im>
date Tue, 17 Apr 2018 10:03:49 +0100
parents 0684c6698e3f
children 04caefd35391
comparison
equal deleted inserted replaced
1437:de385fed1197 1438:09c2ba31a711
2 2
3 /* 3 /*
4 Sonic Visualiser 4 Sonic Visualiser
5 An audio file viewer and annotation editor. 5 An audio file viewer and annotation editor.
6 Centre for Digital Music, Queen Mary, University of London. 6 Centre for Digital Music, Queen Mary, University of London.
7 This file copyright 2017 Lucas Thompson. 7 This file copyright 2017 Queen Mary, University of London.
8 8
9 This program is free software; you can redistribute it and/or 9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as 10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the 11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file 12 License, or (at your option) any later version. See the file
85 void simpleValidOutput() 85 void simpleValidOutput()
86 { 86 {
87 MockWaveModel mwm({ DC, DC }, 16, 4); 87 MockWaveModel mwm({ DC, DC }, 16, 4);
88 88
89 std::ostringstream oss; 89 std::ostringstream oss;
90 const auto result = CSV::writeToStreamInChunks(oss, mwm); 90 const auto result = CSVStreamWriter::writeInChunks(oss, mwm);
91 QVERIFY( oss.str() == getExpectedString() ); 91 QVERIFY( oss.str() == getExpectedString() );
92 QVERIFY( result ); 92 QVERIFY( result );
93 } 93 }
94 94
95 void callsReporterCorrectTimes() 95 void callsReporterCorrectTimes()
98 StubReporter reporter { []() -> bool { return false; } }; 98 StubReporter reporter { []() -> bool { return false; } };
99 const auto expected = getExpectedString(); 99 const auto expected = getExpectedString();
100 100
101 std::ostringstream oss; 101 std::ostringstream oss;
102 const auto writeStreamWithBlockSize = [&](int blockSize) { 102 const auto writeStreamWithBlockSize = [&](int blockSize) {
103 return CSV::writeToStreamInChunks( 103 return CSVStreamWriter::writeInChunks(
104 oss, 104 oss,
105 mwm, 105 mwm,
106 &reporter, 106 &reporter,
107 ",", 107 ",",
108 DataExportDefaults, 108 DataExportDefaults,
142 { 142 {
143 MockWaveModel mwm({ DC, DC }, 16, 4); 143 MockWaveModel mwm({ DC, DC }, 16, 4);
144 StubReporter reporter { []() -> bool { return true; } }; 144 StubReporter reporter { []() -> bool { return true; } };
145 145
146 std::ostringstream oss; 146 std::ostringstream oss;
147 const auto cancelImmediately = CSV::writeToStreamInChunks( 147 const auto cancelImmediately = CSVStreamWriter::writeInChunks(
148 oss, 148 oss,
149 mwm, 149 mwm,
150 &reporter, 150 &reporter,
151 ",", 151 ",",
152 DataExportDefaults, 152 DataExportDefaults,
156 QVERIFY( reporter.getCallCount() == 0 ); 156 QVERIFY( reporter.getCallCount() == 0 );
157 157
158 StubReporter cancelMidway { 158 StubReporter cancelMidway {
159 [&]() { return cancelMidway.getCallCount() == 3; } 159 [&]() { return cancelMidway.getCallCount() == 3; }
160 }; 160 };
161 const auto cancelledMidway = CSV::writeToStreamInChunks( 161 const auto cancelledMidway = CSVStreamWriter::writeInChunks(
162 oss, 162 oss,
163 mwm, 163 mwm,
164 &cancelMidway, 164 &cancelMidway,
165 ",", 165 ",",
166 DataExportDefaults, 166 DataExportDefaults,