@@ -53,15 +53,26 @@ class msg : public decltype(Message()) {
5353
5454class op {
5555 template <class TLhs >
56- class comp {
56+ class comp : public decltype (Message()) {
5757 public:
5858 explicit comp (const info& info, const TLhs& lhs) : info_{info}, lhs_{lhs} {}
59+ ~comp () {
60+ if (!followed_ && std::is_same<bool , TLhs>::value) {
61+ const AssertionResult gtest_ar =
62+ (internal::CmpHelperEQ (info_.expr .c_str (), " true" , lhs_, true ));
63+ if (!gtest_ar) {
64+ internal::AssertHelper (info_.failure , info_.file , info_.line ,
65+ gtest_ar.failure_message ()) = *this ;
66+ }
67+ }
68+ }
5969
6070 template <class TRhs ,
6171 std::enable_if_t <std::is_floating_point<TLhs>::value ||
6272 std::is_floating_point<TRhs>::value,
6373 int > = 0 >
6474 auto operator ==(const TRhs& rhs) const {
75+ followed_ = true ;
6576 return msg<TLhs, TRhs, internal::CmpHelperFloatingPointEQ<TLhs>>{
6677 info_, " ==" , lhs_, rhs};
6778 }
@@ -71,43 +82,50 @@ class op {
7182 !std::is_floating_point<TRhs>::value,
7283 int > = 0 >
7384 auto operator ==(const TRhs& rhs) const {
85+ followed_ = true ;
7486 return msg<const TLhs&, const TRhs&, internal::CmpHelperEQ>{
7587 info_, " ==" , lhs_, rhs};
7688 }
7789
7890 template <class TRhs >
7991 auto operator !=(const TRhs& rhs) const {
92+ followed_ = true ;
8093 return msg<const TLhs&, const TRhs&, internal::CmpHelperNE>{
8194 info_, " !=" , lhs_, rhs};
8295 }
8396
8497 template <class TRhs >
8598 auto operator >(const TRhs& rhs) const {
99+ followed_ = true ;
86100 return msg<const TLhs&, const TRhs&, internal::CmpHelperGT>{info_, " >" ,
87101 lhs_, rhs};
88102 }
89103
90104 template <class TRhs >
91105 auto operator >=(const TRhs& rhs) const {
106+ followed_ = true ;
92107 return msg<const TLhs&, const TRhs&, internal::CmpHelperGE>{
93108 info_, " >=" , lhs_, rhs};
94109 }
95110
96111 template <class TRhs >
97112 auto operator <=(const TRhs& rhs) const {
113+ followed_ = true ;
98114 return msg<const TLhs&, const TRhs&, internal::CmpHelperLE>{
99115 info_, " <=" , lhs_, rhs};
100116 }
101117
102118 template <class TRhs >
103119 auto operator <(const TRhs& rhs) const {
120+ followed_ = true ;
104121 return msg<const TLhs&, const TRhs&, internal::CmpHelperLT>{info_, " <" ,
105122 lhs_, rhs};
106123 }
107124
108125 private:
109126 info info_{};
110127 TLhs lhs_{};
128+ mutable bool followed_{false };
111129 };
112130
113131 public:
0 commit comments