2 #include "wx/cppunit.h"
4 // define wxHAVE_U_ESCAPE if the compiler supports \uxxxx character constants
5 #if (defined(__VISUALC__) && (__VISUALC__ >= 1300)) || \
6 (defined(__GNUC__) && (__GNUC__ >= 3))
7 #define wxHAVE_U_ESCAPE
9 // and disable warning that using them results in with MSVC 8+
10 #if wxCHECK_VISUALC_VERSION(8)
11 // universal-character-name encountered in source
12 #pragma warning(disable:4428)
16 // thrown when assert fails in debug build
17 class TestAssertFailure
20 TestAssertFailure(const wxString
& file
,
33 const wxString m_file
;
35 const wxString m_func
;
36 const wxString m_cond
;
39 wxDECLARE_NO_ASSIGN_CLASS(TestAssertFailure
);
42 // macro to use for the functions which are supposed to fail an assertion
44 // some old cppunit versions don't define CPPUNIT_ASSERT_THROW so roll our
46 #define WX_ASSERT_FAILS_WITH_ASSERT(cond) \
48 bool throwsAssert = false; \
50 catch ( const TestAssertFailure& ) { throwsAssert = true; } \
51 if ( !throwsAssert ) \
52 CPPUNIT_FAIL("expected assertion not generated"); \
55 // there are no assertions in this build so just check that it fails
56 #define WX_ASSERT_FAILS_WITH_ASSERT(cond) CPPUNIT_ASSERT(!(cond))
59 // these functions can be used to hook into wxApp event processing and are
60 // currently used by the events propagation test
61 class WXDLLIMPEXP_FWD_BASE wxEvent
;
63 typedef int (*FilterEventFunc
)(wxEvent
&);
64 typedef bool (*ProcessEventFunc
)(wxEvent
&);
66 extern void SetFilterEventFunc(FilterEventFunc func
);
67 extern void SetProcessEventFunc(ProcessEventFunc func
);
69 extern bool IsNetworkAvailable();
71 // helper class setting the locale to "C" for its lifetime
75 CLocaleSetter() : m_locOld(setlocale(LC_ALL
, "C")) { }
76 ~CLocaleSetter() { setlocale(LC_ALL
, m_locOld
); }
79 const char * const m_locOld
;
80 wxDECLARE_NO_COPY_CLASS(CLocaleSetter
);