comparison tests/x3.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 struct exception_test : public fructose::test_base<exception_test>
20 {
21 void test_array_bounds(const std::string&)
22 {
23 std::vector<int> v;
24 v.push_back(1234);
25 fructose_assert_exception(v.at(2), std::out_of_range);
26 }
27
28 void test_should_catch_std_exceptions(const std::string& )
29 {
30 fructose_assert_exception(throw my_logic_error("a coding error has been detected"),
31 std::logic_error);
32 fructose_assert_exception(throw my_runtime_error("my runtime error"),
33 std::runtime_error);
34 fructose_assert_exception(throw my_logic_error("another coding error has been detected"),
35 std::exception);
36 fructose_assert_exception(throw my_runtime_error("my runtime error"),
37 std::exception);
38 }
39
40 //void test_commented_out(const std::string&)
41 //{
42 // fructose_assert(false);
43 //}
44 };
45
46 // class MyTest : public fructose::test_base<MyTest>
47 // {
48 // public:
49 // void testIt(const std::string&)
50 // {
51 // fructose_assert(true);
52 // }
53 // };
54
55 class MyTest : public fructose::test_base<MyTest>
56 {
57 public:
58 void testIt(const std::string&)
59 {
60 fructose_assert(true);
61 }
62 };
63 #endif