diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-06-16 22:17:54 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-06-16 22:17:54 +0200 |
commit | 3ae86373f2238bcd771392f329b52d7b8923d003 (patch) | |
tree | 03a9648d64081de0457d9ec94e41774ca662cf00 /tests/testutils.h | |
parent | 9d727c366ed709fd15d2358800f57e927fd18ed2 (diff) | |
download | sink-3ae86373f2238bcd771392f329b52d7b8923d003.tar.gz sink-3ae86373f2238bcd771392f329b52d7b8923d003.zip |
Central place for test macros
Diffstat (limited to 'tests/testutils.h')
-rw-r--r-- | tests/testutils.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/testutils.h b/tests/testutils.h new file mode 100644 index 0000000..f89da38 --- /dev/null +++ b/tests/testutils.h | |||
@@ -0,0 +1,47 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2016 Christian Mollekopf <chrigi_1@fastmail.fm> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | */ | ||
19 | #pragma once | ||
20 | |||
21 | #define ASYNCCOMPARE(actual, expected) \ | ||
22 | do {\ | ||
23 | if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__))\ | ||
24 | return KAsync::error<void>(1, "Comparison failed.");\ | ||
25 | } while (0) | ||
26 | |||
27 | #define ASYNCVERIFY(statement) \ | ||
28 | do {\ | ||
29 | if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__))\ | ||
30 | return KAsync::error<void>(1, "Verify failed.");\ | ||
31 | } while (0) | ||
32 | |||
33 | #define VERIFYEXEC(statement) \ | ||
34 | do {\ | ||
35 | auto result = statement.exec(); \ | ||
36 | result.waitForFinished(); \ | ||
37 | if (!QTest::qVerify(!result.errorCode(), #statement, "", __FILE__, __LINE__))\ | ||
38 | return;\ | ||
39 | } while (0) | ||
40 | |||
41 | #define VERIFYEXEC_FAIL(statement) \ | ||
42 | do {\ | ||
43 | auto result = statement.exec(); \ | ||
44 | result.waitForFinished(); \ | ||
45 | if (!QTest::qVerify(result.errorCode(), #statement, "", __FILE__, __LINE__))\ | ||
46 | return;\ | ||
47 | } while (0) | ||