# HG changeset patch # User Lucas Thompson # Date 1523955829 -3600 # Node ID de385fed1197772cf13d4a0316ae7d07adafd50c # Parent d61d6c33f14d8bafe61815fa95d06a2479f1b31c Revert to adding a test case in the style of the existing file diff -r d61d6c33f14d -r de385fed1197 data/fileio/test/files.pri --- a/data/fileio/test/files.pri Tue Apr 17 10:03:49 2018 +0100 +++ b/data/fileio/test/files.pri Tue Apr 17 10:03:49 2018 +0100 @@ -1,6 +1,5 @@ TEST_HEADERS += \ - ../../../test/TestHelper.h \ ../../model/test/MockWaveModel.h \ AudioFileReaderTest.h \ AudioFileWriterTest.h \ diff -r d61d6c33f14d -r de385fed1197 data/fileio/test/svcore-data-fileio-test.cpp --- a/data/fileio/test/svcore-data-fileio-test.cpp Tue Apr 17 10:03:49 2018 +0100 +++ b/data/fileio/test/svcore-data-fileio-test.cpp Tue Apr 17 10:03:49 2018 +0100 @@ -12,15 +12,20 @@ COPYING included with this distribution for more information. */ -#include "../../../test/TestHelper.h" #include "AudioFileReaderTest.h" #include "AudioFileWriterTest.h" #include "EncodingTest.h" #include "MIDIFileReaderTest.h" #include "CSVStreamWriterTest.h" +#include + +#include + int main(int argc, char *argv[]) { + int good = 0, bad = 0; + QString testDir; #ifdef Q_OS_WIN @@ -38,16 +43,45 @@ cerr << "Setting test directory base path to \"" << testDir << "\"" << endl; } - return Test::startTestRunner( - { - Test::createFactory(testDir), - Test::createFactory(testDir), - Test::createFactory(testDir), - Test::createFactory(testDir), - Test::createFactory() - }, - argc, - argv, - "test-fileio" - ); + QCoreApplication app(argc, argv); + app.setOrganizationName("sonic-visualiser"); + app.setApplicationName("test-fileio"); + + { + AudioFileReaderTest t(testDir); + if (QTest::qExec(&t, argc, argv) == 0) ++good; + else ++bad; + } + + { + AudioFileWriterTest t(testDir); + if (QTest::qExec(&t, argc, argv) == 0) ++good; + else ++bad; + } + + { + EncodingTest t(testDir); + if (QTest::qExec(&t, argc, argv) == 0) ++good; + else ++bad; + } + + { + MIDIFileReaderTest t(testDir); + if (QTest::qExec(&t, argc, argv) == 0) ++good; + else ++bad; + } + + { + CSVStreamWriterTest t; + if (QTest::qExec(&t, argc, argv) == 0) ++good; + else ++bad; + } + + if (bad > 0) { + cerr << "\n********* " << bad << " test suite(s) failed!\n" << endl; + return 1; + } else { + cerr << "All tests passed" << endl; + return 0; + } } diff -r d61d6c33f14d -r de385fed1197 test/TestHelper.h --- a/test/TestHelper.h Tue Apr 17 10:03:49 2018 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ - -/* - Sonic Visualiser - An audio file viewer and annotation editor. - Centre for Digital Music, Queen Mary, University of London. - This file copyright 2017 Lucas Thompson. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. See the file - COPYING included with this distribution for more information. -*/ - -#ifndef _TEST_HELPER_H_ -#define _TEST_HELPER_H_ - -#include -#include -#include -#include - -#include - -namespace Test -{ - -template -using Factory = std::function()>; - -template -auto createFactory(Args... FArgs) -> Factory -{ - return [&]() { return std::unique_ptr { new T {FArgs...} }; }; -} - -using TestStatus = int; - -auto startTestRunner( - std::initializer_list> tests, - int argc, - char *argv[], - QString testName, - QString orgName = "sonic-visualiser" -) -> TestStatus -{ - int good = 0, bad = 0; - - QCoreApplication app(argc, argv); - app.setOrganizationName(orgName); - app.setApplicationName(testName); - auto executeTest = [&](std::unique_ptr t) { - if (QTest::qExec(t.get(), argc, argv) == 0) ++good; - else ++bad; - }; - - for (const auto& test : tests) { - executeTest(test()); - } - - if (bad > 0) { - std::cerr << "\n********* " << bad << " test suite(s) failed!\n" << std::endl; - return 1; - } else { - std::cerr << "All tests passed" << std::endl; - return 0; - } -} - -} // namespace - -#endif \ No newline at end of file