bgneal@0: #ifndef FRUCTOSE_MAIN_TEST_X3_H bgneal@0: #define FRUCTOSE_MAIN_TEST_X3_H bgneal@0: bgneal@0: #include bgneal@0: #include bgneal@0: bgneal@0: #include "fructose/fructose.h" bgneal@0: bgneal@0: struct my_logic_error : public std::logic_error bgneal@0: { bgneal@0: my_logic_error(const char* message) : std::logic_error(message) {} bgneal@0: }; bgneal@0: bgneal@0: struct my_runtime_error : public std::runtime_error bgneal@0: { bgneal@0: my_runtime_error(const char* message) : std::runtime_error(message) {} bgneal@0: }; bgneal@0: bgneal@0: struct exception_test : public fructose::test_base bgneal@0: { bgneal@0: void test_array_bounds(const std::string&) bgneal@0: { bgneal@0: std::vector v; bgneal@0: v.push_back(1234); bgneal@0: fructose_assert_exception(v.at(2), std::out_of_range); bgneal@0: } bgneal@0: bgneal@0: void test_should_catch_std_exceptions(const std::string& ) bgneal@0: { bgneal@0: fructose_assert_exception(throw my_logic_error("a coding error has been detected"), bgneal@0: std::logic_error); bgneal@0: fructose_assert_exception(throw my_runtime_error("my runtime error"), bgneal@0: std::runtime_error); bgneal@0: fructose_assert_exception(throw my_logic_error("another coding error has been detected"), bgneal@0: std::exception); bgneal@0: fructose_assert_exception(throw my_runtime_error("my runtime error"), bgneal@0: std::exception); bgneal@0: } bgneal@0: bgneal@0: //void test_commented_out(const std::string&) bgneal@0: //{ bgneal@0: // fructose_assert(false); bgneal@0: //} bgneal@0: }; bgneal@0: bgneal@0: // class MyTest : public fructose::test_base bgneal@0: // { bgneal@0: // public: bgneal@0: // void testIt(const std::string&) bgneal@0: // { bgneal@0: // fructose_assert(true); bgneal@0: // } bgneal@0: // }; bgneal@0: bgneal@0: class MyTest : public fructose::test_base bgneal@0: { bgneal@0: public: bgneal@0: void testIt(const std::string&) bgneal@0: { bgneal@0: fructose_assert(true); bgneal@0: } bgneal@0: }; bgneal@0: #endif