comparison test/TestHelper.h @ 1431:7decc74b0fd0 streaming-csv-writer

Untabify
author Lucas Thompson <dev@lucas.im>
date Tue, 17 Apr 2018 10:03:49 +0100
parents b5283878cca2
children 779a084d7e3d
comparison
equal deleted inserted replaced
1430:b5283878cca2 1431:7decc74b0fd0
30 using Factory = std::function<std::unique_ptr<T>()>; 30 using Factory = std::function<std::unique_ptr<T>()>;
31 31
32 template <class T, typename... Args> 32 template <class T, typename... Args>
33 auto createFactory(Args... FArgs) -> Factory<T> 33 auto createFactory(Args... FArgs) -> Factory<T>
34 { 34 {
35 return [&]() { return std::unique_ptr<T> { new T {FArgs...} }; }; 35 return [&]() { return std::unique_ptr<T> { new T {FArgs...} }; };
36 } 36 }
37 37
38 using TestStatus = int; 38 using TestStatus = int;
39 39
40 auto startTestRunner( 40 auto startTestRunner(
41 std::initializer_list<Factory<QObject>> tests, 41 std::initializer_list<Factory<QObject>> tests,
42 int argc, 42 int argc,
43 char *argv[], 43 char *argv[],
44 QString testName, 44 QString testName,
45 QString orgName = "sonic-visualiser" 45 QString orgName = "sonic-visualiser"
46 ) -> TestStatus 46 ) -> TestStatus
47 { 47 {
48 int good = 0, bad = 0; 48 int good = 0, bad = 0;
49 49
50 QCoreApplication app(argc, argv); 50 QCoreApplication app(argc, argv);
58 for (const auto& test : tests) { 58 for (const auto& test : tests) {
59 executeTest(test()); 59 executeTest(test());
60 } 60 }
61 61
62 if (bad > 0) { 62 if (bad > 0) {
63 cerr << "\n********* " << bad << " test suite(s) failed!\n" << endl; 63 cerr << "\n********* " << bad << " test suite(s) failed!\n" << endl;
64 return 1; 64 return 1;
65 } else { 65 } else {
66 cerr << "All tests passed" << endl; 66 cerr << "All tests passed" << endl;
67 return 0; 67 return 0;
68 } 68 }
69 } 69 }
70 70
71 } // namespace 71 } // namespace
72 72