/thirdparty/breakpad/third_party/protobuf/protobuf/gtest/include/gtest/gtest_pred_impl.h

http://github.com/tomahawk-player/tomahawk · C++ Header · 368 lines · 227 code · 43 blank · 98 comment · 7 complexity · cbf630142417c158b4162e22dbb7be81 MD5 · raw 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. // This file is AUTOMATICALLY GENERATED on 10/02/2008 by command
  30. // 'gen_gtest_pred_impl.py 5'. DO NOT EDIT BY HAND!
  31. //
  32. // Implements a family of generic predicate assertion macros.
  33. #ifndef GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
  34. #define GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
  35. // Makes sure this header is not included before gtest.h.
  36. #ifndef GTEST_INCLUDE_GTEST_GTEST_H_
  37. #error Do not include gtest_pred_impl.h directly. Include gtest.h instead.
  38. #endif // GTEST_INCLUDE_GTEST_GTEST_H_
  39. // This header implements a family of generic predicate assertion
  40. // macros:
  41. //
  42. // ASSERT_PRED_FORMAT1(pred_format, v1)
  43. // ASSERT_PRED_FORMAT2(pred_format, v1, v2)
  44. // ...
  45. //
  46. // where pred_format is a function or functor that takes n (in the
  47. // case of ASSERT_PRED_FORMATn) values and their source expression
  48. // text, and returns a testing::AssertionResult. See the definition
  49. // of ASSERT_EQ in gtest.h for an example.
  50. //
  51. // If you don't care about formatting, you can use the more
  52. // restrictive version:
  53. //
  54. // ASSERT_PRED1(pred, v1)
  55. // ASSERT_PRED2(pred, v1, v2)
  56. // ...
  57. //
  58. // where pred is an n-ary function or functor that returns bool,
  59. // and the values v1, v2, ..., must support the << operator for
  60. // streaming to std::ostream.
  61. //
  62. // We also define the EXPECT_* variations.
  63. //
  64. // For now we only support predicates whose arity is at most 5.
  65. // Please email googletestframework@googlegroups.com if you need
  66. // support for higher arities.
  67. // GTEST_ASSERT_ is the basic statement to which all of the assertions
  68. // in this file reduce. Don't use this in your code.
  69. #define GTEST_ASSERT_(expression, on_failure) \
  70. GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
  71. if (const ::testing::AssertionResult gtest_ar = (expression)) \
  72. ; \
  73. else \
  74. on_failure(gtest_ar.failure_message())
  75. // Helper function for implementing {EXPECT|ASSERT}_PRED1. Don't use
  76. // this in your code.
  77. template <typename Pred,
  78. typename T1>
  79. AssertionResult AssertPred1Helper(const char* pred_text,
  80. const char* e1,
  81. Pred pred,
  82. const T1& v1) {
  83. if (pred(v1)) return AssertionSuccess();
  84. Message msg;
  85. msg << pred_text << "("
  86. << e1 << ") evaluates to false, where"
  87. << "\n" << e1 << " evaluates to " << v1;
  88. return AssertionFailure(msg);
  89. }
  90. // Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT1.
  91. // Don't use this in your code.
  92. #define GTEST_PRED_FORMAT1_(pred_format, v1, on_failure)\
  93. GTEST_ASSERT_(pred_format(#v1, v1),\
  94. on_failure)
  95. // Internal macro for implementing {EXPECT|ASSERT}_PRED1. Don't use
  96. // this in your code.
  97. #define GTEST_PRED1_(pred, v1, on_failure)\
  98. GTEST_ASSERT_(::testing::AssertPred1Helper(#pred, \
  99. #v1, \
  100. pred, \
  101. v1), on_failure)
  102. // Unary predicate assertion macros.
  103. #define EXPECT_PRED_FORMAT1(pred_format, v1) \
  104. GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_NONFATAL_FAILURE_)
  105. #define EXPECT_PRED1(pred, v1) \
  106. GTEST_PRED1_(pred, v1, GTEST_NONFATAL_FAILURE_)
  107. #define ASSERT_PRED_FORMAT1(pred_format, v1) \
  108. GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_FATAL_FAILURE_)
  109. #define ASSERT_PRED1(pred, v1) \
  110. GTEST_PRED1_(pred, v1, GTEST_FATAL_FAILURE_)
  111. // Helper function for implementing {EXPECT|ASSERT}_PRED2. Don't use
  112. // this in your code.
  113. template <typename Pred,
  114. typename T1,
  115. typename T2>
  116. AssertionResult AssertPred2Helper(const char* pred_text,
  117. const char* e1,
  118. const char* e2,
  119. Pred pred,
  120. const T1& v1,
  121. const T2& v2) {
  122. if (pred(v1, v2)) return AssertionSuccess();
  123. Message msg;
  124. msg << pred_text << "("
  125. << e1 << ", "
  126. << e2 << ") evaluates to false, where"
  127. << "\n" << e1 << " evaluates to " << v1
  128. << "\n" << e2 << " evaluates to " << v2;
  129. return AssertionFailure(msg);
  130. }
  131. // Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT2.
  132. // Don't use this in your code.
  133. #define GTEST_PRED_FORMAT2_(pred_format, v1, v2, on_failure)\
  134. GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2),\
  135. on_failure)
  136. // Internal macro for implementing {EXPECT|ASSERT}_PRED2. Don't use
  137. // this in your code.
  138. #define GTEST_PRED2_(pred, v1, v2, on_failure)\
  139. GTEST_ASSERT_(::testing::AssertPred2Helper(#pred, \
  140. #v1, \
  141. #v2, \
  142. pred, \
  143. v1, \
  144. v2), on_failure)
  145. // Binary predicate assertion macros.
  146. #define EXPECT_PRED_FORMAT2(pred_format, v1, v2) \
  147. GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_)
  148. #define EXPECT_PRED2(pred, v1, v2) \
  149. GTEST_PRED2_(pred, v1, v2, GTEST_NONFATAL_FAILURE_)
  150. #define ASSERT_PRED_FORMAT2(pred_format, v1, v2) \
  151. GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_FATAL_FAILURE_)
  152. #define ASSERT_PRED2(pred, v1, v2) \
  153. GTEST_PRED2_(pred, v1, v2, GTEST_FATAL_FAILURE_)
  154. // Helper function for implementing {EXPECT|ASSERT}_PRED3. Don't use
  155. // this in your code.
  156. template <typename Pred,
  157. typename T1,
  158. typename T2,
  159. typename T3>
  160. AssertionResult AssertPred3Helper(const char* pred_text,
  161. const char* e1,
  162. const char* e2,
  163. const char* e3,
  164. Pred pred,
  165. const T1& v1,
  166. const T2& v2,
  167. const T3& v3) {
  168. if (pred(v1, v2, v3)) return AssertionSuccess();
  169. Message msg;
  170. msg << pred_text << "("
  171. << e1 << ", "
  172. << e2 << ", "
  173. << e3 << ") evaluates to false, where"
  174. << "\n" << e1 << " evaluates to " << v1
  175. << "\n" << e2 << " evaluates to " << v2
  176. << "\n" << e3 << " evaluates to " << v3;
  177. return AssertionFailure(msg);
  178. }
  179. // Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT3.
  180. // Don't use this in your code.
  181. #define GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, on_failure)\
  182. GTEST_ASSERT_(pred_format(#v1, #v2, #v3, v1, v2, v3),\
  183. on_failure)
  184. // Internal macro for implementing {EXPECT|ASSERT}_PRED3. Don't use
  185. // this in your code.
  186. #define GTEST_PRED3_(pred, v1, v2, v3, on_failure)\
  187. GTEST_ASSERT_(::testing::AssertPred3Helper(#pred, \
  188. #v1, \
  189. #v2, \
  190. #v3, \
  191. pred, \
  192. v1, \
  193. v2, \
  194. v3), on_failure)
  195. // Ternary predicate assertion macros.
  196. #define EXPECT_PRED_FORMAT3(pred_format, v1, v2, v3) \
  197. GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_NONFATAL_FAILURE_)
  198. #define EXPECT_PRED3(pred, v1, v2, v3) \
  199. GTEST_PRED3_(pred, v1, v2, v3, GTEST_NONFATAL_FAILURE_)
  200. #define ASSERT_PRED_FORMAT3(pred_format, v1, v2, v3) \
  201. GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_FATAL_FAILURE_)
  202. #define ASSERT_PRED3(pred, v1, v2, v3) \
  203. GTEST_PRED3_(pred, v1, v2, v3, GTEST_FATAL_FAILURE_)
  204. // Helper function for implementing {EXPECT|ASSERT}_PRED4. Don't use
  205. // this in your code.
  206. template <typename Pred,
  207. typename T1,
  208. typename T2,
  209. typename T3,
  210. typename T4>
  211. AssertionResult AssertPred4Helper(const char* pred_text,
  212. const char* e1,
  213. const char* e2,
  214. const char* e3,
  215. const char* e4,
  216. Pred pred,
  217. const T1& v1,
  218. const T2& v2,
  219. const T3& v3,
  220. const T4& v4) {
  221. if (pred(v1, v2, v3, v4)) return AssertionSuccess();
  222. Message msg;
  223. msg << pred_text << "("
  224. << e1 << ", "
  225. << e2 << ", "
  226. << e3 << ", "
  227. << e4 << ") evaluates to false, where"
  228. << "\n" << e1 << " evaluates to " << v1
  229. << "\n" << e2 << " evaluates to " << v2
  230. << "\n" << e3 << " evaluates to " << v3
  231. << "\n" << e4 << " evaluates to " << v4;
  232. return AssertionFailure(msg);
  233. }
  234. // Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT4.
  235. // Don't use this in your code.
  236. #define GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, on_failure)\
  237. GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, v1, v2, v3, v4),\
  238. on_failure)
  239. // Internal macro for implementing {EXPECT|ASSERT}_PRED4. Don't use
  240. // this in your code.
  241. #define GTEST_PRED4_(pred, v1, v2, v3, v4, on_failure)\
  242. GTEST_ASSERT_(::testing::AssertPred4Helper(#pred, \
  243. #v1, \
  244. #v2, \
  245. #v3, \
  246. #v4, \
  247. pred, \
  248. v1, \
  249. v2, \
  250. v3, \
  251. v4), on_failure)
  252. // 4-ary predicate assertion macros.
  253. #define EXPECT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \
  254. GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_)
  255. #define EXPECT_PRED4(pred, v1, v2, v3, v4) \
  256. GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_)
  257. #define ASSERT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \
  258. GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_FATAL_FAILURE_)
  259. #define ASSERT_PRED4(pred, v1, v2, v3, v4) \
  260. GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_FATAL_FAILURE_)
  261. // Helper function for implementing {EXPECT|ASSERT}_PRED5. Don't use
  262. // this in your code.
  263. template <typename Pred,
  264. typename T1,
  265. typename T2,
  266. typename T3,
  267. typename T4,
  268. typename T5>
  269. AssertionResult AssertPred5Helper(const char* pred_text,
  270. const char* e1,
  271. const char* e2,
  272. const char* e3,
  273. const char* e4,
  274. const char* e5,
  275. Pred pred,
  276. const T1& v1,
  277. const T2& v2,
  278. const T3& v3,
  279. const T4& v4,
  280. const T5& v5) {
  281. if (pred(v1, v2, v3, v4, v5)) return AssertionSuccess();
  282. Message msg;
  283. msg << pred_text << "("
  284. << e1 << ", "
  285. << e2 << ", "
  286. << e3 << ", "
  287. << e4 << ", "
  288. << e5 << ") evaluates to false, where"
  289. << "\n" << e1 << " evaluates to " << v1
  290. << "\n" << e2 << " evaluates to " << v2
  291. << "\n" << e3 << " evaluates to " << v3
  292. << "\n" << e4 << " evaluates to " << v4
  293. << "\n" << e5 << " evaluates to " << v5;
  294. return AssertionFailure(msg);
  295. }
  296. // Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT5.
  297. // Don't use this in your code.
  298. #define GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, on_failure)\
  299. GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, #v5, v1, v2, v3, v4, v5),\
  300. on_failure)
  301. // Internal macro for implementing {EXPECT|ASSERT}_PRED5. Don't use
  302. // this in your code.
  303. #define GTEST_PRED5_(pred, v1, v2, v3, v4, v5, on_failure)\
  304. GTEST_ASSERT_(::testing::AssertPred5Helper(#pred, \
  305. #v1, \
  306. #v2, \
  307. #v3, \
  308. #v4, \
  309. #v5, \
  310. pred, \
  311. v1, \
  312. v2, \
  313. v3, \
  314. v4, \
  315. v5), on_failure)
  316. // 5-ary predicate assertion macros.
  317. #define EXPECT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \
  318. GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_)
  319. #define EXPECT_PRED5(pred, v1, v2, v3, v4, v5) \
  320. GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_)
  321. #define ASSERT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \
  322. GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_)
  323. #define ASSERT_PRED5(pred, v1, v2, v3, v4, v5) \
  324. GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_)
  325. #endif // GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_