2010-04-02 10:58:12 -07:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#ifndef mozilla_algorithm_h
|
|
|
|
# error "failed to wrap <algorithm>"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#ifndef mozilla_vector_h
|
|
|
|
# error "failed to wrap <vector>"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// gcc errors out if we |try ... catch| with -fno-exceptions, but we
|
|
|
|
// can still test on windows
|
2010-04-15 22:29:15 -07:00
|
|
|
#ifdef _MSC_VER
|
2010-04-02 10:58:12 -07:00
|
|
|
# define TRY try
|
|
|
|
# define CATCH(e) catch (e)
|
|
|
|
#else
|
|
|
|
# define TRY
|
|
|
|
# define CATCH(e) if (0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
std::vector<int> v;
|
2010-04-14 19:09:35 -07:00
|
|
|
int rv = 1;
|
2010-04-02 10:58:12 -07:00
|
|
|
|
|
|
|
TRY {
|
2010-04-14 19:09:35 -07:00
|
|
|
// v.at(1) on empty v should abort; NOT throw an exception
|
|
|
|
|
|
|
|
// (Do some arithmetic with result of v.at() to avoid
|
|
|
|
// compiler warnings for unused variable/result.)
|
|
|
|
rv += v.at(1) ? 1 : 2;
|
2010-04-02 10:58:12 -07:00
|
|
|
} CATCH(const std::out_of_range& e) {
|
2010-04-14 19:09:35 -07:00
|
|
|
fputs("TEST-FAIL | TestSTLWrappers.cpp | caught an exception?\n",
|
2010-04-02 10:58:12 -07:00
|
|
|
stderr);
|
2010-04-14 19:09:35 -07:00
|
|
|
return 1;
|
2010-04-02 10:58:12 -07:00
|
|
|
}
|
|
|
|
|
2010-04-14 19:09:35 -07:00
|
|
|
fputs("TEST-FAIL | TestSTLWrappers.cpp | didn't abort()?\n",
|
|
|
|
stderr);
|
|
|
|
return rv;
|
2010-04-02 10:58:12 -07:00
|
|
|
}
|