Back out changeset fecc8ed9e813.
[mozilla-central.git] / xpcom / tests / TestSTLWrappers.cpp
blobc4d387a558e5cd47748445236fe4bb3b08eb96b6
1 #include <stdio.h>
3 #include <algorithm>
4 #ifndef mozilla_algorithm_h
5 # error "failed to wrap <algorithm>"
6 #endif
8 #include <vector>
9 #ifndef mozilla_vector_h
10 # error "failed to wrap <vector>"
11 #endif
13 // gcc errors out if we |try ... catch| with -fno-exceptions, but we
14 // can still test on windows
15 #ifdef _MSC_VER
16 # define TRY try
17 # define CATCH(e) catch (e)
18 #else
19 # define TRY
20 # define CATCH(e) if (0)
21 #endif
23 int main() {
24 std::vector<int> v;
25 int rv = 1;
27 TRY {
28 // v.at(1) on empty v should abort; NOT throw an exception
30 // (Do some arithmetic with result of v.at() to avoid
31 // compiler warnings for unused variable/result.)
32 rv += v.at(1) ? 1 : 2;
33 } CATCH(const std::out_of_range& e) {
34 fputs("TEST-FAIL | TestSTLWrappers.cpp | caught an exception?\n",
35 stderr);
36 return 1;
39 fputs("TEST-FAIL | TestSTLWrappers.cpp | didn't abort()?\n",
40 stderr);
41 return rv;