]>
Commit | Line | Data |
---|---|---|
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 | // Licence: wxWindows Licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #ifndef _WX_CPPUNIT_H_ | |
12 | #define _WX_CPPUNIT_H_ | |
13 | ||
14 | /////////////////////////////////////////////////////////////////////////////// | |
15 | // using CPPUNIT_TEST() macro results in this warning, disable it as there is | |
16 | // no other way to get rid of it and it's not very useful anyhow | |
17 | #ifdef __VISUALC__ | |
18 | // typedef-name 'foo' used as synonym for class-name 'bar' | |
19 | #pragma warning(disable:4097) | |
20 | ||
21 | // unreachable code: we don't care about warnings in CppUnit headers | |
22 | #pragma warning(disable:4702) | |
23 | ||
24 | // 'id': identifier was truncated to 'num' characters in the debug info | |
25 | #pragma warning(disable:4786) | |
26 | #endif // __VISUALC__ | |
27 | ||
28 | #ifdef __BORLANDC__ | |
29 | #pragma warn -8022 | |
30 | #endif | |
31 | ||
32 | /////////////////////////////////////////////////////////////////////////////// | |
33 | // Set the default format for the errors, which can be used by an IDE to jump | |
34 | // to the error location. This default gets overridden by the cppunit headers | |
35 | // for some compilers (e.g. VC++). | |
36 | ||
37 | #ifndef CPPUNIT_COMPILER_LOCATION_FORMAT | |
38 | #define CPPUNIT_COMPILER_LOCATION_FORMAT "%p:%l:" | |
39 | #endif | |
40 | ||
41 | ||
42 | /////////////////////////////////////////////////////////////////////////////// | |
43 | // Include all needed cppunit headers. | |
44 | // | |
45 | ||
46 | #include "wx/beforestd.h" | |
47 | #include <cppunit/extensions/TestFactoryRegistry.h> | |
48 | #include <cppunit/ui/text/TestRunner.h> | |
49 | #include <cppunit/TestCase.h> | |
50 | #include <cppunit/extensions/HelperMacros.h> | |
51 | #include <cppunit/CompilerOutputter.h> | |
52 | #include "wx/afterstd.h" | |
53 | ||
54 | ||
55 | /////////////////////////////////////////////////////////////////////////////// | |
56 | // Set of helpful test macros. | |
57 | // | |
58 | ||
59 | // Base macro for wrapping CPPUNIT_TEST macros and so making them conditional | |
60 | // tests, meaning that the test only get registered and thus run when a given | |
61 | // runtime condition is true. | |
62 | // In case the condition is evaluated as false a skip message is logged | |
63 | // (the message will only be shown in verbose mode). | |
64 | #define WXTEST_ANY_WITH_CONDITION(suiteName, Condition, testMethod, anyTest) \ | |
65 | if (Condition) \ | |
66 | { anyTest; } \ | |
67 | else \ | |
68 | wxLogInfo(wxString::Format(_T("skipping: %s.%s\n reason: %s equals false\n"), \ | |
69 | wxString(suiteName, wxConvUTF8).c_str(), \ | |
70 | wxString(#testMethod, wxConvUTF8).c_str(), \ | |
71 | wxString(#Condition, wxConvUTF8).c_str())) | |
72 | ||
73 | // Conditional CPPUNIT_TEST macro. | |
74 | #define WXTEST_WITH_CONDITION(suiteName, Condition, testMethod) \ | |
75 | WXTEST_ANY_WITH_CONDITION(suiteName, Condition, testMethod, CPPUNIT_TEST(testMethod)) | |
76 | // Conditional CPPUNIT_TEST_FAIL macro. | |
77 | #define WXTEST_FAIL_WITH_CONDITION(suiteName, Condition, testMethod) \ | |
78 | WXTEST_ANY_WITH_CONDITION(suiteName, Condition, testMethod, CPPUNIT_TEST_FAIL(testMethod)) | |
79 | ||
80 | // Use this macro to compare a wxString with a literal string. | |
81 | #define WX_ASSERT_STR_EQUAL(p, s) CPPUNIT_ASSERT_EQUAL(wxString(p), s) | |
82 | ||
83 | ||
84 | /////////////////////////////////////////////////////////////////////////////// | |
85 | // stream inserter for wxString | |
86 | // | |
87 | ||
88 | #include "wx/string.h" | |
89 | ||
90 | inline std::ostream& operator<<(std::ostream& o, const wxString& s) | |
91 | { | |
92 | return o << s.mb_str(); | |
93 | } | |
94 | ||
95 | ||
96 | /////////////////////////////////////////////////////////////////////////////// | |
97 | // Some more compiler warning tweaking and auto linking. | |
98 | // | |
99 | ||
100 | #ifdef __BORLANDC__ | |
101 | #pragma warn .8022 | |
102 | #endif | |
103 | ||
104 | #ifdef _MSC_VER | |
105 | #pragma warning(default:4702) | |
106 | #endif // _MSC_VER | |
107 | ||
108 | // for VC++ automatically link in cppunit library | |
109 | #ifdef __VISUALC__ | |
110 | #ifdef NDEBUG | |
111 | #pragma comment(lib, "cppunit.lib") | |
112 | #else // Debug | |
113 | #pragma comment(lib, "cppunitd.lib") | |
114 | #endif // Release/Debug | |
115 | #endif | |
116 | ||
117 | #endif // _WX_CPPUNIT_H_ | |
118 |