iutest  1.17.1.0
iutest_matcher.hpp
[詳解]
1 //======================================================================
2 //-----------------------------------------------------------------------
13 //-----------------------------------------------------------------------
14 //======================================================================
15 #ifndef INCG_IRIS_IUTEST_MATCHER_HPP_23746E00_1A4B_4778_91AD_45C6DEFEEFA7_
16 #define INCG_IRIS_IUTEST_MATCHER_HPP_23746E00_1A4B_4778_91AD_45C6DEFEEFA7_
17 
18 #if IUTEST_HAS_MATCHERS
19 
20 //======================================================================
21 // define
26 #define IUTEST_TEST_THAT(actual, matcher, on_failure) \
27  IUTEST_AMBIGUOUS_ELSE_BLOCKER_ \
28  if( ::iutest::AssertionResult iutest_ar = matcher(actual) ) { \
29  } else \
30  on_failure(::iutest::detail::MatcherAssertionFailureMessage( \
31  ::iutest::PrintToString(actual).c_str(), #matcher, iutest_ar))
32 
37 namespace iutest {
38 namespace detail
39 {
40 
41 //======================================================================
42 // function
46 inline ::std::string MatcherAssertionFailureMessage(const char* actual, const char* matcher_str
47  , const AssertionResult& ar)
48 {
49  iu_global_format_stringstream strm;
50  strm << "error: Expected: " << matcher_str
51  << "\n Actual: " << actual
52  << "\nWhich is: " << ar.message();
53  return strm.str();
54 }
55 
56 //======================================================================
57 // class
58 
59 IUTEST_PRAGMA_ASSIGNMENT_OPERATOR_COULD_NOT_GENERATE_WARN_DISABLE_BEGIN()
60 
61 
64 class IMatcher
65 {
66  IMatcher& operator=(const IMatcher&);
67 public:
68  template<typename T>
69  struct is_matcher : public iutest_type_traits::is_base_of<IMatcher, T> {};
70 public:
71  IMatcher() {}
72  IMatcher(const IMatcher&) {}
73  virtual ~IMatcher() {}
74  virtual ::std::string WhichIs() const = 0;
75 };
76 
77 #if !defined(IUTEST_NO_SFINAE)
78 template<typename T>
79 inline typename detail::enable_if_t< IMatcher::is_matcher<T>, iu_ostream>::type& operator << (iu_ostream& os, const T& m)
80 {
81  return os << m.WhichIs();
82 }
83 #else
84 inline iu_ostream& operator << (iu_ostream& os, const IMatcher& m)
85 {
86  return os << m.WhichIs();
87 }
88 #endif
89 
95 #define IIUT_DECL_COMPARE_MATCHER(name, op) \
96  template<typename T>class IUTEST_PP_CAT(name, Matcher): public IMatcher{ \
97  public: explicit IUTEST_PP_CAT(name, Matcher)(const T& v) : m_expected(v) {}\
98  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE { \
99  iu_global_format_stringstream strm; \
100  strm << #name ": " << m_expected; return strm.str(); \
101  } \
102  template<typename U>AssertionResult operator ()(const U& actual) const { \
103  if( actual op m_expected ) return AssertionSuccess(); \
104  return AssertionFailure() << WhichIs(); \
105  } \
106  private: const T& m_expected; \
107  }
108 
109 #define IIUT_DECL_COMPARE_MATCHER2(name, op) \
110  class IUTEST_PP_CAT(Twofold, IUTEST_PP_CAT(name, Matcher)): public IMatcher{ \
111  public: ::std::string WhichIs() const IUTEST_CXX_OVERRIDE { return #name; } \
112  template<typename T, typename U>AssertionResult operator () \
113  (const T& actual, const U& expected) const { \
114  if( actual op expected ) return AssertionSuccess(); \
115  return AssertionFailure() << WhichIs() << ": " << actual << " vs " << expected; \
116  } \
117  }
118 
119 
120 IUTEST_PRAGMA_WARN_PUSH()
121 IUTEST_PRAGMA_WARN_DISABLE_SIGN_COMPARE()
122 
123 IIUT_DECL_COMPARE_MATCHER(Ne, !=);
124 IIUT_DECL_COMPARE_MATCHER(Le, <=);
125 IIUT_DECL_COMPARE_MATCHER(Lt, < );
126 IIUT_DECL_COMPARE_MATCHER(Ge, >=);
127 IIUT_DECL_COMPARE_MATCHER(Gt, > );
128 
129 IIUT_DECL_COMPARE_MATCHER2(Eq, ==);
130 IIUT_DECL_COMPARE_MATCHER2(Ne, !=);
131 IIUT_DECL_COMPARE_MATCHER2(Le, <=);
132 IIUT_DECL_COMPARE_MATCHER2(Lt, < );
133 IIUT_DECL_COMPARE_MATCHER2(Ge, >=);
134 IIUT_DECL_COMPARE_MATCHER2(Gt, > );
135 
136 IUTEST_PRAGMA_WARN_POP()
137 
138 #undef IIUT_DECL_COMPARE_MATCHER
139 #undef IIUT_DECL_COMPARE_MATCHER2
140 
141 #define IIUT_DECL_STR_COMPARE_MATCHER(name) \
142  template<typename T>class IUTEST_PP_CAT(name, Matcher): public IMatcher { \
143  public: IUTEST_PP_CAT(name, Matcher)(const T& value) : m_expected(value) {} \
144  template<typename U>AssertionResult operator ()(const U& actual) const { \
145  if( internal::IUTEST_PP_CAT(name, Helper)::Compare( \
146  actual, m_expected) ) { return AssertionSuccess(); } \
147  return AssertionFailure() << WhichIs(); \
148  } \
149  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE { \
150  iu_global_format_stringstream strm; strm << #name ": " << m_expected; \
151  return strm.str(); \
152  } \
153  private: \
154  const T& m_expected; \
155  }
156 
157 IIUT_DECL_STR_COMPARE_MATCHER(StrEq);
158 IIUT_DECL_STR_COMPARE_MATCHER(StrNe);
159 IIUT_DECL_STR_COMPARE_MATCHER(StrCaseEq);
160 IIUT_DECL_STR_COMPARE_MATCHER(StrCaseNe);
161 
162 #undef IIUT_DECL_COMPARE_MATCHER
163 
171 class IsNullMatcher : public IMatcher
172 {
173 public:
174  template<typename U>
175  AssertionResult operator ()(const U* actual) const
176  {
177  if( actual == NULL )
178  {
179  return AssertionSuccess();
180  }
181  return AssertionFailure() << WhichIs();
182  }
183  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
184  {
185  return "Is Null";
186  }
187 };
188 
192 class NotNullMatcher : public IMatcher
193 {
194 public:
195  template<typename U>
196  AssertionResult operator ()(const U* actual) const
197  {
198  if( actual != NULL )
199  {
200  return AssertionSuccess();
201  }
202  return AssertionFailure() << WhichIs();
203  }
204  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
205  {
206  return "Not Null";
207  }
208 };
209 
213 template<typename T>
214 class FloatingPointEqMatcher : public IMatcher
215 {
216 public:
217  explicit FloatingPointEqMatcher(const T& value) : m_expected(value) {}
218 
219 public:
220  template<typename U>
221  AssertionResult operator ()(const U& actual) const
222  {
223  floating_point<T> f2(actual);
224  if( m_expected.AlmostEquals(f2) )
225  {
226  return AssertionSuccess();
227  }
228  return AssertionFailure() << WhichIs();
229  }
230 
231  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
232  {
233  iu_global_format_stringstream strm;
234  strm << "Eq: " << PrintToString(m_expected);
235  return strm.str();
236  }
237 private:
238  floating_point<T> m_expected;
239 };
240 
244 template<typename T>
245 class NanSensitiveFloatingPointEqMatcher : public IMatcher
246 {
247 public:
248  explicit NanSensitiveFloatingPointEqMatcher(const T& value) : m_expected(value) {}
249 
250 public:
251  template<typename U>
252  AssertionResult operator ()(const U& actual) const
253  {
254  floating_point<T> f2(actual);
255  if( m_expected.NanSensitiveAlmostEquals(f2) )
256  {
257  return AssertionSuccess();
258  }
259  return AssertionFailure() << WhichIs();
260  }
261 
262  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
263  {
264  iu_global_format_stringstream strm;
265  strm << "NanSensitive Eq: " << PrintToString(m_expected);
266  return strm.str();
267  }
268 private:
269  floating_point<T> m_expected;
270 };
271 
275 template<typename T>
276 class FloatingPointNearMatcher : public IMatcher
277 {
278 public:
279  explicit FloatingPointNearMatcher(const T& value, const T& abs_error)
280  : m_expected(value), m_max_abs_error(abs_error) {}
281 
282 public:
283  template<typename U>
284  AssertionResult operator ()(const U& actual) const
285  {
286  floating_point<T> a(actual);
287  if( m_expected.AlmostNear(a, m_max_abs_error) )
288  {
289  return AssertionSuccess();
290  }
291  return AssertionFailure() << WhichIs();
292  }
293 
294  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
295  {
296  iu_global_format_stringstream strm;
297  strm << "Near: " << PrintToString(m_expected) << "(abs error <= " << m_max_abs_error << ")";
298  return strm.str();
299  }
300 private:
301  floating_point<T> m_expected;
302  T m_max_abs_error;
303 };
304 
308 template<typename T>
309 class NanSensitiveFloatingPointNearMatcher : public IMatcher
310 {
311 public:
312  explicit NanSensitiveFloatingPointNearMatcher(const T& value, const T& abs_error)
313  : m_expected(value), m_max_abs_error(abs_error) {}
314 
315 public:
316  template<typename U>
317  AssertionResult operator ()(const U& actual) const
318  {
319  floating_point<T> a(actual);
320  if( m_expected.NanSensitiveAlmostNear(a, m_max_abs_error) )
321  {
322  return AssertionSuccess();
323  }
324  return AssertionFailure() << WhichIs();
325  }
326 
327  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
328  {
329  iu_global_format_stringstream strm;
330  strm << "NanSensitive Near: " << PrintToString(m_expected) << "(abs error <= " << m_max_abs_error << ")";
331  return strm.str();
332  }
333 private:
334  floating_point<T> m_expected;
335  T m_max_abs_error;
336 };
337 
341 template<typename T>
342 class StartsWithMatcher : public IMatcher
343 {
344 public:
345  explicit StartsWithMatcher(T str) : m_expected(str) {}
346 
347 public:
348  template<typename U>
349  AssertionResult operator ()(const U& actual) const
350  {
351  if( StartsWith(actual, m_expected) )
352  {
353  return AssertionSuccess();
354  }
355  return AssertionFailure() << WhichIs();
356  }
357 
358 public:
359  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
360  {
361  iu_global_format_stringstream strm;
362  strm << "StartsWith: " << m_expected;
363  return strm.str();
364  }
365 private:
366  static bool StartsWith(const char* actual, const char* start)
367  {
368  return strstr(actual, start) == actual;
369  }
370  static bool StartsWith(const ::std::string& actual, const char* start)
371  {
372  const char* p = actual.c_str();
373  return StartsWith(p, start);
374  }
375  static bool StartsWith(const char* actual, const ::std::string& start)
376  {
377  const char* p = start.c_str();
378  return StartsWith(actual, p);
379  }
380  static bool StartsWith(const ::std::string& actual, const ::std::string& start)
381  {
382  const char* p = start.c_str();
383  return StartsWith(actual, p);
384  }
385 private:
386  T m_expected;
387 };
388 
392 template<typename T>
393 class HasSubstrMatcher : public IMatcher
394 {
395 public:
396  explicit HasSubstrMatcher(T expected) : m_expected(expected) {}
397 public:
398  template<typename U>
399  AssertionResult operator ()(const U& actual) const
400  {
401  if( HasSubstr(actual, m_expected) )
402  {
403  return AssertionSuccess();
404  }
405  return AssertionFailure() << WhichIs();
406  }
407 
408 public:
409  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
410  {
411  iu_global_format_stringstream strm;
412  strm << "HasSubstr: " << m_expected;
413  return strm.str();
414  }
415 private:
416  static bool HasSubstr(const char* actual, const char* expected)
417  {
418  return strstr(actual, expected) != NULL;
419  }
420  static bool HasSubstr(const ::std::string& actual, const char* expected)
421  {
422  const char* p = actual.c_str();
423  return HasSubstr(p, expected);
424  }
425  static bool HasSubstr(const char* actual, const ::std::string& expected)
426  {
427  const char* p = expected.c_str();
428  return HasSubstr(actual, p);
429  }
430  static bool HasSubstr(const ::std::string& actual, const ::std::string& expected)
431  {
432  const char* p = expected.c_str();
433  return HasSubstr(actual, p);
434  }
435 
436 private:
437  T m_expected;
438 };
439 
443 template<typename T>
444 class EndsWithMatcher : public IMatcher
445 {
446 public:
447  explicit EndsWithMatcher(T str) : m_expected(str) {}
448 
449 public:
450  template<typename U>
451  AssertionResult operator ()(const U& actual) const
452  {
453  if( EndsWith(actual, m_expected) )
454  {
455  return AssertionSuccess();
456  }
457  return AssertionFailure() << WhichIs();
458  }
459 
460 public:
461  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
462  {
463  iu_global_format_stringstream strm;
464  strm << "EndsWith: " << m_expected;
465  return strm.str();
466  }
467 private:
468  static bool EndsWith(const char* actual, const char* end)
469  {
470  const size_t len = strlen(end);
471  const size_t actual_len = strlen(actual);
472  if( len > actual_len )
473  {
474  return false;
475  }
476  const char* p = actual + actual_len - 1;
477  const char* q = end + len - 1;
478  for( size_t i=0; i < len; ++i, --p, --q )
479  {
480  if( *p != *q )
481  {
482  return false;
483  }
484  }
485  return true;
486  }
487  static bool EndsWith(const ::std::string& actual, const char* end)
488  {
489  const char* p = actual.c_str();
490  return EndsWith(p, end);
491  }
492  static bool EndsWith(const char* actual, const ::std::string& end)
493  {
494  const char* p = end.c_str();
495  return EndsWith(actual, p);
496  }
497  static bool EndsWith(const ::std::string& actual, const ::std::string& end)
498  {
499  const char* p = end.c_str();
500  return EndsWith(actual, p);
501  }
502 private:
503  T m_expected;
504 };
505 
509 template<typename T>
510 class EqMatcher : public IMatcher
511 {
512 public:
513  explicit EqMatcher(const T& expected) : m_expected(expected) {}
514 
515 public:
516  template<typename U>
517  AssertionResult operator ()(const U& actual) const
518  {
519  if( Equals(actual, m_expected) )
520  {
521  return AssertionSuccess();
522  }
523  return AssertionFailure() << WhichIs();
524  }
525 
526 public:
527  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
528  {
529  iu_global_format_stringstream strm;
530  strm << "Eq: " << m_expected;
531  return strm.str();
532  }
533 private:
534  template<typename A, typename B>
535  static bool Equals(const A& actual, const B& expected)
536  {
537 IUTEST_PRAGMA_WARN_PUSH()
538 IUTEST_PRAGMA_WARN_DISABLE_SIGN_COMPARE()
539  return actual == expected;
540 IUTEST_PRAGMA_WARN_POP()
541  }
542  static bool Equals(const char* actual, const char* expected)
543  {
544  return strcmp(actual, expected) == 0;
545  }
546  static bool Equals(const ::std::string& actual, const char* expected)
547  {
548  const char* p = actual.c_str();
549  return Equals(p, expected);
550  }
551  static bool Equals(const ::std::string& actual, const ::std::string& expected)
552  {
553  const char* p = expected.c_str();
554  return Equals(actual, p);
555  }
556 private:
557  const T& m_expected;
558 };
559 
563 template<typename T>
564 class TypedEqMatcher : public EqMatcher<T>
565 {
566 public:
567  explicit TypedEqMatcher(T expected) : EqMatcher<T>(m_expected), m_expected(expected) {}
568 public:
569  AssertionResult operator ()(const T& actual)
570  {
571  return EqMatcher<T>::operator ()(actual);
572  }
573  template<typename U>
574  AssertionResult operator ()(const U&) const;
575 
576 private:
577  T m_expected;
578 };
579 
583 #if !defined(IUTEST_NO_SFINAE)
584 
585 template<typename T>
586 T& CastToMatcher(T& matcher
587  , typename detail::enable_if_t< IMatcher::is_matcher<T> >::type*& = detail::enabler::value)
588 {
589  return matcher;
590 }
592 template<typename T>
593 EqMatcher<T> CastToMatcher(const T& value
594  , typename detail::disable_if_t< IMatcher::is_matcher<T> >::type*& = detail::enabler::value)
595 {
596  return EqMatcher<T>(value);
597 }
598 
599 #else
600 
601 template<typename T>
602 T& CastToMatcher(T& matcher)
603 {
604  return matcher;
605 }
606 
607 #endif
608 
609 
613 template<typename T>
614 class ContainsMatcher : public IMatcher
615 {
616 public:
617  explicit ContainsMatcher(const T& expected) : m_expected(expected) {}
618 
619 public:
620  template<typename U>
621  AssertionResult operator ()(const U& actual)
622  {
624  if( Contains(begin(actual), end(actual)) )
625  {
626  return AssertionSuccess();
627  }
628  return AssertionFailure() << WhichIs();
629  }
630 
631 public:
632  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
633  {
634  iu_global_format_stringstream strm;
635  strm << "Contains: " << m_expected;
636  return strm.str();
637  }
638 private:
639  template<typename Ite>
640  bool Contains(Ite begin, Ite end)
641  {
642  for( Ite it = begin; it != end; ++it )
643  {
644  if( CastToMatcher(m_expected)(*it) )
645  {
646  return true;
647  }
648  }
649  return false;
650  }
651 
652 private:
653  T m_expected;
654 };
655 
656 #if IUTEST_HAS_MATCHER_EACH
657 
661 template<typename T>
662 class EachMatcher : public IMatcher
663 {
664 public:
665  explicit EachMatcher(const T& expected) : m_expected(expected) {}
666 
667 public:
668  template<typename U>
669  AssertionResult operator ()(const U& actual)
670  {
672  if( Each(begin(actual), end(actual)) )
673  {
674  return AssertionSuccess();
675  }
676  return AssertionFailure() << WhichIs();
677  }
678 
679 public:
680  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
681  {
682  iu_global_format_stringstream strm;
683  strm << "Each: " << m_expected;
684  return strm.str();
685  }
686 private:
687  template<typename Ite>
688  bool Each(Ite begin, Ite end)
689  {
690  for( Ite it = begin; it != end; ++it )
691  {
692  if( !CastToMatcher(m_expected)(*it) )
693  {
694  return false;
695  }
696  }
697  return true;
698  }
699 
700 private:
701  T m_expected;
702 };
703 
704 #endif
705 
709 template<typename T>
710 class ContainerEqMatcher : public IMatcher
711 {
712 public:
713  explicit ContainerEqMatcher(const T& expected) : m_expected(expected) {}
714 
715 public:
716  template<typename U>
717  AssertionResult operator ()(const U& actual)
718  {
720  if( Check(begin(m_expected), end(m_expected)
721  , begin(actual), end(actual)) )
722  {
723  return AssertionSuccess();
724  }
725  return AssertionFailure() << WhichIs();
726  }
727 
728 public:
729  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
730  {
731  iu_global_format_stringstream strm;
732  strm << "ContainerEq: " << PrintToString(m_expected);
733  strm << " (" << m_whichIs << ")";
734  return strm.str();
735  }
736 private:
737  template<typename Ite1, typename Ite2>
738  bool Check(Ite1 b1, Ite1 e1, Ite2 b2, Ite2 e2)
739  {
740  size_t elem=0;
741  bool result = true;
742  Message ar;
743  for( elem=0; b1 != e1 && b2 != e2; ++b1, ++b2, ++elem )
744  {
745  if( !internal::backward::EqHelper<false>::Compare("", "", *b1, *b2) )
746  {
747  result = false;
748  ar << "\nMismatch in a position " << elem << ": "
749  << ::iutest::internal::FormatForComparisonFailureMessage(*b1, *b2)
750  << " vs " << ::iutest::internal::FormatForComparisonFailureMessage(*b2, *b1);
751  }
752  }
753  if( b1 != e1 || b2 != e2 )
754  {
755  const size_t elem1 = elem + ::std::distance(b1, e1);
756  const size_t elem2 = elem + ::std::distance(b2, e2);
757  result = false;
758  ar << "\nMismatch element : " << elem1 << " vs " << elem2;
759  }
760  m_whichIs = ar.GetString();
761  return result;
762  }
763 
764 private:
765  const T& m_expected;
766  ::std::string m_whichIs;
767 };
768 
769 
770 #if IUTEST_HAS_MATCHER_POINTWISE
771 
775 template<typename M, typename T>
776 class PointwiseMatcher : public IMatcher
777 {
778 public:
779  PointwiseMatcher(const M& matcher, const T& expected)
780  : m_matcher(matcher), m_expected(expected) {}
781 
782 public:
783  template<typename U>
784  AssertionResult operator ()(const U& actual)
785  {
787  if( Check(begin(m_expected), end(m_expected)
788  , begin(actual), end(actual)) )
789  {
790  return AssertionSuccess();
791  }
792  return AssertionFailure() << WhichIs();
793  }
794 
795 public:
796  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
797  {
798  iu_global_format_stringstream strm;
799  strm << "Pointwise: " << m_matcher << ": " << PrintToString(m_expected);
800  strm << " (" << m_whichIs << ")";
801  return strm.str();
802  }
803 private:
804  template<typename Ite1, typename Ite2>
805  bool Check(Ite1 b1, Ite1 e1, Ite2 b2, Ite2 e2)
806  {
807  size_t elem=0;
808  bool result = true;
809  Message ar;
810  for( elem=0; b1 != e1 && b2 != e2; ++b1, ++b2, ++elem )
811  {
812  const AssertionResult r = m_matcher(*b2, *b1);
813  if( r.failed() )
814  {
815  result = false;
816  ar << "\nMismatch in a position " << elem << ": " << r.message();
817  }
818  }
819  if( b1 != e1 || b2 != e2 )
820  {
821  const size_t elem1 = elem + ::std::distance(b1, e1);
822  const size_t elem2 = elem + ::std::distance(b2, e2);
823  result = false;
824  ar << "\nMismatch element : " << elem1 << " vs " << elem2;
825  }
826  m_whichIs = ar.GetString();
827  return result;
828  }
829 
830 private:
831  M m_matcher;
832  const T& m_expected;
833  ::std::string m_whichIs;
834 };
835 
836 #endif
837 
841 class IsEmptyMatcher : public IMatcher
842 {
843 public:
844  template<typename U>
845  AssertionResult operator ()(const U& actual)
846  {
847  if( (actual).empty() )
848  {
849  return AssertionSuccess();
850  }
851  return AssertionFailure() << WhichIs();
852  }
853 
854 public:
855  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
856  {
857  return "Is Empty";
858  }
859 };
860 
861 
865 template<typename T>
866 class SizeIsMatcher : public IMatcher
867 {
868 public:
869  explicit SizeIsMatcher(const T& expected) : m_expected(expected) {}
870 
871 public:
872  template<typename U>
873  AssertionResult operator ()(const U& actual)
874  {
875  if( Check(actual) )
876  {
877  return AssertionSuccess();
878  }
879  return AssertionFailure() << WhichIs();
880  }
881 
882 public:
883  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
884  {
885  iu_global_format_stringstream strm;
886  strm << "Size is: " << m_expected;
887  return strm.str();
888  }
889 private:
890  template<typename Container>
891  bool Check(const Container& actual)
892  {
893  return static_cast<bool>(CastToMatcher(m_expected)(actual.size()));
894  }
895 #if !defined(IUTEST_NO_FUNCTION_TEMPLATE_ORDERING)
896  template<typename U, size_t SIZE>
897  bool Check(const U(&)[SIZE])
898  {
899  return static_cast<bool>(CastToMatcher(m_expected)(SIZE));
900  }
901 #endif
902 
903 private:
904  T m_expected;
905 };
906 
910 template<typename T>
911 class AtMatcher : public IMatcher
912 {
913 public:
914  AtMatcher(size_t index, const T& expected) : m_index(index), m_expected(expected) {}
915 
916 public:
917  template<typename U>
918  AssertionResult operator ()(const U& actual)
919  {
920  if( CastToMatcher(m_expected)(actual[m_index]) )
921  {
922  return AssertionSuccess();
923  }
924  return AssertionFailure() << WhichIs();
925  }
926 
927 public:
928  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
929  {
930  iu_global_format_stringstream strm;
931  strm << "At " << m_index << ": " << m_expected;
932  return strm.str();
933  }
934 
935 private:
936  size_t m_index;
937  T m_expected;
938 };
939 
943 template<typename T>
944 class ElementsAreArrayMatcher : public IMatcher
945 {
946 public:
947  template<typename It>
948  ElementsAreArrayMatcher(It begin, It end, bool expected_elem_count=true)
949  : m_expected_elem_count(expected_elem_count)
950  {
951  m_expected.insert(m_expected.end(), begin, end);
952  }
953 
954 public:
955  template<typename U>
956  AssertionResult operator ()(const U& actual)
957  {
959  return Check(begin(actual), end(actual));
960  }
961 
962 public:
963  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
964  {
965  return WhichIs(PrintToString(m_expected));
966  }
967  ::std::string WhichIs(const ::std::string& msg) const
968  {
969  iu_global_format_stringstream strm;
970  if( m_expected_elem_count )
971  {
972  strm << "ElementsAreArray: ";
973  }
974  else
975  {
976  strm << "ElementsAreArrayForward: ";
977  }
978  strm << msg;
979  return strm.str();
980  }
981 private:
982  template<typename Ite>
983  AssertionResult Check(Ite actual_begin, Ite actual_end)
984  {
985  const size_t actual_cnt = ::std::distance(actual_begin, actual_end);
986  const size_t expected_cnt = m_expected.size();
987  if( actual_cnt < expected_cnt )
988  {
989  iu_global_format_stringstream stream;
990  stream << "actual argument[" << actual_cnt << "] is less than " << expected_cnt;
991  return AssertionFailure() << WhichIs(stream.str());
992  }
993  if( m_expected_elem_count && actual_cnt > expected_cnt )
994  {
995  iu_global_format_stringstream stream;
996  stream << "actual argument[" << actual_cnt << "] is greater than " << expected_cnt;
997  return AssertionFailure() << WhichIs(stream.str());
998  }
999 
1000  Ite it_a=actual_begin;
1001  typename ::std::vector<T>::iterator it_e=m_expected.begin();
1002  for( int i=0; it_a != actual_end && it_e != m_expected.end(); ++it_e, ++it_a, ++i )
1003  {
1004  (void)i;
1005  if( *it_a != *it_e )
1006  {
1007  return AssertionFailure() << WhichIs();
1008  }
1009  }
1010  return AssertionSuccess();
1011  }
1012 
1013 private:
1014  ::std::vector<T> m_expected;
1015  bool m_expected_elem_count;
1016 };
1017 
1018 #if IUTEST_HAS_MATCHER_ELEMENTSARE
1019 
1023 class ElementsAreMatcherBase : public IMatcher
1024 {
1025 protected:
1026  template<typename T, typename U>
1027  static AssertionResult Check(T& matchers, const U& actual)
1028  {
1030  return Check<0, tuples::tuple_size<T>::value - 1>(begin(actual), end(actual), matchers);
1031  }
1032  template<int N, typename T>
1033  static ::std::string WhichIs(const T& matchers)
1034  {
1035  ::std::string str = "ElementsAre: {";
1036  str += WhichIs_<T, N, tuples::tuple_size<T>::value-1>(matchers);
1037  str += "}";
1038  return str;
1039  }
1040 private:
1041  template<int N, int LAST, typename Ite, typename M>
1042  static AssertionResult Check(Ite it, Ite end, M& matchers)
1043  {
1044  const size_t cnt = ::std::distance(it, end);
1045  if( cnt < LAST+1 )
1046  {
1047  return AssertionFailure() << "ElementsAre: argument[" << cnt << "] is less than " << LAST+1;
1048  }
1049  return CheckElem<N, LAST>(it, end, matchers);
1050  }
1051 
1052  template<int N, int LAST, typename Ite, typename M>
1053  static AssertionResult CheckElem(Ite it, Ite end, M& matchers
1054  , typename detail::enable_if<N == LAST, void>::type*& = detail::enabler::value)
1055  {
1056  for( int index=N; it != end; ++it, ++index )
1057  {
1058  AssertionResult ar = CastToMatcher(tuples::get<N>(matchers))(*it);
1059  if( !ar )
1060  {
1061  return AssertionFailure() << WhichIsElem<N>(matchers, index);
1062  }
1063  }
1064  return AssertionSuccess();
1065  }
1066 
1067  template<int N, int LAST, typename Ite, typename M>
1068  static AssertionResult CheckElem(Ite it, Ite end, M& matchers
1069  , typename detail::disable_if<N == LAST, void>::type*& = detail::enabler::value)
1070  {
1071  AssertionResult ar = CastToMatcher(tuples::get<N>(matchers))(*it);
1072  if( ar )
1073  {
1074  return CheckElem<N + 1, LAST>(++it, end, matchers);
1075  }
1076  return AssertionFailure() << WhichIsElem<N>(matchers, N);
1077  }
1078 
1079  template<int N, typename T>
1080  static ::std::string WhichIsElem(const T& matchers, int index)
1081  {
1082  iu_global_format_stringstream strm;
1083  strm << "ElementsAre(" << index << "): " << tuples::get<N>(matchers);
1084  return strm.str();
1085  }
1086 
1087  template<typename T, int N, int LAST>
1088  static ::std::string WhichIs_(const T& matchers
1089  , typename detail::enable_if<N == LAST, void>::type*& = detail::enabler::value)
1090  {
1091  return StreamableToString(tuples::get<N>(matchers));
1092  }
1093  template<typename T, int N, int LAST>
1094  static ::std::string WhichIs_(const T& matchers
1095  , typename detail::disable_if<N == LAST, void>::type*& = detail::enabler::value)
1096  {
1097  return StreamableToString(tuples::get<N>(matchers)) + ", " + WhichIs_<T, N + 1, LAST>(matchers);
1098  }
1099 };
1100 
1101 #if IUTEST_HAS_MATCHER_VARIADIC
1102 
1106 template<typename ...T>
1107 class ElementsAreMatcher : public ElementsAreMatcherBase
1108 {
1109 public:
1110  explicit ElementsAreMatcher(T... t) : m_matchers(t...) {}
1111 
1112 public:
1113  template<typename U>
1114  AssertionResult operator ()(const U& actual)
1115  {
1116  return Check(m_matchers, actual);
1117  }
1118  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
1119  {
1120  return ElementsAreMatcherBase::WhichIs<0>(m_matchers);
1121  }
1122 
1123 private:
1124  tuples::tuple<T...> m_matchers;
1125 };
1126 
1127 #else
1128 
1129 /*
1130 template<typename T0, typename T1>
1131 class ElementsAreMatcher : public ElementsAreMatcherBase
1132 {
1133 public:
1134  ElementsAreMatcher(T0 m0, T1 m1) : m_matchers(m0, m1) {}
1135 
1136 public:
1137  template<typename U>
1138  AssertionResult operator ()(const U& actual)
1139  {
1140  return Check(m_matchers, actual);
1141  }
1142  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
1143  {
1144  return ElementsAreMatcherBase::WhichIs<0>(m_matchers);
1145  }
1146 private:
1147  tuples::tuple<T0, T1> m_matchers;
1148 };
1149 */
1150 
1151 #define IIUT_DECL_ELEMENTSARE_MATCHER(n) \
1152  template< IUTEST_PP_ENUM_PARAMS(n, typename T) > \
1153  class IUTEST_PP_CAT(ElementsAreMatcher, n) : public ElementsAreMatcherBase { \
1154  public: IUTEST_PP_CAT(ElementsAreMatcher, n)(IUTEST_PP_ENUM_BINARY_PARAMS(n, T, m)) \
1155  : m_matchers(IUTEST_PP_ENUM_PARAMS(n, m)) {} \
1156  template<typename U>AssertionResult operator ()(const U& actual) { \
1157  return Check(m_matchers, actual); } \
1158  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE { \
1159  return ElementsAreMatcherBase::WhichIs<0>(m_matchers); } \
1160  private: \
1161  tuples::tuple< IUTEST_PP_ENUM_PARAMS(n, T) > m_matchers; \
1162  }
1163 
1164 IIUT_DECL_ELEMENTSARE_MATCHER(1);
1165 IIUT_DECL_ELEMENTSARE_MATCHER(2);
1166 IIUT_DECL_ELEMENTSARE_MATCHER(3);
1167 IIUT_DECL_ELEMENTSARE_MATCHER(4);
1168 IIUT_DECL_ELEMENTSARE_MATCHER(5);
1169 IIUT_DECL_ELEMENTSARE_MATCHER(6);
1170 IIUT_DECL_ELEMENTSARE_MATCHER(7);
1171 IIUT_DECL_ELEMENTSARE_MATCHER(8);
1172 IIUT_DECL_ELEMENTSARE_MATCHER(9);
1173 IIUT_DECL_ELEMENTSARE_MATCHER(10);
1174 
1175 #undef IIUT_DECL_ELEMENTSARE_MATCHER
1176 
1177 #endif
1178 
1179 #endif
1180 
1184 template<typename F, typename T>
1185 class FieldMatcher : public IMatcher
1186 {
1187 public:
1188  FieldMatcher(const F& field, const T& expected) : m_field(field), m_expected(expected) {}
1189 
1190 public:
1191  template<typename U>
1192  AssertionResult operator ()(const U& actual)
1193  {
1194  if( Check(actual) )
1195  {
1196  return AssertionSuccess();
1197  }
1198  return AssertionFailure() << WhichIs();
1199  }
1200 
1201 public:
1202  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
1203  {
1204  iu_global_format_stringstream strm;
1205  strm << "Field: " << m_expected;
1206  //strm << "Field: (" << detail::GetTypeNameProxy<F>::GetTypeName() << ") " << m_expected;
1207  return strm.str();
1208  }
1209 private:
1210 #if !defined(IUTEST_NO_SFINAE)
1211  template<typename U>
1212  bool Check(const U& actual
1213  , typename detail::disable_if_t< detail::is_pointer<U> >::type*& = detail::enabler::value)
1214  {
1215  return static_cast<bool>(CastToMatcher(m_expected)(actual.*m_field));
1216  }
1217  template<typename U>
1218  bool Check(const U& actual
1219  , typename detail::enable_if_t< detail::is_pointer<U> >::type*& = detail::enabler::value)
1220  {
1221  return static_cast<bool>(CastToMatcher(m_expected)(actual->*m_field));
1222  }
1223 #else
1224  template<typename U>
1225  bool Check(const U& actual)
1226  {
1227  return static_cast<bool>(CastToMatcher(m_expected)(actual->*m_field));
1228  }
1229 #endif
1230 
1231 private:
1232  const F& m_field;
1233  T m_expected;
1234 };
1235 
1239 template<typename F, typename T>
1240 class PropertyMatcher : public IMatcher
1241 {
1242 public:
1243  PropertyMatcher(const F& prop, const T& expected) : m_property(prop), m_expected(expected) {}
1244 
1245 public:
1246  template<typename U>
1247  AssertionResult operator ()(const U& actual)
1248  {
1249  if( Check(actual) )
1250  {
1251  return AssertionSuccess();
1252  }
1253  return AssertionFailure() << WhichIs();
1254  }
1255 
1256 public:
1257  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
1258  {
1259  iu_global_format_stringstream strm;
1260  strm << "Property: " << m_expected;
1261  //strm << "Property: (" << detail::GetTypeNameProxy<F>::GetTypeName() << ") " << m_expected;
1262  return strm.str();
1263  }
1264 private:
1265 #if !defined(IUTEST_NO_SFINAE)
1266  template<typename U>
1267  bool Check(const U& actual
1268  , typename detail::disable_if_t< detail::is_pointer<U> >::type*& = detail::enabler::value)
1269  {
1270  return static_cast<bool>(CastToMatcher(m_expected)((actual.*m_property)()));
1271  }
1272  template<typename U>
1273  bool Check(const U& actual
1274  , typename detail::enable_if_t< detail::is_pointer<U> >::type*& = detail::enabler::value)
1275  {
1276  return static_cast<bool>(CastToMatcher(m_expected)((actual->*m_property)()));
1277  }
1278 #else
1279  template<typename U>
1280  bool Check(const U& actual)
1281  {
1282  return static_cast<bool>(CastToMatcher(m_expected)((actual->*m_property)()));
1283  }
1284 #endif
1285 
1286 private:
1287  const F& m_property;
1288  T m_expected;
1289 };
1290 
1294 template<typename T>
1295 class KeyMatcher : public IMatcher
1296 {
1297 public:
1298  explicit KeyMatcher(const T& expected) : m_expected(expected) {}
1299 
1300 public:
1301  template<typename U>
1302  AssertionResult operator ()(const U& actual) const
1303  {
1304  if( CastToMatcher(m_expected)(actual.first) )
1305  {
1306  return AssertionSuccess();
1307  }
1308  return AssertionFailure() << WhichIs();
1309  }
1310 
1311 public:
1312  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
1313  {
1314  iu_global_format_stringstream strm;
1315  strm << "Key: " << m_expected;
1316  return strm.str();
1317  }
1318 
1319 private:
1320  const T& m_expected;
1321 };
1322 
1326 template<typename T1, typename T2>
1327 class PairMatcher : public IMatcher
1328 {
1329 public:
1330  PairMatcher(const T1& m1, const T2& m2) : m_m1(m1), m_m2(m2) {}
1331 
1332 public:
1333  template<typename U>
1334  AssertionResult operator ()(const U& actual)
1335  {
1336  if( !CheckElem(actual.first, m_m1) )
1337  {
1338  return AssertionFailure() << WhichIs();
1339  }
1340  if( !CheckElem(actual.second, m_m2) )
1341  {
1342  return AssertionFailure() << WhichIs();
1343  }
1344  return AssertionSuccess();
1345  }
1346 
1347 public:
1348  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
1349  {
1350  iu_global_format_stringstream strm;
1351  strm << "Pair: (" << m_m1 << ", " << m_m2 << ")";
1352  return strm.str();
1353  }
1354 private:
1355  template<typename T, typename U>
1356  bool CheckElem(const T& actual, U& matcher)
1357  {
1358  return static_cast<bool>(CastToMatcher(matcher)(actual));
1359  }
1360 
1361 private:
1362  T1 m_m1;
1363  T2 m_m2;
1364 };
1365 
1369 template<typename F, typename T>
1370 class ResultOfMatcher : public IMatcher
1371 {
1372 public:
1373  ResultOfMatcher(F& func, const T& expected) : m_func(func), m_expected(expected) {}
1374 
1375 public:
1376  template<typename U>
1377  AssertionResult operator ()(const U& actual)
1378  {
1379  if( Check(actual) )
1380  {
1381  return AssertionSuccess();
1382  }
1383  return AssertionFailure() << WhichIs();
1384  }
1385 
1386 public:
1387  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
1388  {
1389  iu_global_format_stringstream strm;
1390  strm << "Result of: " << m_expected;
1391  //strm << "Result of " << detail::GetTypeNameProxy<F>::GetTypeName() << "(): " << m_expected;
1392  return strm.str();
1393  }
1394 private:
1395  template<typename U>
1396  bool Check(const U& actual)
1397  {
1398  return static_cast<bool>(CastToMatcher(m_expected)((*m_func)(actual)));
1399  }
1400 private:
1401  F& m_func;
1402  T m_expected;
1403 };
1404 
1408 template<typename T>
1409 class PointeeMatcher : public IMatcher
1410 {
1411 public:
1412  explicit PointeeMatcher(const T& expected) : m_expected(expected) {}
1413 
1414 public:
1415  template<typename U>
1416  AssertionResult operator ()(const U& actual)
1417  {
1418  if( Check(actual) )
1419  {
1420  return AssertionSuccess();
1421  }
1422  return AssertionFailure() << WhichIs();
1423  }
1424 
1425 public:
1426  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
1427  {
1428  iu_global_format_stringstream strm;
1429  strm << "Points To: " << m_expected;
1430  return strm.str();
1431  }
1432 private:
1433  template<typename U>
1434  bool Check(const U& actual)
1435  {
1436  return static_cast<bool>(CastToMatcher(m_expected)(*actual));
1437  }
1438 private:
1439  T m_expected;
1440 };
1441 
1445 template<typename T>
1446 class NotMatcher : public IMatcher
1447 {
1448 public:
1449  explicit NotMatcher(const T& unexpected) : m_unexpected(unexpected) {}
1450 
1451 public:
1452  template<typename U>
1453  AssertionResult operator ()(const U& actual)
1454  {
1455  if( !CastToMatcher(m_unexpected)(actual) )
1456  {
1457  return AssertionSuccess();
1458  }
1459  return AssertionFailure() << WhichIs();
1460  }
1461 
1462 public:
1463  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
1464  {
1465  iu_global_format_stringstream strm;
1466  strm << "Not: (" << m_unexpected << ")";
1467  return strm.str();
1468  }
1469 
1470 private:
1471  T m_unexpected;
1472 };
1473 
1477 template<typename T>
1478 class AnyMatcher : public IMatcher
1479 {
1480 public:
1481  AssertionResult operator ()(const T&) const
1482  {
1483  return AssertionSuccess();
1484  }
1485  template<typename U>
1486  AssertionResult operator ()(const U&) const;
1487 
1488 public:
1489  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
1490  {
1491  iu_global_format_stringstream strm;
1492  strm << "A: " << detail::GetTypeNameProxy<T>::GetTypeName();
1493  return strm.str();
1494  }
1495 };
1496 
1500 class AnythingMatcher : public IMatcher
1501 {
1502 public:
1503  AnythingMatcher() {}
1504 public:
1505  template<typename U>
1506  AssertionResult operator ()(const U&) const
1507  {
1508  return AssertionSuccess();
1509  }
1510 
1511 public:
1512  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
1513  {
1514  return "_";
1515  }
1516 };
1517 
1518 #if IUTEST_HAS_MATCHER_REGEX
1519 
1523 class RegexMatcher : public IMatcher
1524 {
1525 public:
1526  RegexMatcher(const detail::iuRegex& expected, bool full_match) : m_expected(expected), m_full_match(full_match) {}
1527 
1528 public:
1529  template<typename U>
1530  AssertionResult operator ()(const U& actual) const
1531  {
1532  if( Regex(actual) )
1533  {
1534  return AssertionSuccess();
1535  }
1536  return AssertionFailure() << WhichIs();
1537  }
1538 
1539 public:
1540  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
1541  {
1542  iu_global_format_stringstream strm;
1543  if( m_full_match )
1544  {
1545  strm << "MatchesRegex: " << m_expected.pattern();
1546  }
1547  else
1548  {
1549  strm << "ContainsRegex: " << m_expected.pattern();
1550  }
1551  return strm.str();
1552  }
1553 private:
1554  bool Regex(const char* actual) const
1555  {
1556  return m_full_match ? m_expected.FullMatch(actual)
1557  : m_expected.PartialMatch(actual);
1558  }
1559  bool Regex(const ::std::string& actual) const
1560  {
1561  return m_full_match ? m_expected.FullMatch(actual.c_str())
1562  : m_expected.PartialMatch(actual.c_str());
1563  }
1564 
1565 private:
1566  detail::iuRegex m_expected;
1567  bool m_full_match;
1568 };
1569 
1570 #endif
1571 
1572 #if IUTEST_HAS_MATCHER_ALLOF_AND_ANYOF
1573 
1577 class AllOfMatcherBase : public IMatcher
1578 {
1579 protected:
1580  template<typename T, typename U>
1581  static AssertionResult Check(T& matchers, const U& actual)
1582  {
1583  return Check_<T, U, 0, tuples::tuple_size<T>::value-1>(matchers, actual);
1584  }
1585  template<int N, typename T>
1586  static ::std::string WhichIs(const T& matchers)
1587  {
1588  return WhichIs_<T, N, tuples::tuple_size<T>::value-1>(matchers);
1589  }
1590 private:
1591  template<typename T, typename U, int N, int LAST>
1592  static AssertionResult Check_(T& matchers, const U& actual, typename detail::enable_if<N == LAST, void>::type*& = detail::enabler::value)
1593  {
1594  AssertionResult ar = tuples::get<N>(matchers)(actual);
1595  if( ar )
1596  {
1597  return ar;
1598  }
1599  return AssertionFailure() << WhichIs_<T, 0, N>(matchers);
1600  }
1601  template<typename T, typename U, int N, int LAST>
1602  static AssertionResult Check_(T& matchers, const U& actual, typename detail::disable_if<N == LAST, void>::type*& = detail::enabler::value)
1603  {
1604  AssertionResult ar = tuples::get<N>(matchers)(actual);
1605  if( ar )
1606  {
1607  return Check_<T, U, N + 1, LAST>(matchers, actual);
1608  }
1609  return AssertionFailure() << WhichIs_<T, 0, N>(matchers);
1610  }
1611 
1612  template<typename T, int N, int LAST>
1613  static ::std::string WhichIs_(const T& matchers, typename detail::enable_if<N == LAST, void>::type*& = detail::enabler::value)
1614  {
1615  return tuples::get<N>(matchers).WhichIs();
1616  }
1617  template<typename T, int N, int LAST>
1618  static ::std::string WhichIs_(const T& matchers, typename detail::disable_if<N == LAST, void>::type*& = detail::enabler::value)
1619  {
1620  return tuples::get<N>(matchers).WhichIs() + " and " + WhichIs_<T, N + 1, LAST>(matchers);
1621  }
1622 };
1623 
1624 #if IUTEST_HAS_MATCHER_VARIADIC
1625 
1629 template<typename ...T>
1630 class AllOfMatcher : public AllOfMatcherBase
1631 {
1632 public:
1633  explicit AllOfMatcher(T... t) : m_matchers(t...) {}
1634 
1635 public:
1636  template<typename U>
1637  AssertionResult operator ()(const U& actual)
1638  {
1639  return Check(m_matchers, actual);
1640  }
1641  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
1642  {
1643  return AllOfMatcherBase::WhichIs<0>(m_matchers);
1644  }
1645 
1646 private:
1647  tuples::tuple<T...> m_matchers;
1648 };
1649 
1650 #else
1651 
1652 /*
1653 template<typename T0, typename T1>
1654 class AllOfMatcher : public AllOfMatcherBase
1655 {
1656 public:
1657  AllOfMatcher(T0 m0, T1 m1) : m_matchers(m0, m1) {}
1658 
1659 public:
1660  template<typename U>
1661  AssertionResult operator ()(const U& actual)
1662  {
1663  return Check(m_matchers, actual);
1664  }
1665  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
1666  {
1667  return AllOfMatcherBase::WhichIs<0>(m_matchers);
1668  }
1669 private:
1670  tuples::tuple<T0, T1> m_matchers;
1671 };
1672 */
1673 
1674 #define IIUT_DECL_ALLOF_MATCHER(n) \
1675  template< IUTEST_PP_ENUM_PARAMS(n, typename T) > \
1676  class IUTEST_PP_CAT(AllOfMatcher, n) : public AllOfMatcherBase { \
1677  public: IUTEST_PP_CAT(AllOfMatcher, n)(IUTEST_PP_ENUM_BINARY_PARAMS(n, T, m)) \
1678  : m_matchers(IUTEST_PP_ENUM_PARAMS(n, m)) {} \
1679  template<typename U>AssertionResult operator ()(const U& actual) { \
1680  return Check(m_matchers, actual); } \
1681  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE { \
1682  return AllOfMatcherBase::WhichIs<0>(m_matchers); } \
1683  private: \
1684  tuples::tuple< IUTEST_PP_ENUM_PARAMS(n, T) > m_matchers; \
1685  }
1686 
1687 IIUT_DECL_ALLOF_MATCHER(2);
1688 IIUT_DECL_ALLOF_MATCHER(3);
1689 IIUT_DECL_ALLOF_MATCHER(4);
1690 IIUT_DECL_ALLOF_MATCHER(5);
1691 IIUT_DECL_ALLOF_MATCHER(6);
1692 IIUT_DECL_ALLOF_MATCHER(7);
1693 IIUT_DECL_ALLOF_MATCHER(8);
1694 IIUT_DECL_ALLOF_MATCHER(9);
1695 IIUT_DECL_ALLOF_MATCHER(10);
1696 
1697 #undef IIUT_DECL_ALLOF_MATCHER
1698 
1699 #endif
1700 
1704 class AnyOfMatcherBase : public IMatcher
1705 {
1706 protected:
1707  template<typename T, typename U>
1708  static AssertionResult Check(T& matchers, const U& actual)
1709  {
1710  return Check_<T, U, 0, tuples::tuple_size<T>::value-1>(matchers, actual);
1711  }
1712  template<int N, typename T>
1713  static ::std::string WhichIs(const T& matchers)
1714  {
1715  return WhichIs_<T, N, tuples::tuple_size<T>::value-1>(matchers);
1716  }
1717 private:
1718  template<typename T, typename U, int N, int LAST>
1719  static AssertionResult Check_(T& matchers, const U& actual, typename detail::enable_if<N == LAST, void>::type*& = detail::enabler::value)
1720  {
1721  AssertionResult ar = tuples::get<N>(matchers)(actual);
1722  if( ar )
1723  {
1724  return ar;
1725  }
1726  return AssertionFailure() << WhichIs_<T, 0, N>(matchers);
1727  }
1728  template<typename T, typename U, int N, int LAST>
1729  static AssertionResult Check_(T& matchers, const U& actual, typename detail::disable_if<N == LAST, void>::type*& = detail::enabler::value)
1730  {
1731  AssertionResult ar = tuples::get<N>(matchers)(actual);
1732  if( ar )
1733  {
1734  return ar;
1735  }
1736  return Check_<T, U, N + 1, LAST>(matchers, actual);
1737  }
1738 
1739  template<typename T, int N, int LAST>
1740  static ::std::string WhichIs_(const T& matchers, typename detail::enable_if<N == LAST, void>::type*& = detail::enabler::value)
1741  {
1742  return tuples::get<N>(matchers).WhichIs();
1743  }
1744  template<typename T, int N, int LAST>
1745  static ::std::string WhichIs_(const T& matchers, typename detail::disable_if<N == LAST, void>::type*& = detail::enabler::value)
1746  {
1747  return tuples::get<N>(matchers).WhichIs() + " or " + WhichIs_<T, N + 1, LAST>(matchers);
1748  }
1749 };
1750 
1751 #if IUTEST_HAS_MATCHER_VARIADIC
1752 
1756 template<typename ...T>
1757 class AnyOfMatcher : public AnyOfMatcherBase
1758 {
1759 public:
1760  explicit AnyOfMatcher(T... t) : m_matchers(t...) {}
1761 
1762 public:
1763  template<typename U>
1764  AssertionResult operator ()(const U& actual)
1765  {
1766  return Check(m_matchers, actual);
1767  }
1768  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
1769  {
1770  return AnyOfMatcherBase::WhichIs<0>(m_matchers);
1771  }
1772 
1773 private:
1774  tuples::tuple<T...> m_matchers;
1775 };
1776 
1777 #else
1778 
1779 /*
1780 template<typename T0, typename T1>
1781 class AnyOfMatcher : public AnyOfMatcherBase
1782 {
1783 public:
1784  AnyOfMatcher(T0 m0, T1 m1) : m_matchers(m0, m1) {}
1785 
1786 public:
1787  template<typename U>
1788  AssertionResult operator ()(const U& actual)
1789  {
1790  return Check(m_matchers, actual);
1791  }
1792  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE
1793  {
1794  return AnyOfMatcherBase::WhichIs<0>(m_matchers);
1795  }
1796 private:
1797  tuples::tuple<T0, T1> m_matchers;
1798 };
1799 */
1800 
1801 #define IIUT_DECL_ANYOF_MATCHER(n) \
1802  template< IUTEST_PP_ENUM_PARAMS(n, typename T) > \
1803  class IUTEST_PP_CAT(AnyOfMatcher, n) : public AnyOfMatcherBase { \
1804  public: IUTEST_PP_CAT(AnyOfMatcher, n)(IUTEST_PP_ENUM_BINARY_PARAMS(n, T, m)) \
1805  : m_matchers(IUTEST_PP_ENUM_PARAMS(n, m)) {} \
1806  template<typename U>AssertionResult operator ()(const U& actual) { \
1807  return Check(m_matchers, actual); } \
1808  ::std::string WhichIs() const IUTEST_CXX_OVERRIDE { \
1809  return AnyOfMatcherBase::WhichIs<0>(m_matchers); } \
1810  private: \
1811  tuples::tuple< IUTEST_PP_ENUM_PARAMS(n, T) > m_matchers; \
1812  }
1813 
1814 IIUT_DECL_ANYOF_MATCHER(2);
1815 IIUT_DECL_ANYOF_MATCHER(3);
1816 IIUT_DECL_ANYOF_MATCHER(4);
1817 IIUT_DECL_ANYOF_MATCHER(5);
1818 IIUT_DECL_ANYOF_MATCHER(6);
1819 IIUT_DECL_ANYOF_MATCHER(7);
1820 IIUT_DECL_ANYOF_MATCHER(8);
1821 IIUT_DECL_ANYOF_MATCHER(9);
1822 IIUT_DECL_ANYOF_MATCHER(10);
1823 
1824 #undef IIUT_DECL_ANYOF_MATCHER
1825 
1826 #endif
1827 
1828 #endif
1829 
1830 IUTEST_PRAGMA_ASSIGNMENT_OPERATOR_COULD_NOT_GENERATE_WARN_DISABLE_END()
1831 
1832 } // end of namespace detail
1833 
1837 namespace matchers
1839 
1850 template<typename T>
1851 detail::EqMatcher<T> Equals(const T& expected)
1853  return detail::EqMatcher<T>(expected);
1854 }
1855 
1860 template<typename T>
1861 detail::EqMatcher<T> Eq(const T& expected)
1863  return detail::EqMatcher<T>(expected);
1864 }
1865 
1870 template<typename T>
1871 detail::NeMatcher<T> Ne(const T& expected)
1873  return detail::NeMatcher<T>(expected);
1874 }
1875 
1880 template<typename T>
1881 detail::LeMatcher<T> Le(const T& expected)
1883  return detail::LeMatcher<T>(expected);
1884 }
1885 
1890 template<typename T>
1891 detail::LtMatcher<T> Lt(const T& expected)
1893  return detail::LtMatcher<T>(expected);
1894 }
1895 
1900 template<typename T>
1901 detail::GeMatcher<T> Ge(const T& expected)
1903  return detail::GeMatcher<T>(expected);
1904 }
1905 
1910 template<typename T>
1911 detail::GtMatcher<T> Gt(const T& expected)
1913  return detail::GtMatcher<T>(expected);
1914 }
1915 
1920 inline detail::TwofoldEqMatcher Eq()
1922  return detail::TwofoldEqMatcher();
1923 }
1924 
1929 inline detail::TwofoldNeMatcher Ne()
1931  return detail::TwofoldNeMatcher();
1932 }
1933 
1938 inline detail::TwofoldLeMatcher Le()
1940  return detail::TwofoldLeMatcher();
1941 }
1942 
1947 inline detail::TwofoldLtMatcher Lt()
1949  return detail::TwofoldLtMatcher();
1950 }
1951 
1956 inline detail::TwofoldGeMatcher Ge()
1958  return detail::TwofoldGeMatcher();
1959 }
1960 
1965 inline detail::TwofoldGtMatcher Gt()
1967  return detail::TwofoldGtMatcher();
1968 }
1969 
1974 inline detail::IsNullMatcher IsNull()
1976  return detail::IsNullMatcher();
1977 }
1978 
1983 inline detail::NotNullMatcher NotNull()
1985  return detail::NotNullMatcher();
1986 }
1987 
1992 template<typename T, typename U>
1993 detail::TypedEqMatcher<T> TypedEq(const U& expected)
1995  return detail::TypedEqMatcher<T>(static_cast<T>(expected));
1996 }
1997 
2002 template<typename T>
2003 inline detail::FloatingPointEqMatcher<T> FloatingPointEq(T expected)
2005  return detail::FloatingPointEqMatcher<T>(expected);
2006 }
2007 
2012 inline detail::FloatingPointEqMatcher<float> FloatEq(float expected)
2014  return detail::FloatingPointEqMatcher<float>(expected);
2015 }
2016 
2021 inline detail::FloatingPointEqMatcher<double> DoubleEq(double expected)
2023  return detail::FloatingPointEqMatcher<double>(expected);
2024 }
2025 
2026 #if IUTEST_HAS_LONG_DOUBLE
2027 
2032 inline detail::FloatingPointEqMatcher<long double> LongDoubleEq(long double expected)
2033 {
2034  return detail::FloatingPointEqMatcher<long double>(expected);
2035 }
2036 
2037 #endif
2038 
2043 template<typename T>
2044 inline detail::NanSensitiveFloatingPointEqMatcher<T> NanSensitiveFloatingPointEq(T expected)
2046  return detail::NanSensitiveFloatingPointEqMatcher<T>(expected);
2047 }
2048 
2053 inline detail::NanSensitiveFloatingPointEqMatcher<float> NanSensitiveFloatEq(float expected)
2055  return detail::NanSensitiveFloatingPointEqMatcher<float>(expected);
2056 }
2057 
2062 inline detail::NanSensitiveFloatingPointEqMatcher<double> NanSensitiveDoubleEq(double expected)
2064  return detail::NanSensitiveFloatingPointEqMatcher<double>(expected);
2065 }
2066 
2067 #if IUTEST_HAS_LONG_DOUBLE
2068 
2073 inline detail::NanSensitiveFloatingPointEqMatcher<long double> NanSensitiveLongDoubleEq(long double expected)
2074 {
2075  return detail::NanSensitiveFloatingPointEqMatcher<long double>(expected);
2076 }
2077 
2078 #endif
2079 
2080 #if IUTEST_HAS_MATCHER_FLOATINGPOINT_NEAR
2081 
2086 template<typename T>
2087 inline detail::FloatingPointNearMatcher<T> FloatingPointNear(T expected, T max_abs_error)
2089  return detail::FloatingPointNearMatcher<T>(expected, max_abs_error);
2090 }
2091 
2096 inline detail::FloatingPointNearMatcher<float> FloatNear(float expected, float max_abs_error)
2098  return detail::FloatingPointNearMatcher<float>(expected, max_abs_error);
2099 }
2100 
2105 inline detail::FloatingPointNearMatcher<double> DoubleNear(double expected, double max_abs_error)
2107  return detail::FloatingPointNearMatcher<double>(expected, max_abs_error);
2108 }
2109 
2110 #if IUTEST_HAS_LONG_DOUBLE
2111 
2116 inline detail::FloatingPointNearMatcher<long double> LongDoubleNear(long double expected, long double max_abs_error)
2117 {
2118  return detail::FloatingPointNearMatcher<long double>(expected, max_abs_error);
2119 }
2120 
2121 #endif
2122 
2127 template<typename T>
2128 inline detail::NanSensitiveFloatingPointNearMatcher<T> NanSensitiveFloatingPointNear(T expected, T max_abs_error)
2130  return detail::NanSensitiveFloatingPointNearMatcher<T>(expected, max_abs_error);
2131 }
2132 
2137 inline detail::NanSensitiveFloatingPointNearMatcher<float> NanSensitiveFloatNear(float expected, float max_abs_error)
2139  return detail::NanSensitiveFloatingPointNearMatcher<float>(expected, max_abs_error);
2140 }
2141 
2146 inline detail::NanSensitiveFloatingPointNearMatcher<double> NanSensitiveDoubleNear(double expected, double max_abs_error)
2148  return detail::NanSensitiveFloatingPointNearMatcher<double>(expected, max_abs_error);
2149 }
2150 
2151 #if IUTEST_HAS_LONG_DOUBLE
2152 
2157 inline detail::NanSensitiveFloatingPointNearMatcher<long double> NanSensitiveLongDoubleNear(long double expected, long double max_abs_error)
2158 {
2159  return detail::NanSensitiveFloatingPointNearMatcher<long double>(expected, max_abs_error);
2160 }
2161 
2162 #endif
2163 
2164 #endif
2165 
2170 template<typename T>
2171 detail::StrEqMatcher<T> StrEq(const T& expected)
2173  return detail::StrEqMatcher<T>(expected);
2174 }
2175 
2180 template<typename T>
2181 detail::StrNeMatcher<T> StrNe(const T& expected)
2183  return detail::StrNeMatcher<T>(expected);
2184 }
2185 
2190 template<typename T>
2191 detail::StrCaseEqMatcher<T> StrCaseEq(const T& expected)
2193  return detail::StrCaseEqMatcher<T>(expected);
2194 }
2195 
2200 template<typename T>
2201 detail::StrCaseNeMatcher<T> StrCaseNe(const T& expected)
2203  return detail::StrCaseNeMatcher<T>(expected);
2204 }
2205 
2210 template<typename T>
2211 detail::StartsWithMatcher<const T&> StartsWith(const T& str)
2213  return detail::StartsWithMatcher<const T&>(str);
2214 }
2215 
2220 template<typename T>
2221 detail::HasSubstrMatcher<const T&> HasSubstr(const T& str)
2223  return detail::HasSubstrMatcher<const T&>(str);
2224 }
2225 
2230 template<typename T>
2231 detail::EndsWithMatcher<const T&> EndsWith(const T& str)
2233  return detail::EndsWithMatcher<const T&>(str);
2234 }
2235 
2240 template<typename T>
2241 detail::ContainsMatcher<T> Contains(const T& expected)
2243  return detail::ContainsMatcher<T>(expected);
2244 }
2245 
2246 #if IUTEST_HAS_MATCHER_EACH
2247 
2252 template<typename T>
2253 detail::EachMatcher<T> Each(const T& expected)
2255  return detail::EachMatcher<T>(expected);
2256 }
2257 
2258 #endif
2259 
2264 template<typename T>
2265 detail::ContainerEqMatcher<T> ContainerEq(const T& expected)
2267  return detail::ContainerEqMatcher<T>(expected);
2268 }
2269 
2270 #if IUTEST_HAS_MATCHER_POINTWISE
2271 
2276 template<typename M, typename T>
2277 detail::PointwiseMatcher<M, T> Pointwise(const M& matcher, const T& expected)
2279  return detail::PointwiseMatcher<M, T>(matcher, expected);
2280 }
2281 
2282 #endif
2283 
2288 inline detail::IsEmptyMatcher IsEmpty()
2290  return detail::IsEmptyMatcher();
2291 }
2292 
2297 template<typename T>
2298 detail::SizeIsMatcher<T> SizeIs(const T& expected)
2300  return detail::SizeIsMatcher<T>(expected);
2301 }
2302 
2307 template<typename T>
2308 detail::AtMatcher<T> At(size_t index, const T& expected)
2310  return detail::AtMatcher<T>(index, expected);
2311 }
2312 
2317 template<typename Container>
2318 detail::ElementsAreArrayMatcher< typename Container::value_type > ElementsAreArray(const Container& container)
2321  return detail::ElementsAreArrayMatcher<typename Container::value_type>(container.begin(), container.end());
2322 }
2323 
2324 #if !defined(IUTEST_NO_FUNCTION_TEMPLATE_ORDERING)
2325 
2326 template<typename T, size_t SIZE>
2327 detail::ElementsAreArrayMatcher<T> ElementsAreArray(const T(&v)[SIZE])
2329  return detail::ElementsAreArrayMatcher<T>(v, v + SIZE);
2330 }
2331 
2332 #if !defined(IUTEST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
2333 
2334 template<typename Ite>
2335 detail::ElementsAreArrayMatcher< typename detail::IteratorTraits<Ite>::type > ElementsAreArray(Ite begin, Ite end)
2337  return detail::ElementsAreArrayMatcher< typename detail::IteratorTraits<Ite>::type >(begin, end);
2338 }
2339 #endif
2340 
2341 #if IUTEST_HAS_INITIALIZER_LIST
2342 
2343 template<typename T>
2344 detail::ElementsAreArrayMatcher<T> ElementsAreArray(::std::initializer_list<T> l)
2345 {
2346  return detail::ElementsAreArrayMatcher<T>(l.begin(), l.end());
2347 }
2348 #endif
2349 
2350 #endif
2351 
2356 template<typename T>
2357 detail::ElementsAreArrayMatcher<T> ElementsAreArray(const T* a, int count)
2359  return detail::ElementsAreArrayMatcher<T>(a, a + count);
2360 }
2361 
2362 #if IUTEST_HAS_MATCHER_ELEMENTSAREARRAYFORWARD
2363 
2368 template<typename Container>
2369 detail::ElementsAreArrayMatcher< typename Container::value_type > ElementsAreArrayForward(const Container& container)
2371  return detail::ElementsAreArrayMatcher<typename Container::value_type>(container.begin(), container.end(), false);
2372 }
2373 
2374 #if !defined(IUTEST_NO_FUNCTION_TEMPLATE_ORDERING)
2375 
2376 template<typename T, size_t SIZE>
2377 detail::ElementsAreArrayMatcher<T> ElementsAreArrayForward(const T(&v)[SIZE])
2379  return detail::ElementsAreArrayMatcher<T>(v, v + SIZE, false);
2380 }
2381 
2382 #if !defined(IUTEST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
2383 
2384 template<typename Ite>
2385 detail::ElementsAreArrayMatcher< typename detail::IteratorTraits<Ite>::type > ElementsAreArrayForward(Ite begin, Ite end)
2387  return detail::ElementsAreArrayMatcher< typename detail::IteratorTraits<Ite>::type >(begin, end, false);
2388 }
2389 #endif
2390 
2391 #if IUTEST_HAS_INITIALIZER_LIST
2392 
2393 template<typename T>
2394 detail::ElementsAreArrayMatcher<T> ElementsAreArrayForward(::std::initializer_list<T> l)
2395 {
2396  return detail::ElementsAreArrayMatcher<T>(l.begin(), l.end(), false);
2397 }
2398 #endif
2399 
2400 #endif
2401 
2406 template<typename T>
2407 detail::ElementsAreArrayMatcher<T> ElementsAreArrayForward(const T* a, int count)
2409  return detail::ElementsAreArrayMatcher<T>(a, a + count, false);
2410 }
2411 
2412 #endif
2413 
2414 #if IUTEST_HAS_MATCHER_ELEMENTSARE
2415 
2416 #if IUTEST_HAS_MATCHER_VARIADIC
2417 
2421 template<typename ...T>
2422 detail::ElementsAreMatcher<T...> ElementsAre(const T&... m)
2424  return detail::ElementsAreMatcher<T...>(m...);
2425 }
2426 
2427 #else
2428 
2429 #define IIUT_ELEMENTSARE_MATCHER_NAME(n) IUTEST_PP_CAT(ElementsAreMatcher, n)
2430 #define IIUT_DECL_ELEMENTSARE(n) \
2431  template< IUTEST_PP_ENUM_PARAMS(n, typename T) > \
2432  detail:: IIUT_ELEMENTSARE_MATCHER_NAME(n)< IUTEST_PP_ENUM_PARAMS(n, T) > \
2433  ElementsAre( IUTEST_PP_ENUM_BINARY_PARAMS(n, const T, &m) ) { return \
2434  detail:: IIUT_ELEMENTSARE_MATCHER_NAME(n)< IUTEST_PP_ENUM_PARAMS(n, T) > \
2435  ( IUTEST_PP_ENUM_PARAMS(n, m) ); }
2436 
2437 
2438 IIUT_DECL_ELEMENTSARE(1)
2439 IIUT_DECL_ELEMENTSARE(2)
2440 IIUT_DECL_ELEMENTSARE(3)
2441 IIUT_DECL_ELEMENTSARE(4)
2442 IIUT_DECL_ELEMENTSARE(5)
2443 IIUT_DECL_ELEMENTSARE(6)
2444 IIUT_DECL_ELEMENTSARE(7)
2445 IIUT_DECL_ELEMENTSARE(8)
2446 IIUT_DECL_ELEMENTSARE(9)
2447 IIUT_DECL_ELEMENTSARE(10)
2448 
2449 #undef IIUT_ELEMENTSARE_MATCHER_NAME
2450 #undef IIUT_DECL_ELEMENTSARE
2451 #endif
2452 
2453 #endif
2454 
2459 template<typename T>
2460 detail::KeyMatcher<T> Key(const T& expected)
2462  return detail::KeyMatcher<T>(expected);
2463 }
2464 
2469 template<typename T1, typename T2>
2470 detail::PairMatcher<T1, T2> Pair(const T1& m1, const T2& m2)
2472  return detail::PairMatcher<T1, T2>(m1, m2);
2473 }
2474 
2479 template<typename F, typename T>
2480 detail::FieldMatcher<F, T> Field(const F& field, const T& expected)
2482  return detail::FieldMatcher<F, T>(field, expected);
2483 }
2484 
2489 template<typename P, typename T>
2490 detail::PropertyMatcher<P, T> Property(const P& prop, const T& expected)
2492  return detail::PropertyMatcher<P, T>(prop, expected);
2493 }
2494 
2499 template<typename F, typename T>
2500 detail::ResultOfMatcher<F, T> ResultOf(const F& func, const T& expected)
2502  return detail::ResultOfMatcher<F, T>(func, expected);
2503 }
2504 
2508 template<typename T>
2509 detail::PointeeMatcher<T> Pointee(const T& expected)
2511  return detail::PointeeMatcher<T>(expected);
2512 }
2513 
2517 template<typename T>
2518 detail::NotMatcher<T> Not(const T& unexpected)
2520  return detail::NotMatcher<T>(unexpected);
2521 }
2522 
2526 template<typename T>
2527 detail::AnyMatcher<T> A()
2529  return detail::AnyMatcher<T>();
2530 }
2531 
2532 
2536 const detail::AnythingMatcher _;
2538 #if IUTEST_HAS_MATCHER_REGEX
2539 
2543 inline detail::RegexMatcher MatchesRegex(const ::std::string& str)
2544 {
2545  return detail::RegexMatcher(detail::iuRegex(str), true);
2546 }
2547 
2551 inline detail::RegexMatcher ContainsRegex(const ::std::string& str)
2552 {
2553  return detail::RegexMatcher(detail::iuRegex(str), false);
2554 }
2555 
2556 #endif
2557 
2558 #if IUTEST_HAS_MATCHER_ALLOF_AND_ANYOF
2559 
2560 #if IUTEST_HAS_MATCHER_VARIADIC
2561 
2566 template<typename ...T>
2567 detail::AllOfMatcher<T...> AllOf(const T&... m)
2569  return detail::AllOfMatcher<T...>(m...);
2570 }
2571 
2576 template<typename ...T>
2577 detail::AnyOfMatcher<T...> AnyOf(const T&... m)
2579  return detail::AnyOfMatcher<T...>(m...);
2580 }
2581 
2582 #else
2583 
2584 #define IIUT_ANYOF_AND_ALLOF_MATCHER_NAME(name, n) IUTEST_PP_CAT( IUTEST_PP_CAT(name, Matcher), n)
2585 #define IIUT_DECL_ANYOF_AND_ALLOF(name, n) \
2586  template< IUTEST_PP_ENUM_PARAMS(n, typename T) > \
2587  detail:: IIUT_ANYOF_AND_ALLOF_MATCHER_NAME(name, n)< IUTEST_PP_ENUM_PARAMS(n, T) > \
2588  name( IUTEST_PP_ENUM_BINARY_PARAMS(n, const T, &m) ) { return \
2589  detail:: IIUT_ANYOF_AND_ALLOF_MATCHER_NAME(name, n)< IUTEST_PP_ENUM_PARAMS(n, T) > \
2590  ( IUTEST_PP_ENUM_PARAMS(n, m) ); }
2591 
2592 
2593 IIUT_DECL_ANYOF_AND_ALLOF(AllOf, 2)
2594 IIUT_DECL_ANYOF_AND_ALLOF(AllOf, 3)
2595 IIUT_DECL_ANYOF_AND_ALLOF(AllOf, 4)
2596 IIUT_DECL_ANYOF_AND_ALLOF(AllOf, 5)
2597 IIUT_DECL_ANYOF_AND_ALLOF(AllOf, 6)
2598 IIUT_DECL_ANYOF_AND_ALLOF(AllOf, 7)
2599 IIUT_DECL_ANYOF_AND_ALLOF(AllOf, 8)
2600 IIUT_DECL_ANYOF_AND_ALLOF(AllOf, 9)
2601 IIUT_DECL_ANYOF_AND_ALLOF(AllOf, 10)
2602 
2603 IIUT_DECL_ANYOF_AND_ALLOF(AnyOf, 2)
2604 IIUT_DECL_ANYOF_AND_ALLOF(AnyOf, 3)
2605 IIUT_DECL_ANYOF_AND_ALLOF(AnyOf, 4)
2606 IIUT_DECL_ANYOF_AND_ALLOF(AnyOf, 5)
2607 IIUT_DECL_ANYOF_AND_ALLOF(AnyOf, 6)
2608 IIUT_DECL_ANYOF_AND_ALLOF(AnyOf, 7)
2609 IIUT_DECL_ANYOF_AND_ALLOF(AnyOf, 8)
2610 IIUT_DECL_ANYOF_AND_ALLOF(AnyOf, 9)
2611 IIUT_DECL_ANYOF_AND_ALLOF(AnyOf, 10)
2612 
2613 #undef IIUT_ANYOF_AND_ALLOF_MATCHER_NAME
2614 #undef IIUT_DECL_ANYOF_AND_ALLOF
2615 
2616 #endif
2617 
2618 #endif
2619 
2623 template<typename T, typename M>
2624 bool Value(const T& value, const M& expected)
2626  return static_cast<bool>(detail::CastToMatcher(expected)(value));
2627 }
2628 
2633 } // end of namespace matchers
2634 
2635 using namespace matchers; // NOLINT
2636 
2637 } // end of namespace iutest
2638 
2639 #endif // IUTEST_HAS_MATCHERS
2640 
2641 #endif // INCG_IRIS_IUTEST_MATCHER_HPP_23746E00_1A4B_4778_91AD_45C6DEFEEFA7_
iutest::matchers::ContainerEq
detail::ContainerEqMatcher< T > ContainerEq(const T &expected)
Make ContainerEq matcher
Definition: iutest_matcher.hpp:2266
iutest::matchers::IsEmpty
detail::IsEmptyMatcher IsEmpty()
Make IsEmpty matcher
Definition: iutest_matcher.hpp:2289
iutest::matchers::TypedEq
detail::TypedEqMatcher< T > TypedEq(const U &expected)
Make TypedEq matcher
Definition: iutest_matcher.hpp:1994
iutest::matchers::StartsWith
detail::StartsWithMatcher< const T & > StartsWith(const T &str)
Make StartsWith matcher
Definition: iutest_matcher.hpp:2212
iutest::matchers::ElementsAreArrayForward
detail::ElementsAreArrayMatcher< T > ElementsAreArrayForward(const T *a, int count)
Make ElementsAreArrayForward matcher
Definition: iutest_matcher.hpp:2408
iutest::matchers::Lt
detail::TwofoldLtMatcher Lt()
Make Twofold Lt matcher
Definition: iutest_matcher.hpp:1948
iutest::matchers::NanSensitiveDoubleEq
detail::NanSensitiveFloatingPointEqMatcher< double > NanSensitiveDoubleEq(double expected)
Make NanSensitive Double Eq matcher
Definition: iutest_matcher.hpp:2063
iutest::matchers::StrNe
detail::StrNeMatcher< T > StrNe(const T &expected)
Make StrNe matcher
Definition: iutest_matcher.hpp:2182
iutest::matchers::At
detail::AtMatcher< T > At(size_t index, const T &expected)
Make At matcher
Definition: iutest_matcher.hpp:2309
iutest_config.hpp
iris unit test config
iutest::matchers::A
detail::AnyMatcher< T > A()
Make Any matcher
Definition: iutest_matcher.hpp:2528
iutest::matchers::FloatEq
detail::FloatingPointEqMatcher< float > FloatEq(float expected)
Make Float Eq matcher
Definition: iutest_matcher.hpp:2013
iutest::PrintToString
std::string PrintToString(const T &v)
文字列化
Definition: iutest_printers.hpp:678
iutest::matchers::ResultOf
detail::ResultOfMatcher< F, T > ResultOf(const F &func, const T &expected)
Make ResultOf matcher
Definition: iutest_matcher.hpp:2501
iutest::matchers::FloatingPointNear
detail::FloatingPointNearMatcher< T > FloatingPointNear(T expected, T max_abs_error)
Make FloatingPoint Near matcher
Definition: iutest_matcher.hpp:2088
iutest
iutest root namespace
Definition: iutest_charcode.hpp:31
iutest::Message
detail::iuStreamMessage Message
Message クラス
Definition: iutest_assertion.hpp:31
iutest::matchers::DoubleNear
detail::FloatingPointNearMatcher< double > DoubleNear(double expected, double max_abs_error)
Make Double Near matcher
Definition: iutest_matcher.hpp:2106
iutest::matchers::Not
detail::NotMatcher< T > Not(const T &unexpected)
Make Not matcher
Definition: iutest_matcher.hpp:2519
iutest::matchers::NanSensitiveFloatEq
detail::NanSensitiveFloatingPointEqMatcher< float > NanSensitiveFloatEq(float expected)
Make NanSensitive Float Eq matcher
Definition: iutest_matcher.hpp:2054
iutest::matchers::Key
detail::KeyMatcher< T > Key(const T &expected)
Make Key matcher
Definition: iutest_matcher.hpp:2461
iutest::matchers::NotNull
detail::NotNullMatcher NotNull()
Make NotNull matcher
Definition: iutest_matcher.hpp:1984
iutest::matchers::Eq
detail::TwofoldEqMatcher Eq()
Make Twofold Eq matcher
Definition: iutest_matcher.hpp:1921
iutest::matchers::Value
bool Value(const T &value, const M &expected)
Value predicate
Definition: iutest_matcher.hpp:2625
IUTEST_CXX_OVERRIDE
#define IUTEST_CXX_OVERRIDE
override definition
Definition: iutest_compiler.hpp:670
iutest::matchers::SizeIs
detail::SizeIsMatcher< T > SizeIs(const T &expected)
Make SizeIs matcher
Definition: iutest_matcher.hpp:2299
iutest::matchers::Equals
detail::EqMatcher< T > Equals(const T &expected)
Make Equals matcher
Definition: iutest_matcher.hpp:1852
iutest::matchers::AnyOf
detail::AnyOfMatcher< T... > AnyOf(const T &... m)
Make AnyOf matcher
Definition: iutest_matcher.hpp:2578
iutest::matchers::Contains
detail::ContainsMatcher< T > Contains(const T &expected)
Make Contains matcher
Definition: iutest_matcher.hpp:2242
iutest::matchers::Property
detail::PropertyMatcher< P, T > Property(const P &prop, const T &expected)
Make Property matcher
Definition: iutest_matcher.hpp:2491
iutest::matchers::EndsWith
detail::EndsWithMatcher< const T & > EndsWith(const T &str)
Make EndsWith matcher
Definition: iutest_matcher.hpp:2232
iutest::matchers::HasSubstr
detail::HasSubstrMatcher< const T & > HasSubstr(const T &str)
Make HasSubstr matcher
Definition: iutest_matcher.hpp:2222
iutest::matchers::_
const detail::AnythingMatcher _
Anything matcher
Definition: iutest_matcher.hpp:2537
iutest::matchers::DoubleEq
detail::FloatingPointEqMatcher< double > DoubleEq(double expected)
Make Double Eq matcher
Definition: iutest_matcher.hpp:2022
iutest::matchers::AllOf
detail::AllOfMatcher< T... > AllOf(const T &... m)
Make AllOf matcher
Definition: iutest_matcher.hpp:2568
iutest::matchers::Ne
detail::TwofoldNeMatcher Ne()
Make Twofold Ne matcher
Definition: iutest_matcher.hpp:1930
iutest::matchers::Field
detail::FieldMatcher< F, T > Field(const F &field, const T &expected)
Make Field matcher
Definition: iutest_matcher.hpp:2481
iutest::matchers::Pointwise
detail::PointwiseMatcher< M, T > Pointwise(const M &matcher, const T &expected)
Make Pointwise matcher
Definition: iutest_matcher.hpp:2278
iutest::matchers::ElementsAre
detail::ElementsAreMatcher< T... > ElementsAre(const T &... m)
Make ElementsAre matcher
Definition: iutest_matcher.hpp:2423
IUTEST_USING_BEGIN_END
#define IUTEST_USING_BEGIN_END()
using begin,end
Definition: iutest_stdlib.hpp:581
iutest::matchers::StrCaseEq
detail::StrCaseEqMatcher< T > StrCaseEq(const T &expected)
Make StrCaseEq matcher
Definition: iutest_matcher.hpp:2192
iutest::matchers::Le
detail::TwofoldLeMatcher Le()
Make Twofold Le matcher
Definition: iutest_matcher.hpp:1939
iutest::matchers::StrEq
detail::StrEqMatcher< T > StrEq(const T &expected)
Make StrEq matcher
Definition: iutest_matcher.hpp:2172
iutest::AssertionFailure
AssertionResult AssertionFailure()
テスト失敗を示す AssertionResult オブジェクトの取得
Definition: iutest_assertion.hpp:386
iutest::matchers::Pair
detail::PairMatcher< T1, T2 > Pair(const T1 &m1, const T2 &m2)
Make Pair matcher
Definition: iutest_matcher.hpp:2471
iutest::matchers::NanSensitiveFloatingPointNear
detail::NanSensitiveFloatingPointNearMatcher< T > NanSensitiveFloatingPointNear(T expected, T max_abs_error)
Make FloatingPoint Near matcher
Definition: iutest_matcher.hpp:2129
iutest::matchers::Each
detail::EachMatcher< T > Each(const T &expected)
Make Each matcher
Definition: iutest_matcher.hpp:2254
iutest::matchers::NanSensitiveDoubleNear
detail::NanSensitiveFloatingPointNearMatcher< double > NanSensitiveDoubleNear(double expected, double max_abs_error)
Make NanSensitive Double Near matcher
Definition: iutest_matcher.hpp:2147
iutest::matchers::IsNull
detail::IsNullMatcher IsNull()
Make IsNull matcher
Definition: iutest_matcher.hpp:1975
iutest::matchers::Pointee
detail::PointeeMatcher< T > Pointee(const T &expected)
Make Pointee matcher
Definition: iutest_matcher.hpp:2510
iutest::matchers::NanSensitiveFloatNear
detail::NanSensitiveFloatingPointNearMatcher< float > NanSensitiveFloatNear(float expected, float max_abs_error)
Make NanSensitive Float Near matcher
Definition: iutest_matcher.hpp:2138
iutest::matchers::Ge
detail::TwofoldGeMatcher Ge()
Make Twofold Ge matcher
Definition: iutest_matcher.hpp:1957
iutest::matchers::Gt
detail::TwofoldGtMatcher Gt()
Make Twofold Gt matcher
Definition: iutest_matcher.hpp:1966
iutest::matchers::FloatNear
detail::FloatingPointNearMatcher< float > FloatNear(float expected, float max_abs_error)
Make Float Near matcher
Definition: iutest_matcher.hpp:2097
iutest::AssertionSuccess
AssertionResult AssertionSuccess()
テスト成功を示す AssertionResult オブジェクトの取得
Definition: iutest_assertion.hpp:382
iutest::matchers::FloatingPointEq
detail::FloatingPointEqMatcher< T > FloatingPointEq(T expected)
Make FloatingPoint Eq matcher
Definition: iutest_matcher.hpp:2004
iutest::matchers::StrCaseNe
detail::StrCaseNeMatcher< T > StrCaseNe(const T &expected)
Make StrCaseNe matcher
Definition: iutest_matcher.hpp:2202
iutest::matchers::ElementsAreArray
detail::ElementsAreArrayMatcher< T > ElementsAreArray(const T *a, int count)
Make ElementsAreArray matcher
Definition: iutest_matcher.hpp:2358
iutest::matchers::NanSensitiveFloatingPointEq
detail::NanSensitiveFloatingPointEqMatcher< T > NanSensitiveFloatingPointEq(T expected)
Make FloatingPoint Eq matcher
Definition: iutest_matcher.hpp:2045