]>
Commit | Line | Data |
---|---|---|
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 | |
8 | #endif | |
0468a58a VZ |
9 | |
10 | // thrown when assert fails in debug build | |
b33e98f0 VZ |
11 | class TestAssertFailure |
12 | { | |
13 | public: | |
14 | TestAssertFailure(const wxString& file, | |
15 | int line, | |
16 | const wxString& func, | |
17 | const wxString& cond, | |
18 | const wxString& msg) | |
19 | : m_file(file), | |
20 | m_line(line), | |
21 | m_func(func), | |
22 | m_cond(cond), | |
23 | m_msg(msg) | |
24 | { | |
25 | } | |
26 | ||
27 | const wxString m_file; | |
28 | const int m_line; | |
29 | const wxString m_func; | |
30 | const wxString m_cond; | |
31 | const wxString m_msg; | |
32 | ||
33 | wxDECLARE_NO_ASSIGN_CLASS(TestAssertFailure); | |
34 | }; | |
0468a58a VZ |
35 | |
36 | // macro to use for the functions which are supposed to fail an assertion | |
657a8a35 | 37 | #if wxDEBUG_LEVEL |
0468a58a VZ |
38 | // some old cppunit versions don't define CPPUNIT_ASSERT_THROW so roll our |
39 | // own | |
40 | #define WX_ASSERT_FAILS_WITH_ASSERT(cond) \ | |
41 | { \ | |
42 | bool throwsAssert = false; \ | |
43 | try { cond ; } \ | |
44 | catch ( const TestAssertFailure& ) { throwsAssert = true; } \ | |
45 | if ( !throwsAssert ) \ | |
46 | CPPUNIT_FAIL("expected assertion not generated"); \ | |
47 | } | |
48 | #else | |
657a8a35 | 49 | // there are no assertions in this build so just check that it fails |
0468a58a VZ |
50 | #define WX_ASSERT_FAILS_WITH_ASSERT(cond) CPPUNIT_ASSERT(!(cond)) |
51 | #endif | |
52 | ||
1649d288 VZ |
53 | // these functions can be used to hook into wxApp event processing and are |
54 | // currently used by the events propagation test | |
9eab6725 VZ |
55 | class WXDLLIMPEXP_FWD_BASE wxEvent; |
56 | ||
1649d288 VZ |
57 | typedef int (*FilterEventFunc)(wxEvent&); |
58 | typedef bool (*ProcessEventFunc)(wxEvent&); | |
59 | ||
60 | extern void SetFilterEventFunc(FilterEventFunc func); | |
61 | extern void SetProcessEventFunc(ProcessEventFunc func); |