| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_TESTING_GMOCK_SUPPORT_H_ | 5 #ifndef V8_TESTING_GMOCK_SUPPORT_H_ |
| 6 #define V8_TESTING_GMOCK_SUPPORT_H_ | 6 #define V8_TESTING_GMOCK_SUPPORT_H_ |
| 7 | 7 |
| 8 #include <cmath> |
| 8 #include <cstring> | 9 #include <cstring> |
| 9 | 10 |
| 10 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
| 11 | 12 |
| 12 namespace testing { | 13 namespace testing { |
| 13 | 14 |
| 14 template <typename T> | 15 template <typename T> |
| 15 class Capture { | 16 class Capture { |
| 16 public: | 17 public: |
| 17 Capture() : value_(), has_value_(false) {} | 18 Capture() : value_(), has_value_(false) {} |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 } | 90 } |
| 90 | 91 |
| 91 | 92 |
| 92 // CaptureEq(capture) captures the value passed in during matching as long as it | 93 // CaptureEq(capture) captures the value passed in during matching as long as it |
| 93 // is unset, and once set, compares the value for equality with the argument. | 94 // is unset, and once set, compares the value for equality with the argument. |
| 94 template <typename T> | 95 template <typename T> |
| 95 inline Matcher<T> CaptureEq(Capture<T>* capture) { | 96 inline Matcher<T> CaptureEq(Capture<T>* capture) { |
| 96 return MakeMatcher(new internal::CaptureEqMatcher<T>(capture)); | 97 return MakeMatcher(new internal::CaptureEqMatcher<T>(capture)); |
| 97 } | 98 } |
| 98 | 99 |
| 100 |
| 101 // Creates a polymorphic matcher that matches any floating point NaN value. |
| 102 MATCHER(IsNaN, std::string(negation ? "isn't" : "is") + " not a number") { |
| 103 return std::isnan(arg); |
| 104 } |
| 105 |
| 99 } // namespace testing | 106 } // namespace testing |
| 100 | 107 |
| 101 #endif // V8_TESTING_GMOCK_SUPPORT_H_ | 108 #endif // V8_TESTING_GMOCK_SUPPORT_H_ |
| OLD | NEW |