]>
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)
32 ///////////////////////////////////////////////////////////////////////////////
33 // Include all needed cppunit headers.
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"
44 ///////////////////////////////////////////////////////////////////////////////
45 // Set of helpful test macros.
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
50 // runtime condition is true.
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) \
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()))
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))
70 ///////////////////////////////////////////////////////////////////////////////
71 // Some more compiler warning tweaking and auto linking.
79 #pragma warning(default:4702)
82 // for VC++ automatically link in cppunit library
85 #pragma comment(lib, "cppunit.lib")
87 #pragma comment(lib, "cppunitd.lib")
88 #endif // Release/Debug
91 #endif // _WX_CPPUNIT_H_