swift
tests
test.h
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: Copyright (C) 2013 swift Project Community / Contributors
2
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
4
#ifndef SWIFT_MISCTEST_TEST_H
5
#define SWIFT_MISCTEST_TEST_H
6
10
11
#include <QCoreApplication>
12
#include <QStringList>
13
#include <QTest>
14
18
#define SWIFTTEST_INIT(TestObject) \
19
TestObject to; \
20
QTEST_SET_MAIN_SOURCE_PATH \
21
\
22
QStringList args; \
23
args.reserve(argc); \
24
for (int i = 0; i < argc; ++i) { args.append(argv[i]); } \
25
\
26
/* Output to stdout */
\
27
args.append({ "-o"
, "-,txt" }); \
28
\
29
/* Output to file */
\
30
QString resultsFileName = QString(#TestObject).replace("::"
, "_").toLower(); \
31
args.append({ "-o", resultsFileName + "_testresults.xml,xml" });
32
36
#define SWIFTTEST_APPLESS_MAIN(TestObject) \
37
int main(int argc, char *argv[]) \
38
{ \
39
try \
40
{ \
41
SWIFTTEST_INIT(TestObject) \
42
return QTest::qExec(&to, args); \
43
} \
44
catch (...) \
45
{ \
46
return EXIT_FAILURE; \
47
} \
48
} \
49
static_assert(true)
50
54
#define SWIFTTEST_MAIN(TestObject) \
55
int main(int argc, char *argv[]) \
56
{ \
57
try \
58
{ \
59
QCoreApplication app(argc, argv); \
60
SWIFTTEST_INIT(TestObject) \
61
return QTest::qExec(&to, args); \
62
} \
63
catch (...) \
64
{ \
65
return EXIT_FAILURE; \
66
} \
67
} \
68
static_assert(true)
69
71
72
#endif
// SWIFT_MISCTEST_TEST_H
Generated on Mon Mar 24 2025 16:42:23 for swift by
1.9.1