Mercurial > public > fructose_gen
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:d098192f01d9 |
---|---|
1 #ifndef FRUCTOSE_MAIN_TEST_X3_H | |
2 #define FRUCTOSE_MAIN_TEST_X3_H | |
3 | |
4 #include <stdexcept> | |
5 #include <vector> | |
6 | |
7 #include "fructose/fructose.h" | |
8 | |
9 struct my_logic_error : public std::logic_error | |
10 { | |
11 my_logic_error(const char* message) : std::logic_error(message) {} | |
12 }; | |
13 | |
14 struct my_runtime_error : public std::runtime_error | |
15 { | |
16 my_runtime_error(const char* message) : std::runtime_error(message) {} | |
17 }; | |
18 | |
19 FRUCTOSE_CLASS(exception_test) | |
20 { | |
21 public: | |
22 FRUCTOSE_TEST(array_bounds) | |
23 { | |
24 std::vector<int> v; | |
25 v.push_back(1234); | |
26 fructose_assert_exception(v.at(2), std::out_of_range); | |
27 } | |
28 | |
29 FRUCTOSE_TEST(should_catch_std_exceptions) | |
30 { | |
31 fructose_assert_exception(throw my_logic_error("a coding error has been detected"), | |
32 std::logic_error); | |
33 fructose_assert_exception(throw my_runtime_error("my runtime error"), | |
34 std::runtime_error); | |
35 fructose_assert_exception(throw my_logic_error("another coding error has been detected"), | |
36 std::exception); | |
37 fructose_assert_exception(throw my_runtime_error("my runtime error"), | |
38 std::exception); | |
39 } | |
40 | |
41 //FRUCTOSE_TEST(commented_out) | |
42 //{ | |
43 // fructose_assert(false); | |
44 //} | |
45 }; | |
46 | |
47 // FRUCTOSE_CLASS(MyTest) | |
48 // { | |
49 // public: | |
50 // void testIt(const std::string&) | |
51 // { | |
52 // fructose_assert(true); | |
53 // } | |
54 // }; | |
55 | |
56 FRUCTOSE_CLASS(MyTest) | |
57 { | |
58 public: | |
59 void testIt(const std::string&) | |
60 { | |
61 fructose_assert(true); | |
62 } | |
63 }; | |
64 #endif |