michael@0: #include michael@0: michael@0: #include michael@0: #ifndef mozilla_algorithm_h michael@0: # error "failed to wrap " michael@0: #endif michael@0: michael@0: #include michael@0: #ifndef mozilla_vector_h michael@0: # error "failed to wrap " michael@0: #endif michael@0: michael@0: // gcc errors out if we |try ... catch| with -fno-exceptions, but we michael@0: // can still test on windows michael@0: #ifdef _MSC_VER michael@0: // C4530 will be generated whenever try...catch is used without michael@0: // enabling exceptions. We know we don't enbale exceptions. michael@0: # pragma warning( disable : 4530 ) michael@0: # define TRY try michael@0: # define CATCH(e) catch (e) michael@0: #else michael@0: # define TRY michael@0: # define CATCH(e) if (0) michael@0: #endif michael@0: michael@0: int main() { michael@0: std::vector v; michael@0: int rv = 1; michael@0: michael@0: TRY { michael@0: // v.at(1) on empty v should abort; NOT throw an exception michael@0: michael@0: // (Do some arithmetic with result of v.at() to avoid michael@0: // compiler warnings for unused variable/result.) michael@0: rv += v.at(1) ? 1 : 2; michael@0: } CATCH(const std::out_of_range&) { michael@0: fputs("TEST-FAIL | TestSTLWrappers.cpp | caught an exception?\n", michael@0: stderr); michael@0: return 1; michael@0: } michael@0: michael@0: fputs("TEST-FAIL | TestSTLWrappers.cpp | didn't abort()?\n", michael@0: stderr); michael@0: return rv; michael@0: }