summaryrefslogtreecommitdiffstats
path: root/googletest/include/gtest/gtest-printers.h
Commit message (Collapse)AuthorAgeFilesLines
* Fix double-promotion warnings in AppropriateResolution()Abseil Team2024-01-231-21/+28
| | | | | | | When -Wdouble-promotion is enabled, the templatized function AppropriateResolution fails to compile since its float instantiation promotes floats to doubles when doing arithmetic and comparisons. Add static casts to resolve these errors. PiperOrigin-RevId: 600776333 Change-Id: Ia530b4bbca6ddce27caf0a817196d87efef711cb
* Disable -Wfloat-equal in AppropriateResolution().Krzysztof Kosiński2024-01-091-0/+7
| | | | | | | This function makes exact floating point that are correct in this context, but trigger the compiler warning. PiperOrigin-RevId: 596944060 Change-Id: I4bba3c2abcf3ac189107530978961955ad47d6f0
* Use `absl::HasAbslStringify`, instead of the internal version.Abseil Team2023-09-211-5/+4
| | | | | PiperOrigin-RevId: 567349341 Change-Id: I35f2679901aecbe9cb90d2e78ff28c5e383e7257
* googletest: Add universal printer for `std::span`Dino Radakovic2023-08-251-2/+25
| | | | | | | Fixes #4318 PiperOrigin-RevId: 560089120 Change-Id: I9d0d098140033520266747a1689e953ee8307c47
* Make `AbslStringify` usage public in GoogleTestAbseil Team2023-07-211-0/+22
| | | | | | | Fixes #4314 PiperOrigin-RevId: 549986457 Change-Id: Iff74f02ab1c106696f288540e9c623d56b76e3f7
* Merge pull request #4308 from smr99:fix-float-castCopybara-Service2023-07-111-2/+2
|\ | | | | | | | | PiperOrigin-RevId: 547250378 Change-Id: I084c30e45f331cb296535822923da1cb7e848e11
| * Use template type FloatType in the cast.refs/pull/4308/headSteve Robbins2023-07-041-2/+2
| |
* | Update docstring of PrintWithFallback(..) to reflect the recently changed ↵Abseil Team2023-07-071-1/+1
|/ | | | | | | ordering. PiperOrigin-RevId: 546373360 Change-Id: I2538b45d8c7710592071cc352da6771480c324e6
* Fix C++20 compatibility bug.Mike Kruskal2023-07-011-3/+3
| | | | | | | | | This was shown to work for C++14, C++17, and C++20 after patched into googletest for the protobuf repo's CI. Closes #3659 PiperOrigin-RevId: 544795507 Change-Id: I3e0a94f675e78a6ee9aeccae86c23d940efed8eb
* Merge pull request #3993 from pgroke-dt:work-around-GCC-11-ADL-bugCopybara-Service2023-04-121-6/+7
|\ | | | | | | | | PiperOrigin-RevId: 523706897 Change-Id: If6dcc97c81a20f8fe675241518ae1d6cf23ebf39
| * work around GCC 6~11 ADL bugrefs/pull/3993/headPaul Groke2022-09-151-6/+7
| | | | | | | | | | | | | | see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51577 ADL seems to work properly when we do the SFINAE check via the return type, but not when using a dummy template parameter fix #3992
* | Merge pull request #4182 from venik:venik-char8-lib-fixCopybara-Service2023-03-171-1/+1
|\ \ | | | | | | | | | | | | PiperOrigin-RevId: 517470997 Change-Id: I12b079dc1536f136dd0514871fe79f9678b1fd6a
| * | __cpp_char8_t does not cover std::u8string implementation, but ↵refs/pull/4182/headAlexander Nikforov2023-03-071-1/+1
| | | | | | | | | | | | __cpp_lib_char8_t does
* | | Replace "#if GTEST_HAS_ABSL" with "#ifdef GTEST_HAS_ABSL"Tom Hughes2023-03-061-1/+1
|/ / | | | | | | | | | | | | This allows compilation with "-Wundef" (#3267). PiperOrigin-RevId: 513945230 Change-Id: I45ef19c7ff3d20e97216bd031d406a03365471da
* | Reorder printers list.Phoebe Liang2023-02-271-2/+3
| | | | | | | | | | PiperOrigin-RevId: 512708763 Change-Id: I1f24f2e1d17359aee5aa4cdf614c9357872ca03b
* | Fix -Wimplicit-int-float-conversion warningTom Hughes2023-01-171-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We're intentionally losing precision in this case, so add a cast. googletest/googletest/include/gtest/gtest-printers.h:532:9: error: implicit conversion from 'int32_t' (aka 'int') to 'float' may lose precision [-Werror,-Wimplicit-int-float-conversion] if (static_cast<int32_t>(val * mulfor6 + 0.5) / mulfor6 == val) return 6; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ googletest/googletest/include/gtest/gtest-printers.h:544:9: error: implicit conversion from 'int32_t' (aka 'int') to 'float' may lose precision [-Werror,-Wimplicit-int-float-conversion] if (static_cast<int32_t>(val / divfor6 + 0.5) * divfor6 == val) return 6; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ PiperOrigin-RevId: 502646042 Change-Id: I05989ee42675b531a9907616c9582a5a7c77bed6
* | IWYU: Add missing std includesTom Hughes2023-01-051-0/+1
| | | | | | | | | | PiperOrigin-RevId: 499893032 Change-Id: I33304802b7c82ae2d008f3ee89df38866e5f57ba
* | When printing floating-point numbers, print full precision by default.Abseil Team2022-11-161-0/+75
| | | | | | | | | | | | | | | | | | | | | | To make debug output readable, we still use the faster 6-digit precision sometimes, but only if it will round-trip. This way, when a test fails due to a very small difference in floating-point numbers, users will have enough digits to see the difference. PiperOrigin-RevId: 488958311 Change-Id: Ibcac43f48a97006d89217530c69386cc4fa2735c
* | Terse printing of std::reference_wrapper hides pointerAbseil Team2022-10-141-0/+7
|/ | | | | | | This matches the intention and documentation of terse printing which generally avoids printing the pointer. PiperOrigin-RevId: 481178950 Change-Id: I27039dac1870934d2d5b212e2cc7e97ab82c5b34
* Continuation for #3183refs/pull/3953/headYuriy Chernyshov2022-07-211-2/+2
| | | | Some of the #ifdefs were missed in original PR. Should be fixed now.
* Running clang-format over all of GoogleTestAbseil Team2022-03-151-20/+18
| | | | | | | | | | | | | | | | A few tests are examining code locations and looking af the resulting line numbers to verify that GoogleTest shows those to users correctly. Some of those locations change when clang-format is run. For those locations, I've wrapped portions in: // clang-format off ... // clang-format on There may be other locations that are currently not tickled by running clang-format. PiperOrigin-RevId: 434844712 Change-Id: I3a9f0a6f39eff741c576b6de389bef9b1d11139d
* Consistently apply IWYU pragmas across googletest and googlemock headersAbseil Team2022-01-181-1/+4
| | | | | PiperOrigin-RevId: 422559250 Change-Id: I9f630f2186724950e5e9fbd7093d5264e8bf0a71
* Googletest exportAbseil Team2021-11-091-0/+6
| | | | | | Add printer for std::type_info. PiperOrigin-RevId: 408375407
* Googletest exportAbseil Team2021-10-131-0/+6
| | | | | | Add printer for __{u,}int128_t. PiperOrigin-RevId: 402417369
* Googletest exportAbseil Team2021-09-301-0/+8
| | | | | googletest: Add printer for {std,absl}::nullopt. PiperOrigin-RevId: 399928554
* Googletest exportAbseil Team2021-07-221-2/+0
| | | | | | Delete GOOGLETEST_CM.* tags from C++ code. PiperOrigin-RevId: 386268534
* Merge pull request #3183 from georgthegreat:patch-1CJ Johnson2021-06-171-1/+1
|\ | | | | | | PiperOrigin-RevId: 378915968
| * Use proper feature test macro to test if library supports char8_trefs/pull/3183/headYuriy Chernyshov2020-12-241-1/+1
| | | | | | | | | | Reference is here: https://en.cppreference.com/w/cpp/feature_test This PR fixes the weird case of compiling with `clang++ -std=c++17 -fchar8_t`
* | #3420 Properly declare all overloads of testing::internal::PrintTo as DLL ↵Florin Crișan2021-06-031-3/+3
| | | | | | | | | | | | | | | | | | | | | | exports This was causing the following linker error on Microsoft Visual C++ when compiling as a DLL: ``` googletest-printers-test.cc.obj : error LNK2019: unresolved external symbol "void __cdecl testing::internal::PrintTo(char16_t const *,class std::basic_ostream<char,struct std::char_traits<char> > *)" (?PrintTo@internal@testing@@YAXPEB_SPEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z) referenced in function "public: static void __cdecl testing::internal::UniversalPrinter<char16_t const *>::Print(char16_t const * const &,class std::basic_ostream<char,struct std::char_traits<char> > *)" (?Print@?$UniversalPrinter@PEB_S@internal@testing@@SAXAEBQEB_SPEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z) googletest-printers-test.cc.obj : error LNK2019: unresolved external symbol "void __cdecl testing::internal::PrintTo(char32_t const *,class std::basic_ostream<char,struct std::char_traits<char> > *)" (?PrintTo@internal@testing@@YAXPEB_UPEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z) referenced in function "public: static void __cdecl testing::internal::UniversalPrinter<char32_t const *>::Print(char32_t const * const &,class std::basic_ostream<char,struct std::char_traits<char> > *)" (?Print@?$UniversalPrinter@PEB_U@internal@testing@@SAXAEBQEB_UPEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z) ```
* | Googletest exportAbseil Team2021-04-291-17/+0
| | | | | | | | | | | | Revert https://github.com/google/googletest/commit/ac3c2a8d0496893787015014a5abd397b766cce2 -- it seems to break some gcc users (#3384) PiperOrigin-RevId: 370834917
* | Googletest exportAbseil Team2021-03-221-15/+89
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Print std::u8string, std::u16string, and std::u32string as string literals Previously, these types were printed as "{ U+123, U+456, U+789 }". However, printed output in that form is difficult to compare against any literals that might be defined in code. Instead, just treat these types like std::string and std::wstring, escaping non-ASCII characters with a hexadecimal escape sequence. The tests have also been updated to cover the new functionality: as a bonus, the tests now also pass with the MSVC toolchain. Internally, the code has been reorganized to primarily operate in terms of char32_t, under the assumption that char32_t will always be at least as big as wchar_t. While that assumption is currently true, perhaps it won't be in the future... PiperOrigin-RevId: 364033132
* | Merge pull request #3184 from N-Dekker:PrintTo-type_index-overloadDino Radaković2021-03-091-0/+17
|\ \ | | | | | | | | | PiperOrigin-RevId: 361175466
| * | overload PrintTo for std::type_info and std::type_indexrefs/pull/3184/headNiels Dekker2021-02-251-0/+23
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Included the string returned by their `name()` member function with the output of `PrintTo`. Typical use case: std::unique_ptr<AbstractProduct> product = FactoryMethod(); // Assert that the product is of type X: ASSERT_EQ(std::type_index{typeid(*product)}, std::type_index{typeid(ProductX)}); Possible output in case of a test assert failure, now including the names of the compared type indices: > error: Expected equality of these values: > std::type_index(typeid(*product)) > Which is: 8-byte object <D0-65 54-8C F6-7F 00-00> ("class ProductY") > std::type_index(typeid(ProductX)) > Which is: 8-byte object <40-64 54-8C F6-7F 00-00> ("class ProductX") With help from Krystian Kuzniarek.
* | Googletest exportAbseil Team2021-02-181-3/+3
| | | | | | | | | | | | Make include guards conform with https://google.github.io/styleguide/cppguide.html#The__define_Guard, attempt #2 PiperOrigin-RevId: 357056902
* | Googletest exportAbseil Team2021-02-111-3/+3
| | | | | | | | | | | | Revert include guard fix PiperOrigin-RevId: 356588893
* | Googletest exportAbseil Team2021-02-111-0/+4
| | | | | | | | | | | | | | Fix #2987 Removing const before passing any types through UniversalPrinter. PiperOrigin-RevId: 356508875
* | Googletest exportAbseil Team2021-02-111-3/+3
| | | | | | | | | | | | Make include guards conform with https://google.github.io/styleguide/cppguide.html#The__define_Guard PiperOrigin-RevId: 355882793
* | Googletest exportAbseil Team2021-01-141-0/+39
| | | | | | | | | | | | | | | | Print unique_ptr/shared_ptr recursively. Given that they are smart pointers, it is unlikely that the inner object is invalid. PiperOrigin-RevId: 351586888
* | Googletest exportAbseil Team2021-01-141-1/+3
| | | | | | | | | | | | Fix Objective-C++ compatibility PiperOrigin-RevId: 350192165
* | Googletest exportAbseil Team2021-01-141-5/+12
|/ | | | | | Add support for printing incomplete types in the universal printer. PiperOrigin-RevId: 350154637
* Merge pull request #2714 from kuzkry:remove-repeated-includeAndy Getz2020-11-031-4/+0
|\ | | | | | | PiperOrigin-RevId: 340266002
| * remove a duplicated includerefs/pull/2714/headKrystian Kuzniarek2020-06-121-4/+0
| | | | | | | | | | | | Detection of string_view type (whether it's std or Abseil) is done in googletest/include/gtest/internal/gtest-port.h with GTEST_INTERNAL_HAS_STRING_VIEW.
* | Googletest exportAbseil Team2020-10-141-30/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Improve lookup of operator<< for user types Without this fix, trying to use this class with googletest struct Foo {}; template <typename OutputStream> OutputStream& operator<<(OutputStream& os, const Foo&) { os << "TemplatedStreamableInFoo"; return os; } results in an ambiguity error between the class' operator<< and the operator<< in gtest-printers.h removed in this CL. This fix also enables implicit conversions to happen, so that e.g. we will find the base class operator<< if a subclass has no operator<< of its own. PiperOrigin-RevId: 336261221
* | Merge pull request #2837 from inazarenko:duck_type_protosDerek Mauro2020-10-141-2/+3
|\ \ | | | | | | | | | PiperOrigin-RevId: 336087297
* | | Googletest exportdmauro2020-06-121-0/+20
| | | | | | | | | | | | | | | | | | Adds support for printing pointers of types char8_t, char16_t, and char32_t. PiperOrigin-RevId: 316112767
* | | Googletest exportdmauro2020-06-051-0/+26
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds support for printing the types char8_t, char16_t, and char32_t This changes prints these types as Unicode code points. It is possible that there is a better way of printing these types, but that change is more complex, and the format in which Googletest prints these types is subject to change if someone implements a better way of printing them. This fixes the C++20 build, which removed support for printing these types. https://en.cppreference.com/w/cpp/io/basic_ostream/operator_ltlt2 Fixes #2854 PiperOrigin-RevId: 314826912
* | Merge pull request #2742 from kuzkry:c++17-type-printersGennadiy Rozental2020-06-051-12/+48
|\ \ | |/ |/| | | PiperOrigin-RevId: 314593695
| * make UniversalPrinter<std::any> support RTTIrefs/pull/2742/headKrystian Kuzniarek2020-05-291-2/+9
| |
| * specialize UniversalPrinter<> for std::any (without support for RTTI)Krystian Kuzniarek2020-05-291-0/+20
| |
| * specialize UniversalPrinter<> for std::optionalKrystian Kuzniarek2020-05-291-6/+5
| |