comparison data/fileio/test/svcore-data-fileio-test.cpp @ 1430:b5283878cca2 streaming-csv-writer

Introduce a TestHelper which contains boiler plate for running a suite of QtTest style objects. Stub CSVStreamWriter and test to integrate into build.
author Lucas Thompson <dev@lucas.im>
date Tue, 17 Apr 2018 10:03:49 +0100
parents 667e369cfeab
children de385fed1197
comparison
equal deleted inserted replaced
1425:bd73a689c8af 1430:b5283878cca2
10 published by the Free Software Foundation; either version 2 of the 10 published by the Free Software Foundation; either version 2 of the
11 License, or (at your option) any later version. See the file 11 License, or (at your option) any later version. See the file
12 COPYING included with this distribution for more information. 12 COPYING included with this distribution for more information.
13 */ 13 */
14 14
15 #include "../../../test/TestHelper.h"
15 #include "AudioFileReaderTest.h" 16 #include "AudioFileReaderTest.h"
16 #include "AudioFileWriterTest.h" 17 #include "AudioFileWriterTest.h"
17 #include "EncodingTest.h" 18 #include "EncodingTest.h"
18 #include "MIDIFileReaderTest.h" 19 #include "MIDIFileReaderTest.h"
19 20 #include "CSVStreamWriterTest.h"
20 #include <QtTest>
21
22 #include <iostream>
23 21
24 int main(int argc, char *argv[]) 22 int main(int argc, char *argv[])
25 { 23 {
26 int good = 0, bad = 0;
27
28 QString testDir; 24 QString testDir;
29 25
30 #ifdef Q_OS_WIN 26 #ifdef Q_OS_WIN
31 // incredible to have to hardcode this, but I just can't figure out how to 27 // incredible to have to hardcode this, but I just can't figure out how to
32 // get QMAKE_POST_LINK to add an arg to its command successfully on Windows 28 // get QMAKE_POST_LINK to add an arg to its command successfully on Windows
40 36
41 if (testDir != "") { 37 if (testDir != "") {
42 cerr << "Setting test directory base path to \"" << testDir << "\"" << endl; 38 cerr << "Setting test directory base path to \"" << testDir << "\"" << endl;
43 } 39 }
44 40
45 QCoreApplication app(argc, argv); 41 return Test::startTestRunner(
46 app.setOrganizationName("sonic-visualiser"); 42 {
47 app.setApplicationName("test-fileio"); 43 Test::createFactory<AudioFileReaderTest>(testDir),
48 44 Test::createFactory<AudioFileWriterTest>(testDir),
49 { 45 Test::createFactory<EncodingTest>(testDir),
50 AudioFileReaderTest t(testDir); 46 Test::createFactory<MIDIFileReaderTest>(testDir),
51 if (QTest::qExec(&t, argc, argv) == 0) ++good; 47 Test::createFactory<CSVStreamWriterTest>()
52 else ++bad; 48 },
53 } 49 argc,
54 50 argv,
55 { 51 "test-fileio"
56 AudioFileWriterTest t(testDir); 52 );
57 if (QTest::qExec(&t, argc, argv) == 0) ++good;
58 else ++bad;
59 }
60
61 {
62 EncodingTest t(testDir);
63 if (QTest::qExec(&t, argc, argv) == 0) ++good;
64 else ++bad;
65 }
66
67 {
68 MIDIFileReaderTest t(testDir);
69 if (QTest::qExec(&t, argc, argv) == 0) ++good;
70 else ++bad;
71 }
72
73 if (bad > 0) {
74 cerr << "\n********* " << bad << " test suite(s) failed!\n" << endl;
75 return 1;
76 } else {
77 cerr << "All tests passed" << endl;
78 return 0;
79 }
80 } 53 }
81