]> git.saurik.com Git - wxWidgets.git/blame - tests/testprec.h
Added named section 'Property development funcions'
[wxWidgets.git] / tests / testprec.h
CommitLineData
8899b155
RN
1#include "wx/wxprec.h"
2#include "wx/cppunit.h"
8da7a00a
VZ
3
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
a8f17758
VZ
8
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)
13 #endif
8da7a00a 14#endif
0468a58a
VZ
15
16// thrown when assert fails in debug build
b33e98f0
VZ
17class TestAssertFailure
18{
19public:
20 TestAssertFailure(const wxString& file,
21 int line,
22 const wxString& func,
23 const wxString& cond,
24 const wxString& msg)
25 : m_file(file),
26 m_line(line),
27 m_func(func),
28 m_cond(cond),
29 m_msg(msg)
30 {
31 }
32
33 const wxString m_file;
34 const int m_line;
35 const wxString m_func;
36 const wxString m_cond;
37 const wxString m_msg;
38
39 wxDECLARE_NO_ASSIGN_CLASS(TestAssertFailure);
40};
0468a58a
VZ
41
42// macro to use for the functions which are supposed to fail an assertion
657a8a35 43#if wxDEBUG_LEVEL
0468a58a
VZ
44 // some old cppunit versions don't define CPPUNIT_ASSERT_THROW so roll our
45 // own
46 #define WX_ASSERT_FAILS_WITH_ASSERT(cond) \
47 { \
48 bool throwsAssert = false; \
49 try { cond ; } \
50 catch ( const TestAssertFailure& ) { throwsAssert = true; } \
51 if ( !throwsAssert ) \
52 CPPUNIT_FAIL("expected assertion not generated"); \
53 }
54#else
657a8a35 55 // there are no assertions in this build so just check that it fails
0468a58a
VZ
56 #define WX_ASSERT_FAILS_WITH_ASSERT(cond) CPPUNIT_ASSERT(!(cond))
57#endif
58
1649d288
VZ
59// these functions can be used to hook into wxApp event processing and are
60// currently used by the events propagation test
9eab6725
VZ
61class WXDLLIMPEXP_FWD_BASE wxEvent;
62
1649d288
VZ
63typedef int (*FilterEventFunc)(wxEvent&);
64typedef bool (*ProcessEventFunc)(wxEvent&);
65
66extern void SetFilterEventFunc(FilterEventFunc func);
67extern void SetProcessEventFunc(ProcessEventFunc func);
1f51673b
FM
68
69extern bool IsNetworkAvailable();