gtest/include/gtest/gtest_pred_impl.h
Go to the documentation of this file.
1 // Copyright 2006, Google Inc.
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
6 // met:
7 //
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above
11 // copyright notice, this list of conditions and the following disclaimer
12 // in the documentation and/or other materials provided with the
13 // distribution.
14 // * Neither the name of Google Inc. nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 
30 // This file is AUTOMATICALLY GENERATED on 10/31/2011 by command
31 // 'gen_gtest_pred_impl.py 5'. DO NOT EDIT BY HAND!
32 //
33 // Implements a family of generic predicate assertion macros.
34 
35 #ifndef GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
36 #define GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
37 
38 // Makes sure this header is not included before gtest.h.
39 #ifndef GTEST_INCLUDE_GTEST_GTEST_H_
40 # error Do not include gtest_pred_impl.h directly. Include gtest.h instead.
41 #endif // GTEST_INCLUDE_GTEST_GTEST_H_
42 
43 // This header implements a family of generic predicate assertion
44 // macros:
45 //
46 // ASSERT_PRED_FORMAT1(pred_format, v1)
47 // ASSERT_PRED_FORMAT2(pred_format, v1, v2)
48 // ...
49 //
50 // where pred_format is a function or functor that takes n (in the
51 // case of ASSERT_PRED_FORMATn) values and their source expression
52 // text, and returns a testing::AssertionResult. See the definition
53 // of ASSERT_EQ in gtest.h for an example.
54 //
55 // If you don't care about formatting, you can use the more
56 // restrictive version:
57 //
58 // ASSERT_PRED1(pred, v1)
59 // ASSERT_PRED2(pred, v1, v2)
60 // ...
61 //
62 // where pred is an n-ary function or functor that returns bool,
63 // and the values v1, v2, ..., must support the << operator for
64 // streaming to std::ostream.
65 //
66 // We also define the EXPECT_* variations.
67 //
68 // For now we only support predicates whose arity is at most 5.
69 // Please email googletestframework@googlegroups.com if you need
70 // support for higher arities.
71 
72 // GTEST_ASSERT_ is the basic statement to which all of the assertions
73 // in this file reduce. Don't use this in your code.
74 
75 #define GTEST_ASSERT_(expression, on_failure) \
76  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
77  if (const ::testing::AssertionResult gtest_ar = (expression)) \
78  ; \
79  else \
80  on_failure(gtest_ar.failure_message())
81 
82 
83 // Helper function for implementing {EXPECT|ASSERT}_PRED1. Don't use
84 // this in your code.
85 template <typename Pred,
86  typename T1>
87 AssertionResult AssertPred1Helper(const char * pred_text,
88  const char * e1,
89  Pred pred,
90  const T1 & v1)
91 {
92  if (pred(v1)) { return AssertionSuccess(); }
93 
94  return AssertionFailure() << pred_text << "("
95  << e1 << ") evaluates to false, where"
96  << "\n" << e1 << " evaluates to " << v1;
97 }
98 
99 // Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT1.
100 // Don't use this in your code.
101 #define GTEST_PRED_FORMAT1_(pred_format, v1, on_failure)\
102  GTEST_ASSERT_(pred_format(#v1, v1), \
103  on_failure)
104 
105 // Internal macro for implementing {EXPECT|ASSERT}_PRED1. Don't use
106 // this in your code.
107 #define GTEST_PRED1_(pred, v1, on_failure)\
108  GTEST_ASSERT_(::testing::AssertPred1Helper(#pred, \
109  #v1, \
110  pred, \
111  v1), on_failure)
112 
113 // Unary predicate assertion macros.
114 #define EXPECT_PRED_FORMAT1(pred_format, v1) \
115  GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_NONFATAL_FAILURE_)
116 #define EXPECT_PRED1(pred, v1) \
117  GTEST_PRED1_(pred, v1, GTEST_NONFATAL_FAILURE_)
118 #define ASSERT_PRED_FORMAT1(pred_format, v1) \
119  GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_FATAL_FAILURE_)
120 #define ASSERT_PRED1(pred, v1) \
121  GTEST_PRED1_(pred, v1, GTEST_FATAL_FAILURE_)
122 
123 
124 
125 // Helper function for implementing {EXPECT|ASSERT}_PRED2. Don't use
126 // this in your code.
127 template <typename Pred,
128  typename T1,
129  typename T2>
130 AssertionResult AssertPred2Helper(const char * pred_text,
131  const char * e1,
132  const char * e2,
133  Pred pred,
134  const T1 & v1,
135  const T2 & v2)
136 {
137  if (pred(v1, v2)) { return AssertionSuccess(); }
138 
139  return AssertionFailure() << pred_text << "("
140  << e1 << ", "
141  << e2 << ") evaluates to false, where"
142  << "\n" << e1 << " evaluates to " << v1
143  << "\n" << e2 << " evaluates to " << v2;
144 }
145 
146 // Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT2.
147 // Don't use this in your code.
148 #define GTEST_PRED_FORMAT2_(pred_format, v1, v2, on_failure)\
149  GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), \
150  on_failure)
151 
152 // Internal macro for implementing {EXPECT|ASSERT}_PRED2. Don't use
153 // this in your code.
154 #define GTEST_PRED2_(pred, v1, v2, on_failure)\
155  GTEST_ASSERT_(::testing::AssertPred2Helper(#pred, \
156  #v1, \
157  #v2, \
158  pred, \
159  v1, \
160  v2), on_failure)
161 
162 // Binary predicate assertion macros.
163 #define EXPECT_PRED_FORMAT2(pred_format, v1, v2) \
164  GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_)
165 #define EXPECT_PRED2(pred, v1, v2) \
166  GTEST_PRED2_(pred, v1, v2, GTEST_NONFATAL_FAILURE_)
167 #define ASSERT_PRED_FORMAT2(pred_format, v1, v2) \
168  GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_FATAL_FAILURE_)
169 #define ASSERT_PRED2(pred, v1, v2) \
170  GTEST_PRED2_(pred, v1, v2, GTEST_FATAL_FAILURE_)
171 
172 
173 
174 // Helper function for implementing {EXPECT|ASSERT}_PRED3. Don't use
175 // this in your code.
176 template <typename Pred,
177  typename T1,
178  typename T2,
179  typename T3>
180 AssertionResult AssertPred3Helper(const char * pred_text,
181  const char * e1,
182  const char * e2,
183  const char * e3,
184  Pred pred,
185  const T1 & v1,
186  const T2 & v2,
187  const T3 & v3)
188 {
189  if (pred(v1, v2, v3)) { return AssertionSuccess(); }
190 
191  return AssertionFailure() << pred_text << "("
192  << e1 << ", "
193  << e2 << ", "
194  << e3 << ") evaluates to false, where"
195  << "\n" << e1 << " evaluates to " << v1
196  << "\n" << e2 << " evaluates to " << v2
197  << "\n" << e3 << " evaluates to " << v3;
198 }
199 
200 // Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT3.
201 // Don't use this in your code.
202 #define GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, on_failure)\
203  GTEST_ASSERT_(pred_format(#v1, #v2, #v3, v1, v2, v3), \
204  on_failure)
205 
206 // Internal macro for implementing {EXPECT|ASSERT}_PRED3. Don't use
207 // this in your code.
208 #define GTEST_PRED3_(pred, v1, v2, v3, on_failure)\
209  GTEST_ASSERT_(::testing::AssertPred3Helper(#pred, \
210  #v1, \
211  #v2, \
212  #v3, \
213  pred, \
214  v1, \
215  v2, \
216  v3), on_failure)
217 
218 // Ternary predicate assertion macros.
219 #define EXPECT_PRED_FORMAT3(pred_format, v1, v2, v3) \
220  GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_NONFATAL_FAILURE_)
221 #define EXPECT_PRED3(pred, v1, v2, v3) \
222  GTEST_PRED3_(pred, v1, v2, v3, GTEST_NONFATAL_FAILURE_)
223 #define ASSERT_PRED_FORMAT3(pred_format, v1, v2, v3) \
224  GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_FATAL_FAILURE_)
225 #define ASSERT_PRED3(pred, v1, v2, v3) \
226  GTEST_PRED3_(pred, v1, v2, v3, GTEST_FATAL_FAILURE_)
227 
228 
229 
230 // Helper function for implementing {EXPECT|ASSERT}_PRED4. Don't use
231 // this in your code.
232 template <typename Pred,
233  typename T1,
234  typename T2,
235  typename T3,
236  typename T4>
237 AssertionResult AssertPred4Helper(const char * pred_text,
238  const char * e1,
239  const char * e2,
240  const char * e3,
241  const char * e4,
242  Pred pred,
243  const T1 & v1,
244  const T2 & v2,
245  const T3 & v3,
246  const T4 & v4)
247 {
248  if (pred(v1, v2, v3, v4)) { return AssertionSuccess(); }
249 
250  return AssertionFailure() << pred_text << "("
251  << e1 << ", "
252  << e2 << ", "
253  << e3 << ", "
254  << e4 << ") evaluates to false, where"
255  << "\n" << e1 << " evaluates to " << v1
256  << "\n" << e2 << " evaluates to " << v2
257  << "\n" << e3 << " evaluates to " << v3
258  << "\n" << e4 << " evaluates to " << v4;
259 }
260 
261 // Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT4.
262 // Don't use this in your code.
263 #define GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, on_failure)\
264  GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, v1, v2, v3, v4), \
265  on_failure)
266 
267 // Internal macro for implementing {EXPECT|ASSERT}_PRED4. Don't use
268 // this in your code.
269 #define GTEST_PRED4_(pred, v1, v2, v3, v4, on_failure)\
270  GTEST_ASSERT_(::testing::AssertPred4Helper(#pred, \
271  #v1, \
272  #v2, \
273  #v3, \
274  #v4, \
275  pred, \
276  v1, \
277  v2, \
278  v3, \
279  v4), on_failure)
280 
281 // 4-ary predicate assertion macros.
282 #define EXPECT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \
283  GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_)
284 #define EXPECT_PRED4(pred, v1, v2, v3, v4) \
285  GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_)
286 #define ASSERT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \
287  GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_FATAL_FAILURE_)
288 #define ASSERT_PRED4(pred, v1, v2, v3, v4) \
289  GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_FATAL_FAILURE_)
290 
291 
292 
293 // Helper function for implementing {EXPECT|ASSERT}_PRED5. Don't use
294 // this in your code.
295 template <typename Pred,
296  typename T1,
297  typename T2,
298  typename T3,
299  typename T4,
300  typename T5>
301 AssertionResult AssertPred5Helper(const char * pred_text,
302  const char * e1,
303  const char * e2,
304  const char * e3,
305  const char * e4,
306  const char * e5,
307  Pred pred,
308  const T1 & v1,
309  const T2 & v2,
310  const T3 & v3,
311  const T4 & v4,
312  const T5 & v5)
313 {
314  if (pred(v1, v2, v3, v4, v5)) { return AssertionSuccess(); }
315 
316  return AssertionFailure() << pred_text << "("
317  << e1 << ", "
318  << e2 << ", "
319  << e3 << ", "
320  << e4 << ", "
321  << e5 << ") evaluates to false, where"
322  << "\n" << e1 << " evaluates to " << v1
323  << "\n" << e2 << " evaluates to " << v2
324  << "\n" << e3 << " evaluates to " << v3
325  << "\n" << e4 << " evaluates to " << v4
326  << "\n" << e5 << " evaluates to " << v5;
327 }
328 
329 // Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT5.
330 // Don't use this in your code.
331 #define GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, on_failure)\
332  GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, #v5, v1, v2, v3, v4, v5), \
333  on_failure)
334 
335 // Internal macro for implementing {EXPECT|ASSERT}_PRED5. Don't use
336 // this in your code.
337 #define GTEST_PRED5_(pred, v1, v2, v3, v4, v5, on_failure)\
338  GTEST_ASSERT_(::testing::AssertPred5Helper(#pred, \
339  #v1, \
340  #v2, \
341  #v3, \
342  #v4, \
343  #v5, \
344  pred, \
345  v1, \
346  v2, \
347  v3, \
348  v4, \
349  v5), on_failure)
350 
351 // 5-ary predicate assertion macros.
352 #define EXPECT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \
353  GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_)
354 #define EXPECT_PRED5(pred, v1, v2, v3, v4, v5) \
355  GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_)
356 #define ASSERT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \
357  GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_)
358 #define ASSERT_PRED5(pred, v1, v2, v3, v4, v5) \
359  GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_)
360 
361 
362 
363 #endif // GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
AssertionResult AssertionFailure()
AssertionResult AssertPred1Helper(const char *pred_text, const char *e1, Pred pred, const T1 &v1)
AssertionResult AssertionSuccess()
AssertionResult AssertPred4Helper(const char *pred_text, const char *e1, const char *e2, const char *e3, const char *e4, Pred pred, const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4)
AssertionResult AssertPred5Helper(const char *pred_text, const char *e1, const char *e2, const char *e3, const char *e4, const char *e5, Pred pred, const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4, const T5 &v5)
AssertionResult AssertPred3Helper(const char *pred_text, const char *e1, const char *e2, const char *e3, Pred pred, const T1 &v1, const T2 &v2, const T3 &v3)
AssertionResult AssertPred2Helper(const char *pred_text, const char *e1, const char *e2, Pred pred, const T1 &v1, const T2 &v2)


ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Tue Jan 19 2021 03:12:01