#include "../include/iutest.hpp"
#if IUTEST_HAS_EXCEPTIONS
static void ExceptionFunction(int i)
{
switch( i )
{
case 0:
return;
case 1:
throw 2;
case 2:
throw ::std::bad_exception();
case 3:
throw "error";
case 4:
throw ::std::string("error");
default:
break;
}
}
IUTEST(AssertionTest, Exception)
{
}
#if !defined(_MSC_VER) || _MSC_VER >= 1310
class exception_test
{
public:
explicit exception_test(const ::std::vector<int>&)
{
IUTEST_SUPPRESS_UNREACHABLE_CODE_WARNING(throw ::std::exception());
}
};
IUTEST(AssertionTest, Exception2)
{
::std::vector<int> a;
}
#endif
#if IUTEST_HAS_CATCH_SEH_EXCEPTION_ASSERTION
{
int* p = reinterpret_cast<int*>(0x1234);
}
#endif
#endif
#if IUTEST_HAS_EXCEPTIONS
IUTEST(DISABLED_TestFailure, Exception)
{
}
IUTEST(DISABLED_TestFailure, UnexpectedException1)
{
throw "fail";
}
IUTEST(DISABLED_TestFailure, UnexpectedException2)
{
IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_BEGIN()
IUTEST_PRAGMA_MSC_WARN_DISABLE(6387)
IUTEST_PRAGMA_GCC_WARN_PUSH()
IUTEST_PRAGMA_GCC_WARN_DISABLE("-Wnonnull")
strcpy(NULL, NULL);
IUTEST_PRAGMA_GCC_WARN_POP()
IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_END()
}
#endif