diff options
author | Abseil Team <absl-team@google.com> | 2021-10-11 23:18:01 (GMT) |
---|---|---|
committer | Andy Soffer <asoffer@google.com> | 2021-10-13 16:28:20 (GMT) |
commit | 16f637fbf4ffc3f7a01fa4eceb7906634565242f (patch) | |
tree | bbef3ef26a7ec79187a4933c8034309c77fae028 /googletest/test | |
parent | 178cfacb24f8937ef7a585d9bcfffd967386306a (diff) | |
download | googletest-16f637fbf4ffc3f7a01fa4eceb7906634565242f.zip googletest-16f637fbf4ffc3f7a01fa4eceb7906634565242f.tar.gz googletest-16f637fbf4ffc3f7a01fa4eceb7906634565242f.tar.bz2 |
Googletest export
Add printer for __{u,}int128_t.
PiperOrigin-RevId: 402417369
Diffstat (limited to 'googletest/test')
-rw-r--r-- | googletest/test/googletest-printers-test.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/googletest/test/googletest-printers-test.cc b/googletest/test/googletest-printers-test.cc index 9c9a223..eb78eab 100644 --- a/googletest/test/googletest-printers-test.cc +++ b/googletest/test/googletest-printers-test.cc @@ -449,6 +449,24 @@ TEST(PrintBuiltInTypeTest, Size_t) { #endif // !GTEST_OS_WINDOWS } +// gcc/clang __{u,}int128_t values. +#if defined(__SIZEOF_INT128__) +TEST(PrintBuiltInTypeTest, Int128) { + // Small ones + EXPECT_EQ("0", Print(__int128_t{0})); + EXPECT_EQ("0", Print(__uint128_t{0})); + EXPECT_EQ("12345", Print(__int128_t{12345})); + EXPECT_EQ("12345", Print(__uint128_t{12345})); + EXPECT_EQ("-12345", Print(__int128_t{-12345})); + + // Large ones + EXPECT_EQ("340282366920938463463374607431768211455", Print(~__uint128_t{})); + __int128_t max_128 = static_cast<__int128_t>(~__uint128_t{} / 2); + EXPECT_EQ("-170141183460469231731687303715884105728", Print(~max_128)); + EXPECT_EQ("170141183460469231731687303715884105727", Print(max_128)); +} +#endif // __SIZEOF_INT128__ + // Floating-points. TEST(PrintBuiltInTypeTest, FloatingPoints) { EXPECT_EQ("1.5", Print(1.5f)); // float |