]>
Commit | Line | Data |
---|---|---|
b32b8144 FG |
1 | // (C) Copyright Raffi Enficiaud 2017. |
2 | // Distributed under the Boost Software License, Version 1.0. | |
3 | // (See accompanying file LICENSE_1_0.txt or copy at | |
4 | // http://www.boost.org/LICENSE_1_0.txt) | |
5 | ||
6 | // See http://www.boost.org/libs/test for the library home page. | |
7 | ||
8 | // checks issue https://svn.boost.org/trac/boost/ticket/5563 in particular | |
9 | // the ability of the framework to detect new fixture signatures. | |
10 | ||
11 | #define BOOST_TEST_MODULE test_fixture_detect_setup_teardown_cpp11 | |
12 | #include <boost/test/unit_test.hpp> | |
13 | #include <iostream> | |
14 | #include <boost/test/unit_test_suite.hpp> | |
15 | #include <boost/test/framework.hpp> | |
16 | ||
17 | using namespace boost::unit_test; | |
18 | ||
19 | class fixture_without { | |
20 | public: | |
21 | fixture_without() {} | |
22 | ~fixture_without() {} | |
23 | }; | |
24 | ||
25 | class fixture_with { | |
26 | public: | |
27 | fixture_with() {} | |
28 | void setup() {} | |
29 | void teardown() {} | |
30 | ~fixture_with() {} | |
31 | }; | |
32 | ||
33 | class fixture_with_child : public fixture_with { | |
34 | public: | |
35 | fixture_with_child() {} | |
36 | ~fixture_with_child() {} | |
37 | }; | |
38 | ||
39 | BOOST_AUTO_TEST_CASE( fixture_setup_teardown_detect ) | |
40 | { | |
41 | BOOST_CHECK(!impl_fixture::has_setup<fixture_without>::value); | |
42 | BOOST_CHECK(!impl_fixture::has_setup<fixture_without>::value); | |
43 | ||
44 | fixture_without obj; | |
45 | setup_conditional(obj); | |
46 | teardown_conditional(obj); | |
47 | } | |
48 | ||
49 | BOOST_AUTO_TEST_CASE( fixture_setup_teardown_detect_both ) | |
50 | { | |
51 | BOOST_CHECK(impl_fixture::has_setup<fixture_with>::value); | |
52 | BOOST_CHECK(impl_fixture::has_setup<fixture_with>::value); | |
53 | ||
54 | fixture_with obj; | |
55 | setup_conditional(obj); | |
56 | teardown_conditional(obj); | |
57 | } | |
58 | ||
59 | BOOST_AUTO_TEST_CASE( fixture_setup_teardown_detect_both_from_child ) | |
60 | { | |
61 | // should detect this with the C++11/declspec approach | |
62 | BOOST_CHECK(impl_fixture::has_setup<fixture_with_child>::value); | |
63 | BOOST_CHECK(impl_fixture::has_setup<fixture_with_child>::value); | |
64 | ||
65 | fixture_with_child obj; | |
66 | setup_conditional(obj); | |
67 | teardown_conditional(obj); | |
68 | } |