mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 08:15:31 +00:00
Bug 551254: Simple (disabled) test that the STL wrappers work correctly.
This commit is contained in:
parent
f4b0fe954c
commit
23b3beae10
@ -73,6 +73,10 @@ CPPSRCS = \
|
||||
TestUnicodeArguments.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifdef WRAP_STL_INCLUDES
|
||||
CPPSRCS += TestSTLWrappers.cpp
|
||||
endif
|
||||
|
||||
SIMPLE_PROGRAMS := $(CPPSRCS:.cpp=$(BIN_SUFFIX))
|
||||
|
||||
CPP_UNIT_TESTS = \
|
||||
|
35
xpcom/tests/TestSTLWrappers.cpp
Normal file
35
xpcom/tests/TestSTLWrappers.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
#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
|
||||
#ifdef XP_WIN
|
||||
# define TRY try
|
||||
# define CATCH(e) catch (e)
|
||||
#else
|
||||
# define TRY
|
||||
# define CATCH(e) if (0)
|
||||
#endif
|
||||
|
||||
int main() {
|
||||
std::vector<int> v;
|
||||
|
||||
TRY {
|
||||
// this should abort; NOT throw an exception
|
||||
int unused = v.at(1);
|
||||
} CATCH(const std::out_of_range& e) {
|
||||
fputs("TEST-FAIL | TestSTLWrappers.cpp | caught an exception!\n",
|
||||
stderr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user