@@ -57,7 +57,7 @@ class msg : public decltype(Message()) {
57
57
std::string comp_{};
58
58
TLhs lhs_;
59
59
TRhs rhs_;
60
- bool result_{};
60
+ bool result_{false };
61
61
};
62
62
63
63
template <class TShouldError >
@@ -66,22 +66,10 @@ class op {
66
66
class comp : public decltype (Message()) {
67
67
public:
68
68
explicit comp (const info& info, const TLhs& lhs) : info_{info}, lhs_{lhs} {
69
- if (std::is_same<bool , TLhs>::value) {
70
- result_ = internal::CmpHelperEQ (" " , " " , lhs_, true );
71
- }
69
+ set_result (lhs_);
72
70
}
73
71
74
- ~comp () {
75
- if (TShouldError::value && !followed_ &&
76
- std::is_same<bool , TLhs>::value) {
77
- const AssertionResult gtest_ar =
78
- (internal::CmpHelperEQ (info_.expr .c_str (), " true" , lhs_, true ));
79
- if (!gtest_ar) {
80
- internal::AssertHelper (info_.failure , info_.file , info_.line ,
81
- gtest_ar.failure_message ()) = *this ;
82
- }
83
- }
84
- }
72
+ ~comp () { assert_error (lhs_); }
85
73
86
74
template <class TRhs ,
87
75
std::enable_if_t <std::is_floating_point<TLhs>::value ||
@@ -142,10 +130,31 @@ class op {
142
130
operator bool () const { return result_; }
143
131
144
132
private:
133
+ void set_result (const bool &) {
134
+ result_ = internal::CmpHelperEQ (" " , " " , lhs_, true );
135
+ }
136
+
137
+ template <class T >
138
+ void set_result (const T&) {}
139
+
140
+ void assert_error (const bool &) {
141
+ if (TShouldError::value && !followed_) {
142
+ const AssertionResult gtest_ar =
143
+ (internal::CmpHelperEQ (info_.expr .c_str (), " true" , lhs_, true ));
144
+ if (!gtest_ar) {
145
+ internal::AssertHelper (info_.failure , info_.file , info_.line ,
146
+ gtest_ar.failure_message ()) = *this ;
147
+ }
148
+ }
149
+ }
150
+
151
+ template <class T >
152
+ void assert_error (const T&) {}
153
+
145
154
info info_{};
146
155
TLhs lhs_{};
147
156
mutable bool followed_{false };
148
- bool result_{};
157
+ bool result_{false };
149
158
};
150
159
151
160
public:
0 commit comments