Commit 3bcd14d3 authored by Darwin Huang's avatar Darwin Huang Committed by Commit Bot

custom_data_helper_unittest: Use initializer lists.

No intended logic changes, but should be more readable.

Change-Id: Ife2389f5fbfa8e5448d584efdd612cbc1d67721d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1762979
Commit-Queue: Jarryd Goodman <jarrydg@chromium.org>
Auto-Submit: Darwin Huang <huangdarwin@chromium.org>
Reviewed-by: default avatarJarryd Goodman <jarrydg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#689104}
parent 84af85e9
......@@ -22,10 +22,10 @@ void PrepareEmptyTestData(base::Pickle* pickle) {
}
void PrepareTestData(base::Pickle* pickle) {
std::unordered_map<base::string16, base::string16> data;
data.insert({ASCIIToUTF16("abc"), base::string16()});
data.insert({ASCIIToUTF16("de"), ASCIIToUTF16("1")});
data.insert({ASCIIToUTF16("f"), ASCIIToUTF16("23")});
std::unordered_map<base::string16, base::string16> data = {
{ASCIIToUTF16("abc"), base::string16()},
{ASCIIToUTF16("de"), ASCIIToUTF16("1")},
{ASCIIToUTF16("f"), ASCIIToUTF16("23")}};
WriteCustomDataToPickle(data, pickle);
}
......@@ -66,10 +66,8 @@ TEST(CustomDataHelperTest, ReadTypes) {
std::vector<base::string16> types;
ReadCustomDataTypes(pickle.data(), pickle.size(), &types);
std::vector<base::string16> expected;
expected.push_back(ASCIIToUTF16("abc"));
expected.push_back(ASCIIToUTF16("de"));
expected.push_back(ASCIIToUTF16("f"));
std::vector<base::string16> expected = {
ASCIIToUTF16("abc"), ASCIIToUTF16("de"), ASCIIToUTF16("f")};
// We need to sort to compare equality, as the underlying custom data is
// unordered
std::sort(types.begin(), types.end());
......@@ -108,20 +106,18 @@ TEST(CustomDataHelperTest, ReadMap) {
std::unordered_map<base::string16, base::string16> result;
ReadCustomDataIntoMap(pickle.data(), pickle.size(), &result);
std::unordered_map<base::string16, base::string16> expected;
expected.insert({ASCIIToUTF16("abc"), base::string16()});
expected.insert({ASCIIToUTF16("de"), ASCIIToUTF16("1")});
expected.insert({ASCIIToUTF16("f"), ASCIIToUTF16("23")});
std::unordered_map<base::string16, base::string16> expected = {
{ASCIIToUTF16("abc"), base::string16()},
{ASCIIToUTF16("de"), ASCIIToUTF16("1")},
{ASCIIToUTF16("f"), ASCIIToUTF16("23")}};
EXPECT_EQ(expected, result);
}
TEST(CustomDataHelperTest, BadReadTypes) {
// ReadCustomDataTypes makes the additional guarantee that the contents of the
// result vector will not change if the input is malformed.
std::vector<base::string16> expected;
expected.push_back(ASCIIToUTF16("abc"));
expected.push_back(ASCIIToUTF16("de"));
expected.push_back(ASCIIToUTF16("f"));
std::vector<base::string16> expected = {
ASCIIToUTF16("abc"), ASCIIToUTF16("de"), ASCIIToUTF16("f")};
base::Pickle malformed;
malformed.WriteUInt32(1000);
......
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