| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -56,6 +56,13 @@ | |||
| 56 | 56 | ||
| 57 | 57 | #include "gtest/internal/gtest-port.h" | |
| 58 | 58 | ||
| 59 | + #ifdef GTEST_HAS_ABSL | ||
| 60 | + #include <type_traits> | ||
| 61 | + | ||
| 62 | + #include "absl/strings/internal/has_absl_stringify.h" | ||
| 63 | + #include "absl/strings/str_cat.h" | ||
| 64 | + #endif // GTEST_HAS_ABSL | ||
| 65 | + | ||
| 59 | 66 | GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ | |
| 60 | 67 | /* class A needs to have dll-interface to be used by clients of class B */) | |
| 61 | 68 | ||
@@ -111,8 +118,17 @@ class GTEST_API_ Message { | |||
| 111 | 118 | *ss_ << str; | |
| 112 | 119 | } | |
| 113 | 120 | ||
| 114 | - // Streams a non-pointer value to this object. | ||
| 115 | - template <typename T> | ||
| 121 | + // Streams a non-pointer value to this object. If building a version of | ||
| 122 | + // GoogleTest with ABSL, this overload is only enabled if the value does not | ||
| 123 | + // have an AbslStringify definition. | ||
| 124 | + template <typename T | ||
| 125 | + #ifdef GTEST_HAS_ABSL | ||
| 126 | + , | ||
| 127 | + typename std::enable_if< | ||
| 128 | + !absl::strings_internal::HasAbslStringify<T>::value, // NOLINT | ||
| 129 | + int>::type = 0 | ||
| 130 | + #endif // GTEST_HAS_ABSL | ||
| 131 | + > | ||
| 116 | 132 | inline Message& operator<<(const T& val) { | |
| 117 | 133 | // Some libraries overload << for STL containers. These | |
| 118 | 134 | // overloads are defined in the global namespace instead of ::std. | |
@@ -133,6 +149,22 @@ class GTEST_API_ Message { | |||
| 133 | 149 | return *this; | |
| 134 | 150 | } | |
| 135 | 151 | ||
| 152 | + #ifdef GTEST_HAS_ABSL | ||
| 153 | + // Streams a non-pointer value with an AbslStringify definition to this | ||
| 154 | + // object. | ||
| 155 | + template <typename T, | ||
| 156 | + typename std::enable_if< | ||
| 157 | + absl::strings_internal::HasAbslStringify<T>::value, // NOLINT | ||
| 158 | + int>::type = 0> | ||
| 159 | + inline Message& operator<<(const T& val) { | ||
| 160 | + // ::operator<< is needed here for a similar reason as with the non-Abseil | ||
| 161 | + // version above | ||
| 162 | + using ::operator<<; | ||
| 163 | + *ss_ << absl::StrCat(val); | ||
| 164 | + return *this; | ||
| 165 | + } | ||
| 166 | + #endif // GTEST_HAS_ABSL | ||
| 167 | + | ||
| 136 | 168 | // Streams a pointer value to this object. | |
| 137 | 169 | // | |
| 138 | 170 | // This function is an overload of the previous one. When you | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -51,7 +51,6 @@ | |||
| 51 | 51 | ||
| 52 | 52 | #include <cstddef> | |
| 53 | 53 | #include <cstdint> | |
| 54 | - #include <iomanip> | ||
| 55 | 54 | #include <limits> | |
| 56 | 55 | #include <memory> | |
| 57 | 56 | #include <ostream> | |
@@ -1574,12 +1573,12 @@ AssertionResult CmpHelperFloatingPointEQ(const char* lhs_expression, | |||
| 1574 | 1573 | } | |
| 1575 | 1574 | ||
| 1576 | 1575 | ::std::stringstream lhs_ss; | |
| 1577 | - lhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2) | ||
| 1578 | - << lhs_value; | ||
| 1576 | + lhs_ss.precision(std::numeric_limits<RawType>::digits10 + 2); | ||
| 1577 | + lhs_ss << lhs_value; | ||
| 1579 | 1578 | ||
| 1580 | 1579 | ::std::stringstream rhs_ss; | |
| 1581 | - rhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2) | ||
| 1582 | - << rhs_value; | ||
| 1580 | + rhs_ss.precision(std::numeric_limits<RawType>::digits10 + 2); | ||
| 1581 | + rhs_ss << rhs_value; | ||
| 1583 | 1582 | ||
| 1584 | 1583 | return EqFailure(lhs_expression, rhs_expression, | |
| 1585 | 1584 | StringStreamToString(&lhs_ss), StringStreamToString(&rhs_ss), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -58,7 +58,6 @@ | |||
| 58 | 58 | ||
| 59 | 59 | #include <cstdint> | |
| 60 | 60 | #include <functional> | |
| 61 | - #include <iomanip> | ||
| 62 | 61 | #include <limits> | |
| 63 | 62 | #include <map> | |
| 64 | 63 | #include <set> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -220,7 +220,6 @@ | |||
| 220 | 220 | // GTEST_HAS_ALT_PATH_SEP_ - Always defined to 0 or 1. | |
| 221 | 221 | // GTEST_WIDE_STRING_USES_UTF16_ - Always defined to 0 or 1. | |
| 222 | 222 | // GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ - Always defined to 0 or 1. | |
| 223 | - // GTEST_HAS_DOWNCAST_ - Always defined to 0 or 1. | ||
| 224 | 223 | // GTEST_HAS_NOTIFICATION_- Always defined to 0 or 1. | |
| 225 | 224 | // | |
| 226 | 225 | // Synchronization: | |
@@ -313,10 +312,6 @@ | |||
| 313 | 312 | #include "gtest/internal/custom/gtest-port.h" | |
| 314 | 313 | #include "gtest/internal/gtest-port-arch.h" | |
| 315 | 314 | ||
| 316 | - #ifndef GTEST_HAS_DOWNCAST_ | ||
| 317 | - #define GTEST_HAS_DOWNCAST_ 0 | ||
| 318 | - #endif | ||
| 319 | - | ||
| 320 | 315 | #ifndef GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ | |
| 321 | 316 | #define GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ 0 | |
| 322 | 317 | #endif | |
@@ -1153,17 +1148,12 @@ inline To ImplicitCast_(To x) { | |||
| 1153 | 1148 | // check to enforce this. | |
| 1154 | 1149 | template <class Derived, class Base> | |
| 1155 | 1150 | Derived* CheckedDowncastToActualType(Base* base) { | |
| 1151 | + static_assert(std::is_base_of<Base, Derived>::value, | ||
| 1152 | + "target type not derived from source type"); | ||
| 1156 | 1153 | #if GTEST_HAS_RTTI | |
| 1157 | - GTEST_CHECK_(typeid(*base) == typeid(Derived)); | ||
| 1158 | - #endif | ||
| 1159 | - | ||
| 1160 | - #if GTEST_HAS_DOWNCAST_ | ||
| 1161 | - return ::down_cast<Derived*>(base); | ||
| 1162 | - #elif GTEST_HAS_RTTI | ||
| 1163 | - return dynamic_cast<Derived*>(base); // NOLINT | ||
| 1164 | - #else | ||
| 1165 | - return static_cast<Derived*>(base); // Poor man's downcast. | ||
| 1154 | + GTEST_CHECK_(base == nullptr || dynamic_cast<Derived*>(base) != nullptr); | ||
| 1166 | 1155 | #endif | |
| 1156 | + return static_cast<Derived*>(base); | ||
| 1167 | 1157 | } | |
| 1168 | 1158 | ||
| 1169 | 1159 | #if GTEST_HAS_STREAM_REDIRECTION | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -672,7 +672,7 @@ class GTEST_API_ UnitTestImpl { | |||
| 672 | 672 | void AddTestInfo(internal::SetUpTestSuiteFunc set_up_tc, | |
| 673 | 673 | internal::TearDownTestSuiteFunc tear_down_tc, | |
| 674 | 674 | TestInfo* test_info) { | |
| 675 | - #ifdef GTEST_HAS_FILE_SYSTEM | ||
| 675 | + #if GTEST_HAS_FILE_SYSTEM | ||
| 676 | 676 | // In order to support thread-safe death tests, we need to | |
| 677 | 677 | // remember the original working directory when the test program | |
| 678 | 678 | // was first invoked. We cannot do this in RUN_ALL_TESTS(), as | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,7 +15,7 @@ This a list of all the dependencies: | |||
| 15 | 15 | * [c-ares 1.19.0][] | |
| 16 | 16 | * [cjs-module-lexer 1.2.2][] | |
| 17 | 17 | * [corepack][] | |
| 18 | - * [googletest c875c4e][] | ||
| 18 | + * [googletest 7e33b6a][] | ||
| 19 | 19 | * [histogram 0.11.8][] | |
| 20 | 20 | * [icu-small 73.2][] | |
| 21 | 21 | * [libuv 1.46.0][] | |
@@ -189,7 +189,7 @@ In practical terms, Corepack will let you use Yarn and pnpm without having to | |||
| 189 | 189 | install them - just like what currently happens with npm, which is shipped | |
| 190 | 190 | by Node.js by default. | |
| 191 | 191 | ||
| 192 | - ### googletest c875c4e | ||
| 192 | + ### googletest 7e33b6a | ||
| 193 | 193 | ||
| 194 | 194 | The [googletest](https://github.com/google/googletest) dependency is Google’s | |
| 195 | 195 | C++ testing and mocking framework. | |
@@ -326,7 +326,7 @@ performance improvements not currently available in standard zlib. | |||
| 326 | 326 | [cjs-module-lexer 1.2.2]: #cjs-module-lexer-122 | |
| 327 | 327 | [corepack]: #corepack | |
| 328 | 328 | [dependency-update-action]: ../../../.github/workflows/tools.yml | |
| 329 | - [googletest c875c4e]: #googletest-c875c4e | ||
| 329 | + [googletest 7e33b6a]: #googletest-7e33b6a | ||
| 330 | 330 | [histogram 0.11.8]: #histogram-0118 | |
| 331 | 331 | [icu-small 73.2]: #icu-small-732 | |
| 332 | 332 | [libuv 1.46.0]: #libuv-1460 | |
| Back | FazBrowse Home | New Git URL |
0 commit comments