3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>lightweight_test</title>
5 <link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7 <link rel="home" href="../index.html" title="Chapter 1. Boost.Core">
8 <link rel="up" href="../index.html" title="Chapter 1. Boost.Core">
9 <link rel="prev" href="is_same.html" title="is_same">
10 <link rel="next" href="no_exceptions_support.html" title="no_exceptions_support">
12 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13 <table cellpadding="2" width="100%"><tr>
14 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
15 <td align="center"><a href="../../../../../index.html">Home</a></td>
16 <td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
17 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19 <td align="center"><a href="../../../../../more/index.htm">More</a></td>
22 <div class="spirit-nav">
23 <a accesskey="p" href="is_same.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="no_exceptions_support.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
26 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
27 <a name="core.lightweight_test"></a><a class="link" href="lightweight_test.html" title="lightweight_test">lightweight_test</a>
28 </h2></div></div></div>
29 <div class="toc"><dl class="toc">
30 <dt><span class="section"><a href="lightweight_test.html#core.lightweight_test.header_boost_core_lightweight_te">Header
31 <boost/core/lightweight_test.hpp></a></span></dt>
32 <dt><span class="section"><a href="lightweight_test.html#core.lightweight_test.header_boost_core_lightweight_t0">Header
33 <boost/core/lightweight_test_trait.hpp></a></span></dt>
35 <div class="simplesect">
36 <div class="titlepage"><div><div><h3 class="title">
37 <a name="idm46687075377600"></a>Authors</h3></div></div></div>
38 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
48 <div class="titlepage"><div><div><h3 class="title">
49 <a name="core.lightweight_test.header_boost_core_lightweight_te"></a><a class="link" href="lightweight_test.html#core.lightweight_test.header_boost_core_lightweight_te" title="Header <boost/core/lightweight_test.hpp>">Header
50 <boost/core/lightweight_test.hpp></a>
51 </h3></div></div></div>
53 The header <code class="computeroutput"><span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">core</span><span class="special">/</span><span class="identifier">lightweight_test</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
54 is a lightweight test framework. It's useful for writing Boost regression
55 tests for components that are dependencies of Boost.Test.
58 When using <code class="computeroutput"><span class="identifier">lightweight_test</span><span class="special">.</span><span class="identifier">hpp</span></code>,
59 <span class="bold"><strong>do not forget</strong></span> to <code class="computeroutput"><span class="keyword">return</span>
60 <span class="identifier">boost</span><span class="special">::</span><span class="identifier">report_errors</span><span class="special">()</span></code>
61 from <code class="computeroutput"><span class="identifier">main</span></code>.
64 <div class="titlepage"><div><div><h4 class="title">
65 <a name="core.lightweight_test.header_boost_core_lightweight_te.synopsis"></a><a class="link" href="lightweight_test.html#core.lightweight_test.header_boost_core_lightweight_te.synopsis" title="Synopsis">Synopsis</a>
66 </h4></div></div></div>
67 <pre class="programlisting"><span class="preprocessor">#define</span> <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">expression</span><span class="special">)</span> <span class="comment">/*unspecified*/</span>
68 <span class="preprocessor">#define</span> <span class="identifier">BOOST_TEST_NOT</span><span class="special">(</span><span class="identifier">expression</span><span class="special">)</span> <span class="comment">/*unspecified*/</span>
69 <span class="preprocessor">#define</span> <span class="identifier">BOOST_ERROR</span><span class="special">(</span><span class="identifier">message</span><span class="special">)</span> <span class="comment">/*unspecified*/</span>
70 <span class="preprocessor">#define</span> <span class="identifier">BOOST_TEST_EQ</span><span class="special">(</span><span class="identifier">expr1</span><span class="special">,</span> <span class="identifier">expr2</span><span class="special">)</span> <span class="comment">/*unspecified*/</span>
71 <span class="preprocessor">#define</span> <span class="identifier">BOOST_TEST_NE</span><span class="special">(</span><span class="identifier">expr1</span><span class="special">,</span> <span class="identifier">expr2</span><span class="special">)</span> <span class="comment">/*unspecified*/</span>
72 <span class="preprocessor">#define</span> <span class="identifier">BOOST_TEST_LT</span><span class="special">(</span><span class="identifier">expr1</span><span class="special">,</span> <span class="identifier">expr2</span><span class="special">)</span> <span class="comment">/*unspecified*/</span>
73 <span class="preprocessor">#define</span> <span class="identifier">BOOST_TEST_LE</span><span class="special">(</span><span class="identifier">expr1</span><span class="special">,</span> <span class="identifier">expr2</span><span class="special">)</span> <span class="comment">/*unspecified*/</span>
74 <span class="preprocessor">#define</span> <span class="identifier">BOOST_TEST_GT</span><span class="special">(</span><span class="identifier">expr1</span><span class="special">,</span> <span class="identifier">expr2</span><span class="special">)</span> <span class="comment">/*unspecified*/</span>
75 <span class="preprocessor">#define</span> <span class="identifier">BOOST_TEST_GE</span><span class="special">(</span><span class="identifier">expr1</span><span class="special">,</span> <span class="identifier">expr2</span><span class="special">)</span> <span class="comment">/*unspecified*/</span>
76 <span class="preprocessor">#define</span> <span class="identifier">BOOST_TEST_CSTR_EQ</span><span class="special">(</span><span class="identifier">expr1</span><span class="special">,</span> <span class="identifier">expr2</span><span class="special">)</span> <span class="comment">/*unspecified*/</span>
77 <span class="preprocessor">#define</span> <span class="identifier">BOOST_TEST_CSTR_NE</span><span class="special">(</span><span class="identifier">expr1</span><span class="special">,</span> <span class="identifier">expr2</span><span class="special">)</span> <span class="comment">/*unspecified*/</span>
78 <span class="preprocessor">#define</span> <span class="identifier">BOOST_TEST_ALL_EQ</span><span class="special">(</span><span class="identifier">begin1</span><span class="special">,</span> <span class="identifier">end1</span><span class="special">,</span> <span class="identifier">begin2</span><span class="special">,</span> <span class="identifier">end2</span><span class="special">)</span> <span class="comment">/* unspecified */</span>
79 <span class="preprocessor">#define</span> <span class="identifier">BOOST_TEST_ALL_WITH</span><span class="special">(</span><span class="identifier">begin1</span><span class="special">,</span> <span class="identifier">end1</span><span class="special">,</span> <span class="identifier">begin2</span><span class="special">,</span> <span class="identifier">end2</span><span class="special">,</span> <span class="identifier">predicate</span><span class="special">)</span> <span class="comment">/* unspecified */</span>
80 <span class="preprocessor">#define</span> <span class="identifier">BOOST_TEST_THROWS</span><span class="special">(</span><span class="identifier">expr</span><span class="special">,</span> <span class="identifier">excep</span><span class="special">)</span> <span class="comment">/*unspecified*/</span>
82 <span class="keyword">namespace</span> <span class="identifier">boost</span>
83 <span class="special">{</span>
84 <span class="keyword">int</span> <span class="identifier">report_errors</span><span class="special">();</span>
85 <span class="special">}</span>
89 <div class="titlepage"><div><div><h4 class="title">
90 <a name="core.lightweight_test.header_boost_core_lightweight_te.boost_test"></a><a class="link" href="lightweight_test.html#core.lightweight_test.header_boost_core_lightweight_te.boost_test" title="BOOST_TEST">BOOST_TEST</a>
91 </h4></div></div></div>
92 <pre class="programlisting"><span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">expression</span><span class="special">)</span>
95 If expression is false increases the error count and outputs a message
96 containing <code class="computeroutput"><span class="identifier">expression</span></code>.
100 <div class="titlepage"><div><div><h4 class="title">
101 <a name="core.lightweight_test.header_boost_core_lightweight_te.boost_test_not"></a><a class="link" href="lightweight_test.html#core.lightweight_test.header_boost_core_lightweight_te.boost_test_not" title="BOOST_TEST_NOT">BOOST_TEST_NOT</a>
102 </h4></div></div></div>
103 <pre class="programlisting"><span class="identifier">BOOST_TEST_NOT</span><span class="special">(</span><span class="identifier">expression</span><span class="special">)</span>
106 If expression is true increases the error count and outputs a message containing
107 <code class="computeroutput"><span class="special">!(</span><span class="identifier">expression</span><span class="special">)</span></code>.
110 <div class="section">
111 <div class="titlepage"><div><div><h4 class="title">
112 <a name="core.lightweight_test.header_boost_core_lightweight_te.boost_error"></a><a class="link" href="lightweight_test.html#core.lightweight_test.header_boost_core_lightweight_te.boost_error" title="BOOST_ERROR">BOOST_ERROR</a>
113 </h4></div></div></div>
114 <pre class="programlisting"><span class="identifier">BOOST_ERROR</span><span class="special">(</span><span class="identifier">message</span><span class="special">)</span>
117 Increases error count and outputs a message containing <code class="computeroutput"><span class="identifier">message</span></code>.
120 <div class="section">
121 <div class="titlepage"><div><div><h4 class="title">
122 <a name="core.lightweight_test.header_boost_core_lightweight_te.boost_test_eq"></a><a class="link" href="lightweight_test.html#core.lightweight_test.header_boost_core_lightweight_te.boost_test_eq" title="BOOST_TEST_EQ">BOOST_TEST_EQ</a>
123 </h4></div></div></div>
124 <pre class="programlisting"><span class="identifier">BOOST_TEST_EQ</span><span class="special">(</span><span class="identifier">expr1</span><span class="special">,</span> <span class="identifier">expr2</span><span class="special">)</span>
127 If <code class="computeroutput"><span class="identifier">expr1</span> <span class="special">==</span>
128 <span class="identifier">expr2</span></code> is not true increases the
129 error count and outputs a message containing both expressions.
132 <div class="section">
133 <div class="titlepage"><div><div><h4 class="title">
134 <a name="core.lightweight_test.header_boost_core_lightweight_te.boost_test_ne"></a><a class="link" href="lightweight_test.html#core.lightweight_test.header_boost_core_lightweight_te.boost_test_ne" title="BOOST_TEST_NE">BOOST_TEST_NE</a>
135 </h4></div></div></div>
136 <pre class="programlisting"><span class="identifier">BOOST_TEST_NE</span><span class="special">(</span><span class="identifier">expr1</span><span class="special">,</span> <span class="identifier">expr2</span><span class="special">)</span>
139 If <code class="computeroutput"><span class="identifier">expr1</span> <span class="special">!=</span>
140 <span class="identifier">expr2</span></code> is not true increases the
141 error count and outputs a message containing both expressions.
144 <div class="section">
145 <div class="titlepage"><div><div><h4 class="title">
146 <a name="core.lightweight_test.header_boost_core_lightweight_te.boost_test_lt"></a><a class="link" href="lightweight_test.html#core.lightweight_test.header_boost_core_lightweight_te.boost_test_lt" title="BOOST_TEST_LT">BOOST_TEST_LT</a>
147 </h4></div></div></div>
148 <pre class="programlisting"><span class="identifier">BOOST_TEST_LT</span><span class="special">(</span><span class="identifier">expr1</span><span class="special">,</span> <span class="identifier">expr2</span><span class="special">)</span>
151 If <code class="computeroutput"><span class="identifier">expr1</span> <span class="special"><</span>
152 <span class="identifier">expr2</span></code> is not true increases the
153 error count and outputs a message containing both expressions.
156 <div class="section">
157 <div class="titlepage"><div><div><h4 class="title">
158 <a name="core.lightweight_test.header_boost_core_lightweight_te.boost_test_le"></a><a class="link" href="lightweight_test.html#core.lightweight_test.header_boost_core_lightweight_te.boost_test_le" title="BOOST_TEST_LE">BOOST_TEST_LE</a>
159 </h4></div></div></div>
160 <pre class="programlisting"><span class="identifier">BOOST_TEST_LE</span><span class="special">(</span><span class="identifier">expr1</span><span class="special">,</span> <span class="identifier">expr2</span><span class="special">)</span>
163 If <code class="computeroutput"><span class="identifier">expr1</span> <span class="special"><=</span>
164 <span class="identifier">expr2</span></code> is not true increases the
165 error count and outputs a message containing both expressions.
168 <div class="section">
169 <div class="titlepage"><div><div><h4 class="title">
170 <a name="core.lightweight_test.header_boost_core_lightweight_te.boost_test_gt"></a><a class="link" href="lightweight_test.html#core.lightweight_test.header_boost_core_lightweight_te.boost_test_gt" title="BOOST_TEST_GT">BOOST_TEST_GT</a>
171 </h4></div></div></div>
172 <pre class="programlisting"><span class="identifier">BOOST_TEST_GT</span><span class="special">(</span><span class="identifier">expr1</span><span class="special">,</span> <span class="identifier">expr2</span><span class="special">)</span>
175 If <code class="computeroutput"><span class="identifier">expr1</span> <span class="special">></span>
176 <span class="identifier">expr2</span></code> is not true increases the
177 error count and outputs a message containing both expressions.
180 <div class="section">
181 <div class="titlepage"><div><div><h4 class="title">
182 <a name="core.lightweight_test.header_boost_core_lightweight_te.boost_test_ge"></a><a class="link" href="lightweight_test.html#core.lightweight_test.header_boost_core_lightweight_te.boost_test_ge" title="BOOST_TEST_GE">BOOST_TEST_GE</a>
183 </h4></div></div></div>
184 <pre class="programlisting"><span class="identifier">BOOST_TEST_GE</span><span class="special">(</span><span class="identifier">expr1</span><span class="special">,</span> <span class="identifier">expr2</span><span class="special">)</span>
187 If <code class="computeroutput"><span class="identifier">expr1</span> <span class="special">>=</span>
188 <span class="identifier">expr2</span></code> is not true increases the
189 error count and outputs a message containing both expressions.
192 <div class="section">
193 <div class="titlepage"><div><div><h4 class="title">
194 <a name="core.lightweight_test.header_boost_core_lightweight_te.boost_test_cstr_eq"></a><a class="link" href="lightweight_test.html#core.lightweight_test.header_boost_core_lightweight_te.boost_test_cstr_eq" title="BOOST_TEST_CSTR_EQ">BOOST_TEST_CSTR_EQ</a>
195 </h4></div></div></div>
196 <pre class="programlisting"><span class="identifier">BOOST_TEST_CSTR_EQ</span><span class="special">(</span><span class="identifier">expr1</span><span class="special">,</span> <span class="identifier">expr2</span><span class="special">)</span>
199 Specialization of <code class="computeroutput"><span class="identifier">BOOST_TEST_EQ</span></code>
200 which interprets <code class="computeroutput"><span class="identifier">expr1</span></code>
201 and <code class="computeroutput"><span class="identifier">expr2</span></code> as pointers to
202 null-terminated byte strings (C strings). If <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">strcmp</span><span class="special">(</span><span class="identifier">expr1</span><span class="special">,</span> <span class="identifier">expr2</span><span class="special">)</span> <span class="special">!=</span> <span class="number">0</span></code>,
203 increase the error count and output a message containing both expressions.
206 <div class="section">
207 <div class="titlepage"><div><div><h4 class="title">
208 <a name="core.lightweight_test.header_boost_core_lightweight_te.boost_test_cstr_ne"></a><a class="link" href="lightweight_test.html#core.lightweight_test.header_boost_core_lightweight_te.boost_test_cstr_ne" title="BOOST_TEST_CSTR_NE">BOOST_TEST_CSTR_NE</a>
209 </h4></div></div></div>
210 <pre class="programlisting"><span class="identifier">BOOST_TEST_CSTR_NE</span><span class="special">(</span><span class="identifier">expr1</span><span class="special">,</span> <span class="identifier">expr2</span><span class="special">)</span>
213 Specialization of <code class="computeroutput"><span class="identifier">BOOST_TEST_NE</span></code>
214 which interprets <code class="computeroutput"><span class="identifier">expr1</span></code>
215 and <code class="computeroutput"><span class="identifier">expr2</span></code> as pointers to
216 null-terminated byte strings (C strings). If <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">strcmp</span><span class="special">(</span><span class="identifier">expr1</span><span class="special">,</span> <span class="identifier">expr2</span><span class="special">)</span> <span class="special">==</span> <span class="number">0</span></code>,
217 increase the error count and output a message containing both expressions.
220 <div class="section">
221 <div class="titlepage"><div><div><h4 class="title">
222 <a name="core.lightweight_test.header_boost_core_lightweight_te.boost_test_all_eq"></a><a class="link" href="lightweight_test.html#core.lightweight_test.header_boost_core_lightweight_te.boost_test_all_eq" title="BOOST_TEST_ALL_EQ">BOOST_TEST_ALL_EQ</a>
223 </h4></div></div></div>
224 <pre class="programlisting"><span class="identifier">BOOST_TEST_ALL_EQ</span><span class="special">(</span><span class="identifier">begin1</span><span class="special">,</span> <span class="identifier">end1</span><span class="special">,</span> <span class="identifier">begin2</span><span class="special">,</span> <span class="identifier">end2</span><span class="special">)</span>
227 Compares the content of two sequences. If they have different sizes, or
228 if any pairwise element differs, increases the error count and outputs
229 a message containing at most 8 differing elements.
232 <div class="section">
233 <div class="titlepage"><div><div><h4 class="title">
234 <a name="core.lightweight_test.header_boost_core_lightweight_te.boost_test_all_with"></a><a class="link" href="lightweight_test.html#core.lightweight_test.header_boost_core_lightweight_te.boost_test_all_with" title="BOOST_TEST_ALL_WITH">BOOST_TEST_ALL_WITH</a>
235 </h4></div></div></div>
236 <pre class="programlisting"><span class="identifier">BOOST_TEST_ALL_WITH</span><span class="special">(</span><span class="identifier">begin1</span><span class="special">,</span> <span class="identifier">end1</span><span class="special">,</span> <span class="identifier">begin2</span><span class="special">,</span> <span class="identifier">end2</span><span class="special">,</span> <span class="identifier">predicate</span><span class="special">)</span>
239 Compares the content of two sequences. If they have different sizes, or
240 if any pairwise element do not fulfill the binary predicate, increases
241 the error count and outputs a message containing at most 8 differing elements.
244 <div class="section">
245 <div class="titlepage"><div><div><h4 class="title">
246 <a name="core.lightweight_test.header_boost_core_lightweight_te.boost_test_throws"></a><a class="link" href="lightweight_test.html#core.lightweight_test.header_boost_core_lightweight_te.boost_test_throws" title="BOOST_TEST_THROWS">BOOST_TEST_THROWS</a>
247 </h4></div></div></div>
248 <pre class="programlisting"><span class="identifier">BOOST_TEST_THROWS</span><span class="special">(</span><span class="identifier">expr</span><span class="special">,</span> <span class="identifier">excep</span><span class="special">)</span>
251 If <code class="computeroutput"><span class="identifier">BOOST_NO_EXCEPTIONS</span></code>
252 is <span class="bold"><strong>not</strong></span> defined and if <code class="computeroutput"><span class="identifier">expr</span></code>
253 does not throw an exception of type <code class="computeroutput"><span class="identifier">excep</span></code>,
254 increases the error count and outputs a message containing the expression.
257 If <code class="computeroutput"><span class="identifier">BOOST_NO_EXCEPTIONS</span></code>
258 is defined, this macro expands to nothing and <code class="computeroutput"><span class="identifier">expr</span></code>
262 <div class="section">
263 <div class="titlepage"><div><div><h4 class="title">
264 <a name="core.lightweight_test.header_boost_core_lightweight_te.report_errors"></a><a class="link" href="lightweight_test.html#core.lightweight_test.header_boost_core_lightweight_te.report_errors" title="report_errors">report_errors</a>
265 </h4></div></div></div>
266 <pre class="programlisting"><span class="keyword">int</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">report_errors</span><span class="special">()</span>
269 Return the error count from <code class="computeroutput"><span class="identifier">main</span></code>.
272 <div class="section">
273 <div class="titlepage"><div><div><h4 class="title">
274 <a name="core.lightweight_test.header_boost_core_lightweight_te.example"></a><a class="link" href="lightweight_test.html#core.lightweight_test.header_boost_core_lightweight_te.example" title="Example">Example</a>
275 </h4></div></div></div>
276 <pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">core</span><span class="special">/</span><span class="identifier">lightweight_test</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
278 <span class="keyword">int</span> <span class="identifier">sqr</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">x</span> <span class="special">)</span>
279 <span class="special">{</span>
280 <span class="keyword">return</span> <span class="identifier">x</span> <span class="special">*</span> <span class="identifier">x</span><span class="special">;</span>
281 <span class="special">}</span>
283 <span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
284 <span class="special">{</span>
285 <span class="identifier">BOOST_TEST</span><span class="special">(</span> <span class="identifier">sqr</span><span class="special">(</span><span class="number">2</span><span class="special">)</span> <span class="special">==</span> <span class="number">4</span> <span class="special">);</span>
286 <span class="identifier">BOOST_TEST_EQ</span><span class="special">(</span> <span class="identifier">sqr</span><span class="special">(-</span><span class="number">3</span><span class="special">),</span> <span class="number">9</span> <span class="special">);</span>
288 <span class="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">report_errors</span><span class="special">();</span>
289 <span class="special">}</span>
293 <div class="section">
294 <div class="titlepage"><div><div><h3 class="title">
295 <a name="core.lightweight_test.header_boost_core_lightweight_t0"></a><a class="link" href="lightweight_test.html#core.lightweight_test.header_boost_core_lightweight_t0" title="Header <boost/core/lightweight_test_trait.hpp>">Header
296 <boost/core/lightweight_test_trait.hpp></a>
297 </h3></div></div></div>
299 The header <code class="computeroutput"><span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">core</span><span class="special">/</span><span class="identifier">lightweight_test_trait</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
300 defines a couple of extra macros for testing compile-time traits that return
303 <div class="section">
304 <div class="titlepage"><div><div><h4 class="title">
305 <a name="core.lightweight_test.header_boost_core_lightweight_t0.synopsis"></a><a class="link" href="lightweight_test.html#core.lightweight_test.header_boost_core_lightweight_t0.synopsis" title="Synopsis">Synopsis</a>
306 </h4></div></div></div>
307 <pre class="programlisting"><span class="preprocessor">#define</span> <span class="identifier">BOOST_TEST_TRAIT_TRUE</span><span class="special">((</span><span class="identifier">Trait</span><span class="special">))</span> <span class="comment">/*unspecified*/</span>
308 <span class="preprocessor">#define</span> <span class="identifier">BOOST_TEST_TRAIT_FALSE</span><span class="special">((</span><span class="identifier">Trait</span><span class="special">))</span> <span class="comment">/*unspecified*/</span>
309 <span class="preprocessor">#define</span> <span class="identifier">BOOST_TEST_TRAIT_SAME</span><span class="special">(</span><span class="identifier">Type1</span><span class="special">,</span> <span class="identifier">Type2</span><span class="special">)</span> <span class="comment">/*unspecified*/</span>
312 <div class="section">
313 <div class="titlepage"><div><div><h4 class="title">
314 <a name="core.lightweight_test.header_boost_core_lightweight_t0.boost_test_trait_true"></a><a class="link" href="lightweight_test.html#core.lightweight_test.header_boost_core_lightweight_t0.boost_test_trait_true" title="BOOST_TEST_TRAIT_TRUE">BOOST_TEST_TRAIT_TRUE</a>
315 </h4></div></div></div>
316 <pre class="programlisting"><span class="identifier">BOOST_TEST_TRAIT_TRUE</span><span class="special">((</span><span class="identifier">Trait</span><span class="special">))</span>
319 If <code class="computeroutput"><span class="identifier">Trait</span><span class="special">::</span><span class="identifier">value</span> <span class="special">!=</span> <span class="keyword">true</span></code> increases the error count and outputs
320 a message containing <code class="computeroutput"><span class="identifier">Trait</span></code>.
321 Note the double set of parentheses; these enable <code class="computeroutput"><span class="identifier">Trait</span></code>
322 to contain a comma, which is common for templates.
325 <div class="section">
326 <div class="titlepage"><div><div><h4 class="title">
327 <a name="core.lightweight_test.header_boost_core_lightweight_t0.boost_test_trait_false"></a><a class="link" href="lightweight_test.html#core.lightweight_test.header_boost_core_lightweight_t0.boost_test_trait_false" title="BOOST_TEST_TRAIT_FALSE">BOOST_TEST_TRAIT_FALSE</a>
328 </h4></div></div></div>
329 <pre class="programlisting"><span class="identifier">BOOST_TEST_TRAIT_FALSE</span><span class="special">((</span><span class="identifier">Trait</span><span class="special">))</span>
332 If <code class="computeroutput"><span class="identifier">Trait</span><span class="special">::</span><span class="identifier">value</span> <span class="special">!=</span> <span class="keyword">false</span></code> increases the error count and outputs
333 a message containing <code class="computeroutput"><span class="identifier">Trait</span></code>.
334 Note the double set of parentheses.
337 <div class="section">
338 <div class="titlepage"><div><div><h4 class="title">
339 <a name="core.lightweight_test.header_boost_core_lightweight_t0.boost_test_trait_same"></a><a class="link" href="lightweight_test.html#core.lightweight_test.header_boost_core_lightweight_t0.boost_test_trait_same" title="BOOST_TEST_TRAIT_SAME">BOOST_TEST_TRAIT_SAME</a>
340 </h4></div></div></div>
341 <pre class="programlisting"><span class="identifier">BOOST_TEST_TRAIT_SAME</span><span class="special">(</span><span class="identifier">Type1</span><span class="special">,</span> <span class="identifier">Type2</span><span class="special">)</span>
344 If the two types are not the same, increases the error count and outputs
345 a message containing them. This macro requires that the compiler supports
346 variadic macros and <code class="computeroutput"><span class="identifier">__VA_ARGS__</span></code>.
347 (Note that unlike <code class="computeroutput"><span class="identifier">BOOST_TEST_TRAIT_TRUE</span></code>
348 and <code class="computeroutput"><span class="identifier">BOOST_TEST_TRAIT_FALSE</span></code>,
349 this macro only requires a single set of parentheses.)
352 <div class="section">
353 <div class="titlepage"><div><div><h4 class="title">
354 <a name="core.lightweight_test.header_boost_core_lightweight_t0.example"></a><a class="link" href="lightweight_test.html#core.lightweight_test.header_boost_core_lightweight_t0.example" title="Example">Example</a>
355 </h4></div></div></div>
356 <pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">core</span><span class="special">/</span><span class="identifier">lightweight_test_trait</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
357 <span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">core</span><span class="special">/</span><span class="identifier">is_same</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
359 <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">U</span><span class="special">></span> <span class="keyword">struct</span> <span class="identifier">X</span>
360 <span class="special">{</span>
361 <span class="keyword">typedef</span> <span class="identifier">T</span> <span class="identifier">type</span><span class="special">;</span>
362 <span class="special">};</span>
364 <span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">core</span><span class="special">::</span><span class="identifier">is_same</span><span class="special">;</span>
366 <span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
367 <span class="special">{</span>
368 <span class="identifier">BOOST_TEST_TRAIT_TRUE</span><span class="special">((</span> <span class="identifier">is_same</span><span class="special"><</span><span class="identifier">X</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span> <span class="keyword">long</span><span class="special">>::</span><span class="identifier">type</span><span class="special">,</span> <span class="keyword">int</span><span class="special">></span> <span class="special">));</span>
370 <span class="identifier">BOOST_TEST_TRAIT_SAME</span><span class="special">(</span> <span class="identifier">X</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span> <span class="keyword">long</span><span class="special">>::</span><span class="identifier">type</span><span class="special">,</span> <span class="keyword">int</span> <span class="special">);</span>
372 <span class="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">report_errors</span><span class="special">();</span>
373 <span class="special">}</span>
378 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
379 <td align="left"></td>
380 <td align="right"><div class="copyright-footer">Copyright © 2014 Peter Dimov<br>Copyright © 2014 Glen Fernandes<br>Copyright © 2014 Andrey Semashev<p>
381 Distributed under the <a href="http://boost.org/LICENSE_1_0.txt" target="_top">Boost
382 Software License, Version 1.0</a>.
387 <div class="spirit-nav">
388 <a accesskey="p" href="is_same.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="no_exceptions_support.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>