Mercurial > public > fructose_gen
annotate tests/x3.h @ 4:9d536614c4c0 tip
Added tag fructose1.1.0 for changeset d8aeeb7f6785
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 21 May 2011 21:11:44 -0500 |
parents | d098192f01d9 |
children |
rev | line source |
---|---|
bgneal@0 | 1 #ifndef FRUCTOSE_MAIN_TEST_X3_H |
bgneal@0 | 2 #define FRUCTOSE_MAIN_TEST_X3_H |
bgneal@0 | 3 |
bgneal@0 | 4 #include <stdexcept> |
bgneal@0 | 5 #include <vector> |
bgneal@0 | 6 |
bgneal@0 | 7 #include "fructose/fructose.h" |
bgneal@0 | 8 |
bgneal@0 | 9 struct my_logic_error : public std::logic_error |
bgneal@0 | 10 { |
bgneal@0 | 11 my_logic_error(const char* message) : std::logic_error(message) {} |
bgneal@0 | 12 }; |
bgneal@0 | 13 |
bgneal@0 | 14 struct my_runtime_error : public std::runtime_error |
bgneal@0 | 15 { |
bgneal@0 | 16 my_runtime_error(const char* message) : std::runtime_error(message) {} |
bgneal@0 | 17 }; |
bgneal@0 | 18 |
bgneal@0 | 19 struct exception_test : public fructose::test_base<exception_test> |
bgneal@0 | 20 { |
bgneal@0 | 21 void test_array_bounds(const std::string&) |
bgneal@0 | 22 { |
bgneal@0 | 23 std::vector<int> v; |
bgneal@0 | 24 v.push_back(1234); |
bgneal@0 | 25 fructose_assert_exception(v.at(2), std::out_of_range); |
bgneal@0 | 26 } |
bgneal@0 | 27 |
bgneal@0 | 28 void test_should_catch_std_exceptions(const std::string& ) |
bgneal@0 | 29 { |
bgneal@0 | 30 fructose_assert_exception(throw my_logic_error("a coding error has been detected"), |
bgneal@0 | 31 std::logic_error); |
bgneal@0 | 32 fructose_assert_exception(throw my_runtime_error("my runtime error"), |
bgneal@0 | 33 std::runtime_error); |
bgneal@0 | 34 fructose_assert_exception(throw my_logic_error("another coding error has been detected"), |
bgneal@0 | 35 std::exception); |
bgneal@0 | 36 fructose_assert_exception(throw my_runtime_error("my runtime error"), |
bgneal@0 | 37 std::exception); |
bgneal@0 | 38 } |
bgneal@0 | 39 |
bgneal@0 | 40 //void test_commented_out(const std::string&) |
bgneal@0 | 41 //{ |
bgneal@0 | 42 // fructose_assert(false); |
bgneal@0 | 43 //} |
bgneal@0 | 44 }; |
bgneal@0 | 45 |
bgneal@0 | 46 // class MyTest : public fructose::test_base<MyTest> |
bgneal@0 | 47 // { |
bgneal@0 | 48 // public: |
bgneal@0 | 49 // void testIt(const std::string&) |
bgneal@0 | 50 // { |
bgneal@0 | 51 // fructose_assert(true); |
bgneal@0 | 52 // } |
bgneal@0 | 53 // }; |
bgneal@0 | 54 |
bgneal@0 | 55 class MyTest : public fructose::test_base<MyTest> |
bgneal@0 | 56 { |
bgneal@0 | 57 public: |
bgneal@0 | 58 void testIt(const std::string&) |
bgneal@0 | 59 { |
bgneal@0 | 60 fructose_assert(true); |
bgneal@0 | 61 } |
bgneal@0 | 62 }; |
bgneal@0 | 63 #endif |