Commit fc979660 authored by Nigel Tao's avatar Nigel Tao Committed by Commit Bot

clang-format string_number_conversions_unittest.cc

This will minimize the diff for a follow-up commit.

Change-Id: I79bfaf5913550acb9c579e3e2037012241c6639b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2310050
Commit-Queue: Nico Weber <thakis@chromium.org>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#790650}
parent 979cb165
......@@ -44,7 +44,8 @@ TEST(StringNumberConversionsTest, NumberToString) {
{0, "0", "0"},
{-1, "-1", "18446744073709551615"},
{
std::numeric_limits<int64_t>::max(), "9223372036854775807",
std::numeric_limits<int64_t>::max(),
"9223372036854775807",
"9223372036854775807",
},
{std::numeric_limits<int64_t>::min(), "-9223372036854775808",
......@@ -114,7 +115,9 @@ TEST(StringNumberConversionsTest, StringToInt) {
{"0", 0, true},
{"42", 42, true},
{"42\x99", 42, false},
{"\x99" "42\x99", 0, false},
{"\x99"
"42\x99",
0, false},
{"-2147483648", INT_MIN, true},
{"2147483647", INT_MAX, true},
{"", 0, false},
......@@ -163,7 +166,7 @@ TEST(StringNumberConversionsTest, StringToInt) {
EXPECT_EQ(6, output);
output = 0;
const char16 negative_wide_input[] = { 0xFF4D, '4', '2', 0};
const char16 negative_wide_input[] = {0xFF4D, '4', '2', 0};
EXPECT_FALSE(StringToInt(string16(negative_wide_input), &output));
EXPECT_EQ(0, output);
}
......@@ -177,7 +180,9 @@ TEST(StringNumberConversionsTest, StringToUint) {
{"0", 0, true},
{"42", 42, true},
{"42\x99", 42, false},
{"\x99" "42\x99", 0, false},
{"\x99"
"42\x99",
0, false},
{"-2147483648", 0, false},
{"2147483647", INT_MAX, true},
{"", 0, false},
......@@ -227,7 +232,7 @@ TEST(StringNumberConversionsTest, StringToUint) {
EXPECT_EQ(6U, output);
output = 0;
const char16 negative_wide_input[] = { 0xFF4D, '4', '2', 0};
const char16 negative_wide_input[] = {0xFF4D, '4', '2', 0};
EXPECT_FALSE(StringToUint(string16(negative_wide_input), &output));
EXPECT_EQ(0U, output);
}
......@@ -478,7 +483,9 @@ TEST(StringNumberConversionsTest, HexStringToInt) {
// One additional test to verify that conversion of numbers in strings with
// embedded NUL characters. The NUL and extra data after it should be
// interpreted as junk after the number.
const char input[] = "0xc0ffee\0" "9";
const char input[] =
"0xc0ffee\0"
"9";
std::string input_string(input, base::size(input) - 1);
int output;
EXPECT_FALSE(HexStringToInt(input_string, &output));
......@@ -543,7 +550,9 @@ TEST(StringNumberConversionsTest, HexStringToUInt) {
// One additional test to verify that conversion of numbers in strings with
// embedded NUL characters. The NUL and extra data after it should be
// interpreted as junk after the number.
const char input[] = "0xc0ffee\0" "9";
const char input[] =
"0xc0ffee\0"
"9";
std::string input_string(input, base::size(input) - 1);
uint32_t output;
EXPECT_FALSE(HexStringToUInt(input_string, &output));
......@@ -602,7 +611,9 @@ TEST(StringNumberConversionsTest, HexStringToInt64) {
// One additional test to verify that conversion of numbers in strings with
// embedded NUL characters. The NUL and extra data after it should be
// interpreted as junk after the number.
const char input[] = "0xc0ffee\0" "9";
const char input[] =
"0xc0ffee\0"
"9";
std::string input_string(input, base::size(input) - 1);
int64_t output;
EXPECT_FALSE(HexStringToInt64(input_string, &output));
......@@ -665,7 +676,9 @@ TEST(StringNumberConversionsTest, HexStringToUInt64) {
// One additional test to verify that conversion of numbers in strings with
// embedded NUL characters. The NUL and extra data after it should be
// interpreted as junk after the number.
const char input[] = "0xc0ffee\0" "9";
const char input[] =
"0xc0ffee\0"
"9";
std::string input_string(input, base::size(input) - 1);
uint64_t output;
EXPECT_FALSE(HexStringToUInt64(input_string, &output));
......@@ -695,8 +708,8 @@ TEST(StringNumberConversionsTest, HexStringToBytesStringSpan) {
{"efgh", "\xef", 1, false},
{"", "", 0, false},
{"0123456789ABCDEF", "\x01\x23\x45\x67\x89\xAB\xCD\xEF", 8, true},
{"0123456789ABCDEF012345",
"\x01\x23\x45\x67\x89\xAB\xCD\xEF\x01\x23\x45", 11, true},
{"0123456789ABCDEF012345", "\x01\x23\x45\x67\x89\xAB\xCD\xEF\x01\x23\x45",
11, true},
};
for (size_t test_i = 0; test_i < base::size(cases); ++test_i) {
......@@ -854,7 +867,9 @@ TEST(StringNumberConversionsTest, StringToDouble) {
// One additional test to verify that conversion of numbers in strings with
// embedded NUL characters. The NUL and extra data after it should be
// interpreted as junk after the number.
const char input[] = "3.14\0" "159";
const char input[] =
"3.14\0"
"159";
std::string input_string(input, base::size(input) - 1);
double output;
EXPECT_FALSE(StringToDouble(input_string, &output));
......@@ -886,8 +901,8 @@ TEST(StringNumberConversionsTest, DoubleToString) {
double input = 0;
memcpy(&input, input_bytes, base::size(input_bytes));
EXPECT_EQ("1.335179083776e+12", NumberToString(input));
const char input_bytes2[8] =
{0, 0, 0, '\xa0', '\xda', '\x6c', '\x73', '\x42'};
const char input_bytes2[8] = {0, 0, 0, '\xa0',
'\xda', '\x6c', '\x73', '\x42'};
input = 0;
memcpy(&input, input_bytes2, base::size(input_bytes2));
EXPECT_EQ("1.33489033216e+12", NumberToString(input));
......
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