|
1 #include <stdio.h> |
|
2 |
|
3 #include <algorithm> |
|
4 #ifndef mozilla_algorithm_h |
|
5 # error "failed to wrap <algorithm>" |
|
6 #endif |
|
7 |
|
8 #include <vector> |
|
9 #ifndef mozilla_vector_h |
|
10 # error "failed to wrap <vector>" |
|
11 #endif |
|
12 |
|
13 // gcc errors out if we |try ... catch| with -fno-exceptions, but we |
|
14 // can still test on windows |
|
15 #ifdef _MSC_VER |
|
16 // C4530 will be generated whenever try...catch is used without |
|
17 // enabling exceptions. We know we don't enbale exceptions. |
|
18 # pragma warning( disable : 4530 ) |
|
19 # define TRY try |
|
20 # define CATCH(e) catch (e) |
|
21 #else |
|
22 # define TRY |
|
23 # define CATCH(e) if (0) |
|
24 #endif |
|
25 |
|
26 int main() { |
|
27 std::vector<int> v; |
|
28 int rv = 1; |
|
29 |
|
30 TRY { |
|
31 // v.at(1) on empty v should abort; NOT throw an exception |
|
32 |
|
33 // (Do some arithmetic with result of v.at() to avoid |
|
34 // compiler warnings for unused variable/result.) |
|
35 rv += v.at(1) ? 1 : 2; |
|
36 } CATCH(const std::out_of_range&) { |
|
37 fputs("TEST-FAIL | TestSTLWrappers.cpp | caught an exception?\n", |
|
38 stderr); |
|
39 return 1; |
|
40 } |
|
41 |
|
42 fputs("TEST-FAIL | TestSTLWrappers.cpp | didn't abort()?\n", |
|
43 stderr); |
|
44 return rv; |
|
45 } |