Commit a23d720c by Marcin Kowalczyk Committed by Copybara-Service

Cosmetic reformatting in a test.

PiperOrigin-RevId: 492219541
Change-Id: Iee5d7941e413c8b960365e60fa0254536dd20e49
parent 296abbd3
......@@ -95,7 +95,6 @@ cc_test(
deps = [
":int128",
"//absl/base",
"//absl/base:core_headers",
"//absl/hash:hash_testing",
"//absl/meta:type_traits",
"@com_google_googletest//:gtest_main",
......
......@@ -70,7 +70,6 @@ absl_cc_test(
DEPS
absl::int128
absl::base
absl::core_headers
absl::hash_testing
absl::type_traits
GTest::gmock_main
......
......@@ -76,16 +76,6 @@ std::string StreamFormatToString(std::ios_base::fmtflags flags,
return msg.str();
}
void CheckUint128Case(const Uint128TestCase& test_case) {
std::ostringstream os;
os.flags(test_case.flags);
os.width(test_case.width);
os.fill(kFill);
os << test_case.value;
SCOPED_TRACE(StreamFormatToString(test_case.flags, test_case.width));
EXPECT_EQ(test_case.expected, os.str());
}
constexpr std::ios::fmtflags kDec = std::ios::dec;
constexpr std::ios::fmtflags kOct = std::ios::oct;
constexpr std::ios::fmtflags kHex = std::ios::hex;
......@@ -96,6 +86,16 @@ constexpr std::ios::fmtflags kUpper = std::ios::uppercase;
constexpr std::ios::fmtflags kBase = std::ios::showbase;
constexpr std::ios::fmtflags kPos = std::ios::showpos;
void CheckUint128Case(const Uint128TestCase& test_case) {
std::ostringstream os;
os.flags(test_case.flags);
os.width(test_case.width);
os.fill(kFill);
os << test_case.value;
SCOPED_TRACE(StreamFormatToString(test_case.flags, test_case.width));
EXPECT_EQ(os.str(), test_case.expected);
}
TEST(Uint128, OStreamValueTest) {
CheckUint128Case({1, kDec, /*width = */ 0, "1"});
CheckUint128Case({1, kOct, /*width = */ 0, "1"});
......@@ -161,7 +161,7 @@ void CheckInt128Case(const Int128TestCase& test_case) {
os.fill(kFill);
os << test_case.value;
SCOPED_TRACE(StreamFormatToString(test_case.flags, test_case.width));
EXPECT_EQ(test_case.expected, os.str());
EXPECT_EQ(os.str(), test_case.expected);
}
TEST(Int128, OStreamValueTest) {
......@@ -194,35 +194,33 @@ TEST(Int128, OStreamValueTest) {
{absl::MakeInt128(1, 0), kHex, /*width = */ 0, "10000000000000000"});
CheckInt128Case({absl::MakeInt128(std::numeric_limits<int64_t>::max(),
std::numeric_limits<uint64_t>::max()),
std::ios::dec, /*width = */ 0,
kDec, /*width = */ 0,
"170141183460469231731687303715884105727"});
CheckInt128Case({absl::MakeInt128(std::numeric_limits<int64_t>::max(),
std::numeric_limits<uint64_t>::max()),
std::ios::oct, /*width = */ 0,
kOct, /*width = */ 0,
"1777777777777777777777777777777777777777777"});
CheckInt128Case({absl::MakeInt128(std::numeric_limits<int64_t>::max(),
std::numeric_limits<uint64_t>::max()),
std::ios::hex, /*width = */ 0,
"7fffffffffffffffffffffffffffffff"});
kHex, /*width = */ 0, "7fffffffffffffffffffffffffffffff"});
CheckInt128Case({absl::MakeInt128(std::numeric_limits<int64_t>::min(), 0),
std::ios::dec, /*width = */ 0,
kDec, /*width = */ 0,
"-170141183460469231731687303715884105728"});
CheckInt128Case({absl::MakeInt128(std::numeric_limits<int64_t>::min(), 0),
std::ios::oct, /*width = */ 0,
kOct, /*width = */ 0,
"2000000000000000000000000000000000000000000"});
CheckInt128Case({absl::MakeInt128(std::numeric_limits<int64_t>::min(), 0),
std::ios::hex, /*width = */ 0,
"80000000000000000000000000000000"});
CheckInt128Case({-1, std::ios::dec, /*width = */ 0, "-1"});
CheckInt128Case({-1, std::ios::oct, /*width = */ 0,
kHex, /*width = */ 0, "80000000000000000000000000000000"});
CheckInt128Case({-1, kDec, /*width = */ 0, "-1"});
CheckInt128Case({-1, kOct, /*width = */ 0,
"3777777777777777777777777777777777777777777"});
CheckInt128Case(
{-1, std::ios::hex, /*width = */ 0, "ffffffffffffffffffffffffffffffff"});
CheckInt128Case({-12345, std::ios::dec, /*width = */ 0, "-12345"});
CheckInt128Case({-12345, std::ios::oct, /*width = */ 0,
{-1, kHex, /*width = */ 0, "ffffffffffffffffffffffffffffffff"});
CheckInt128Case({-12345, kDec, /*width = */ 0, "-12345"});
CheckInt128Case({-12345, kOct, /*width = */ 0,
"3777777777777777777777777777777777777747707"});
CheckInt128Case({-12345, std::ios::hex, /*width = */ 0,
"ffffffffffffffffffffffffffffcfc7"});
CheckInt128Case(
{-12345, kHex, /*width = */ 0, "ffffffffffffffffffffffffffffcfc7"});
}
std::vector<Int128TestCase> GetInt128FormatCases();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment