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