2 Copyright 2010, 2011 Beman Dawes
3 Copyright 2013 Ion Gaztanaga
4 Copyright 2014 Peter Dimov
6 Distributed under the Boost Software License, Version 1.0.
8 See accompanying file LICENSE_1_0.txt
9 or copy at http://boost.org/LICENSE_1_0.txt
12 [section:lightweight_test lightweight_test]
21 [section Header <boost/core/lightweight_test.hpp>]
23 The header `<boost/core/lightweight_test.hpp>` is a
24 lightweight test framework. It's useful for writing
25 Boost regression tests for components that are dependencies
28 When using `lightweight_test.hpp`, *do not forget* to
29 `return boost::report_errors()` from `main`.
34 #define BOOST_TEST(expression) /*unspecified*/
35 #define BOOST_TEST_NOT(expression) /*unspecified*/
36 #define BOOST_ERROR(message) /*unspecified*/
37 #define BOOST_TEST_EQ(expr1, expr2) /*unspecified*/
38 #define BOOST_TEST_NE(expr1, expr2) /*unspecified*/
39 #define BOOST_TEST_THROWS(expr, excep) /*unspecified*/
52 BOOST_TEST(expression)
55 If expression is false increases the error count and outputs a
56 message containing `expression`.
60 [section BOOST_TEST_NOT]
63 BOOST_TEST_NOT(expression)
66 If expression is true increases the error count and outputs a
67 message containing `!(expression)`.
77 Increases error count and outputs a message containing
82 [section BOOST_TEST_EQ]
85 BOOST_TEST_EQ(expr1, expr2)
88 If `expr1 != expr2` increases the error count and outputs a
89 message containing both expressions.
93 [section BOOST_TEST_NE]
96 BOOST_TEST_NE(expr1, expr2)
99 If `expr1 == expr2` increases the error count and outputs a
100 message containing both expressions.
104 [section BOOST_TEST_THROWS]
107 BOOST_TEST_THROWS(expr, excep)
110 If `BOOST_NO_EXCEPTIONS` is *not* defined and if `expr` does not
111 throw an exception of type `excep`, increases the error count
112 and outputs a message containing the expression.
114 If `BOOST_NO_EXCEPTIONS` is defined, this macro expands to
115 nothing and `expr` is not evaluated.
119 [section report_errors]
122 int boost::report_errors()
125 Return the error count from `main`.
132 #include <boost/core/lightweight_test.hpp>
141 BOOST_TEST( sqr(2) == 4 );
142 BOOST_TEST_EQ( sqr(-3), 9 );
144 return boost::report_errors();
152 [section Header <boost/core/lightweight_test_trait.hpp>]
154 The header `<boost/core/lightweight_test_trait.hpp>` defines
155 a couple of extra macros for testing compile-time traits that
156 return a boolean value.
161 #define BOOST_TEST_TRAIT_TRUE((Trait)) /*unspecified*/
162 #define BOOST_TEST_TRAIT_FALSE((Trait)) /*unspecified*/
167 [section BOOST_TEST_TRAIT_TRUE]
170 BOOST_TEST_TRAIT_TRUE((Trait))
173 If `Trait::value != true` increases the error count and outputs a
174 message containing `Trait`. Note the double set of parentheses; these
175 enable `Trait` to contain a comma, which is common for templates.
179 [section BOOST_TEST_TRAIT_FALSE]
182 BOOST_TEST_TRAIT_FALSE((Trait))
185 If `Trait::value != false` increases the error count and outputs a
186 message containing `Trait`. Note the double set of parentheses.
193 #include <boost/core/lightweight_test_trait.hpp>
194 #include <boost/core/is_same.hpp>
196 template<class T, class U> struct X
201 using boost::core::is_same;
205 BOOST_TEST_TRAIT_TRUE(( is_same<X<int, long>::type, int> ));
207 return boost::report_errors();