]>
Commit | Line | Data |
---|---|---|
86132a69 VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/cppunit.h | |
3 | // Purpose: wrapper header for CppUnit headers | |
4 | // Author: Vadim Zeitlin | |
5 | // Created: 15.02.04 | |
6 | // RCS-ID: $Id$ | |
7 | // Copyright: (c) 2004 Vadim Zeitlin | |
8 | ///////////////////////////////////////////////////////////////////////////// | |
9 | ||
10 | #ifndef _WX_CPPUNIT_H_ | |
11 | #define _WX_CPPUNIT_H_ | |
12 | ||
044a69a4 | 13 | /////////////////////////////////////////////////////////////////////////////// |
86132a69 VZ |
14 | // using CPPUNIT_TEST() macro results in this warning, disable it as there is |
15 | // no other way to get rid of it and it's not very useful anyhow | |
16 | #ifdef __VISUALC__ | |
17 | // typedef-name 'foo' used as synonym for class-name 'bar' | |
18 | #pragma warning(disable:4097) | |
19 | ||
20 | // unreachable code: we don't care about warnings in CppUnit headers | |
21 | #pragma warning(disable:4702) | |
22 | ||
23 | // 'id': identifier was truncated to 'num' characters in the debug info | |
24 | #pragma warning(disable:4786) | |
25 | #endif // __VISUALC__ | |
26 | ||
20f46e8d VS |
27 | #ifdef __BORLANDC__ |
28 | #pragma warn -8022 | |
29 | #endif | |
30 | ||
044a69a4 VS |
31 | |
32 | /////////////////////////////////////////////////////////////////////////////// | |
33 | // Include all needed cppunit headers. | |
34 | // | |
35 | ||
86132a69 VZ |
36 | #include "wx/beforestd.h" |
37 | #include <cppunit/extensions/TestFactoryRegistry.h> | |
38 | #include <cppunit/ui/text/TestRunner.h> | |
39 | #include <cppunit/TestCase.h> | |
40 | #include <cppunit/extensions/HelperMacros.h> | |
41 | #include "wx/afterstd.h" | |
42 | ||
044a69a4 VS |
43 | |
44 | /////////////////////////////////////////////////////////////////////////////// | |
45 | // Set of helpful test macros. | |
46 | // | |
47 | ||
48 | // Base macro for wrapping CPPUNIT_TEST macros and so making them conditional | |
49 | // tests, meaning that the test only get registered and thus run when a given | |
68379eaf | 50 | // runtime condition is true. |
044a69a4 VS |
51 | // In case the condition is evaluated as false a skip message is logged |
52 | // (the message will only be shown in verbose mode). | |
53 | #define WXTEST_ANY_WITH_CONDITION(suiteName, Condition, testMethod, anyTest) \ | |
54 | if (Condition) \ | |
55 | { anyTest; } \ | |
56 | else \ | |
57 | wxLogInfo(wxString::Format(_T("skipping: %s.%s\n reason: %s equals false\n"), \ | |
58 | wxString(suiteName, wxConvUTF8).c_str(), \ | |
59 | wxString(#testMethod, wxConvUTF8).c_str(), \ | |
60 | wxString(#Condition, wxConvUTF8).c_str())) | |
61 | ||
62 | // Conditional CPPUNIT_TEST macro. | |
63 | #define WXTEST_WITH_CONDITION(suiteName, Condition, testMethod) \ | |
64 | WXTEST_ANY_WITH_CONDITION(suiteName, Condition, testMethod, CPPUNIT_TEST(testMethod)) | |
65 | // Conditional CPPUNIT_TEST_FAIL macro. | |
66 | #define WXTEST_FAIL_WITH_CONDITION(suiteName, Condition, testMethod) \ | |
67 | WXTEST_ANY_WITH_CONDITION(suiteName, Condition, testMethod, CPPUNIT_TEST_FAIL(testMethod)) | |
68 | ||
69 | ||
70 | /////////////////////////////////////////////////////////////////////////////// | |
71 | // Some more compiler warning tweaking and auto linking. | |
72 | // | |
73 | ||
20f46e8d VS |
74 | #ifdef __BORLANDC__ |
75 | #pragma warn .8022 | |
76 | #endif | |
77 | ||
86132a69 VZ |
78 | #ifdef _MSC_VER |
79 | #pragma warning(default:4702) | |
80 | #endif // _MSC_VER | |
81 | ||
82 | // for VC++ automatically link in cppunit library | |
83 | #ifdef __VISUALC__ | |
84 | #ifdef NDEBUG | |
85 | #pragma comment(lib, "cppunit.lib") | |
86 | #else // Debug | |
87 | #pragma comment(lib, "cppunitd.lib") | |
88 | #endif // Release/Debug | |
89 | #endif | |
90 | ||
91 | #endif // _WX_CPPUNIT_H_ | |
92 |