Mercurial > public > fructose_gen
annotate tests/g3.h @ 0:d098192f01d9
Initial commit to the repository.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 19 Mar 2011 19:53:12 -0500 |
parents | |
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 FRUCTOSE_CLASS(exception_test) |
bgneal@0 | 20 { |
bgneal@0 | 21 public: |
bgneal@0 | 22 FRUCTOSE_TEST(array_bounds) |
bgneal@0 | 23 { |
bgneal@0 | 24 std::vector<int> v; |
bgneal@0 | 25 v.push_back(1234); |
bgneal@0 | 26 fructose_assert_exception(v.at(2), std::out_of_range); |
bgneal@0 | 27 } |
bgneal@0 | 28 |
bgneal@0 | 29 FRUCTOSE_TEST(should_catch_std_exceptions) |
bgneal@0 | 30 { |
bgneal@0 | 31 fructose_assert_exception(throw my_logic_error("a coding error has been detected"), |
bgneal@0 | 32 std::logic_error); |
bgneal@0 | 33 fructose_assert_exception(throw my_runtime_error("my runtime error"), |
bgneal@0 | 34 std::runtime_error); |
bgneal@0 | 35 fructose_assert_exception(throw my_logic_error("another coding error has been detected"), |
bgneal@0 | 36 std::exception); |
bgneal@0 | 37 fructose_assert_exception(throw my_runtime_error("my runtime error"), |
bgneal@0 | 38 std::exception); |
bgneal@0 | 39 } |
bgneal@0 | 40 |
bgneal@0 | 41 //FRUCTOSE_TEST(commented_out) |
bgneal@0 | 42 //{ |
bgneal@0 | 43 // fructose_assert(false); |
bgneal@0 | 44 //} |
bgneal@0 | 45 }; |
bgneal@0 | 46 |
bgneal@0 | 47 // FRUCTOSE_CLASS(MyTest) |
bgneal@0 | 48 // { |
bgneal@0 | 49 // public: |
bgneal@0 | 50 // void testIt(const std::string&) |
bgneal@0 | 51 // { |
bgneal@0 | 52 // fructose_assert(true); |
bgneal@0 | 53 // } |
bgneal@0 | 54 // }; |
bgneal@0 | 55 |
bgneal@0 | 56 FRUCTOSE_CLASS(MyTest) |
bgneal@0 | 57 { |
bgneal@0 | 58 public: |
bgneal@0 | 59 void testIt(const std::string&) |
bgneal@0 | 60 { |
bgneal@0 | 61 fructose_assert(true); |
bgneal@0 | 62 } |
bgneal@0 | 63 }; |
bgneal@0 | 64 #endif |