]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/cppunit.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wrapper header for CppUnit headers
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2004 Vadim Zeitlin
8 /////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_CPPUNIT_H_
11 #define _WX_CPPUNIT_H_
13 ///////////////////////////////////////////////////////////////////////////////
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
17 // typedef-name 'foo' used as synonym for class-name 'bar'
18 #pragma warning(disable:4097)
20 // unreachable code: we don't care about warnings in CppUnit headers
21 #pragma warning(disable:4702)
23 // 'id': identifier was truncated to 'num' characters in the debug info
24 #pragma warning(disable:4786)
31 ///////////////////////////////////////////////////////////////////////////////
32 // Set the default format for the errors, which can be used by an IDE to jump
33 // to the error location. This default gets overridden by the cppunit headers
34 // for some compilers (e.g. VC++).
36 #ifndef CPPUNIT_COMPILER_LOCATION_FORMAT
37 #define CPPUNIT_COMPILER_LOCATION_FORMAT "%p:%l:"
41 ///////////////////////////////////////////////////////////////////////////////
42 // Include all needed cppunit headers.
45 #include "wx/beforestd.h"
46 #include <cppunit/extensions/TestFactoryRegistry.h>
47 #include <cppunit/ui/text/TestRunner.h>
48 #include <cppunit/TestCase.h>
49 #include <cppunit/extensions/HelperMacros.h>
50 #include <cppunit/CompilerOutputter.h>
51 #include "wx/afterstd.h"
54 ///////////////////////////////////////////////////////////////////////////////
55 // Set of helpful test macros.
58 // Base macro for wrapping CPPUNIT_TEST macros and so making them conditional
59 // tests, meaning that the test only get registered and thus run when a given
60 // runtime condition is true.
61 // In case the condition is evaluated as false a skip message is logged
62 // (the message will only be shown in verbose mode).
63 #define WXTEST_ANY_WITH_CONDITION(suiteName, Condition, testMethod, anyTest) \
67 wxLogInfo(wxString::Format(_T("skipping: %s.%s\n reason: %s equals false\n"), \
68 wxString(suiteName, wxConvUTF8).c_str(), \
69 wxString(#testMethod, wxConvUTF8).c_str(), \
70 wxString(#Condition, wxConvUTF8).c_str()))
72 // Conditional CPPUNIT_TEST macro.
73 #define WXTEST_WITH_CONDITION(suiteName, Condition, testMethod) \
74 WXTEST_ANY_WITH_CONDITION(suiteName, Condition, testMethod, CPPUNIT_TEST(testMethod))
75 // Conditional CPPUNIT_TEST_FAIL macro.
76 #define WXTEST_FAIL_WITH_CONDITION(suiteName, Condition, testMethod) \
77 WXTEST_ANY_WITH_CONDITION(suiteName, Condition, testMethod, CPPUNIT_TEST_FAIL(testMethod))
80 ///////////////////////////////////////////////////////////////////////////////
81 // Some more compiler warning tweaking and auto linking.
89 #pragma warning(default:4702)
92 // for VC++ automatically link in cppunit library
95 #pragma comment(lib, "cppunit.lib")
97 #pragma comment(lib, "cppunitd.lib")
98 #endif // Release/Debug
101 #endif // _WX_CPPUNIT_H_