Migrate base::{size,empty,data} to STL equivalents in //dbus.
Bug: 1299695
Change-Id: I6ee717b9c155abc84560b5c34603b660f65ec552
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3490663
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Owners-Override: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#975445}
NOKEYCHECK=True
GitOrigin-RevId: e0a0baa600690b1bb6b9f2c17364ffd225afaaf7
diff --git a/end_to_end_async_unittest.cc b/end_to_end_async_unittest.cc
index 2f676da..3b24454 100644
--- a/end_to_end_async_unittest.cc
+++ b/end_to_end_async_unittest.cc
@@ -11,7 +11,6 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
-#include "base/cxx17_backports.h"
#include "base/message_loop/message_pump_type.h"
#include "base/run_loop.h"
#include "base/task/single_thread_task_runner.h"
@@ -305,7 +304,7 @@
TEST_F(EndToEndAsyncTest, EchoThreeTimes) {
const char* kMessages[] = { "foo", "bar", "baz" };
- for (size_t i = 0; i < base::size(kMessages); ++i) {
+ for (size_t i = 0; i < std::size(kMessages); ++i) {
// Create the method call.
MethodCall method_call("org.chromium.TestInterface", "Echo");
MessageWriter writer(&method_call);
diff --git a/property_unittest.cc b/property_unittest.cc
index 871b76f..38c8b53 100644
--- a/property_unittest.cc
+++ b/property_unittest.cc
@@ -12,7 +12,6 @@
#include <vector>
#include "base/bind.h"
-#include "base/cxx17_backports.h"
#include "base/message_loop/message_pump_type.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
@@ -329,7 +328,7 @@
writer.OpenVariant("a{ss}", &variant_writer);
variant_writer.OpenArray("{ss}", &variant_array_writer);
const char* items[] = {"One", "Two", "Three", "Four"};
- for (unsigned i = 0; i < base::size(items); ++i) {
+ for (unsigned i = 0; i < std::size(items); ++i) {
variant_array_writer.OpenDictEntry(&struct_entry_writer);
struct_entry_writer.AppendString(items[i]);
struct_entry_writer.AppendString(base::NumberToString(i + 1));
@@ -379,7 +378,7 @@
for (uint16_t i = 0; i < 5; ++i) {
variant_array_writer.OpenStruct(&struct_entry_writer);
ip_bytes[4] = 0x30 + i;
- struct_entry_writer.AppendArrayOfBytes(ip_bytes, base::size(ip_bytes));
+ struct_entry_writer.AppendArrayOfBytes(ip_bytes, std::size(ip_bytes));
struct_entry_writer.AppendUint16(i);
variant_array_writer.CloseContainer(&struct_entry_writer);
}
@@ -407,7 +406,7 @@
uint8_t ip_bytes[] = {0x54, 0x65, 0x73, 0x74, 0x30};
for (uint16_t i = 0; i < 5; ++i) {
ip_bytes[4] = 0x30 + i;
- std::vector<uint8_t> bytes(ip_bytes, ip_bytes + base::size(ip_bytes));
+ std::vector<uint8_t> bytes(ip_bytes, ip_bytes + std::size(ip_bytes));
test_list.push_back(make_pair(bytes, 16));
}
@@ -434,7 +433,7 @@
const char* keys[] = {"One", "Two", "Three", "Four"};
const std::vector<uint8_t> values[] = {{1}, {1, 2}, {1, 2, 3}, {1, 2, 3, 4}};
- for (unsigned i = 0; i < base::size(keys); ++i) {
+ for (unsigned i = 0; i < std::size(keys); ++i) {
MessageWriter entry_writer(nullptr);
dict_writer.OpenDictEntry(&entry_writer);
@@ -455,8 +454,8 @@
Property<std::map<std::string, std::vector<uint8_t>>> test_property;
EXPECT_TRUE(test_property.PopValueFromReader(&reader));
- ASSERT_EQ(base::size(keys), test_property.value().size());
- for (unsigned i = 0; i < base::size(keys); ++i)
+ ASSERT_EQ(std::size(keys), test_property.value().size());
+ for (unsigned i = 0; i < std::size(keys); ++i)
EXPECT_EQ(values[i], test_property.value().at(keys[i]));
}
@@ -471,7 +470,7 @@
const char* keys[] = {"One", "Two", "Three", "Four"};
const std::vector<uint8_t> values[] = {{1}, {1, 2}, {1, 2, 3}, {1, 2, 3, 4}};
- for (unsigned i = 0; i < base::size(keys); ++i) {
+ for (unsigned i = 0; i < std::size(keys); ++i) {
MessageWriter entry_writer(nullptr);
dict_writer.OpenDictEntry(&entry_writer);
@@ -488,8 +487,8 @@
Property<std::map<std::string, std::vector<uint8_t>>> test_property;
EXPECT_TRUE(test_property.PopValueFromReader(&reader));
- ASSERT_EQ(base::size(keys), test_property.value().size());
- for (unsigned i = 0; i < base::size(keys); ++i)
+ ASSERT_EQ(std::size(keys), test_property.value().size());
+ for (unsigned i = 0; i < std::size(keys); ++i)
EXPECT_EQ(values[i], test_property.value().at(keys[i]));
}
@@ -522,7 +521,7 @@
const uint16_t keys[] = {11, 12, 13, 14};
const std::vector<uint8_t> values[] = {{1}, {1, 2}, {1, 2, 3}, {1, 2, 3, 4}};
- for (unsigned i = 0; i < base::size(keys); ++i) {
+ for (unsigned i = 0; i < std::size(keys); ++i) {
MessageWriter entry_writer(nullptr);
dict_writer.OpenDictEntry(&entry_writer);
@@ -543,8 +542,8 @@
Property<std::map<uint16_t, std::vector<uint8_t>>> test_property;
EXPECT_TRUE(test_property.PopValueFromReader(&reader));
- ASSERT_EQ(base::size(keys), test_property.value().size());
- for (unsigned i = 0; i < base::size(keys); ++i)
+ ASSERT_EQ(std::size(keys), test_property.value().size());
+ for (unsigned i = 0; i < std::size(keys); ++i)
EXPECT_EQ(values[i], test_property.value().at(keys[i]));
}
@@ -559,7 +558,7 @@
const uint16_t keys[] = {11, 12, 13, 14};
const std::vector<uint8_t> values[] = {{1}, {1, 2}, {1, 2, 3}, {1, 2, 3, 4}};
- for (unsigned i = 0; i < base::size(keys); ++i) {
+ for (unsigned i = 0; i < std::size(keys); ++i) {
MessageWriter entry_writer(nullptr);
dict_writer.OpenDictEntry(&entry_writer);
@@ -576,8 +575,8 @@
Property<std::map<uint16_t, std::vector<uint8_t>>> test_property;
EXPECT_TRUE(test_property.PopValueFromReader(&reader));
- ASSERT_EQ(base::size(keys), test_property.value().size());
- for (unsigned i = 0; i < base::size(keys); ++i)
+ ASSERT_EQ(std::size(keys), test_property.value().size());
+ for (unsigned i = 0; i < std::size(keys); ++i)
EXPECT_EQ(values[i], test_property.value().at(keys[i]));
}
diff --git a/values_util_unittest.cc b/values_util_unittest.cc
index 0b16a7d..a27b251 100644
--- a/values_util_unittest.cc
+++ b/values_util_unittest.cc
@@ -12,7 +12,6 @@
#include <utility>
#include <vector>
-#include "base/cxx17_backports.h"
#include "base/json/json_writer.h"
#include "base/values.h"
#include "dbus/message.h"
@@ -330,7 +329,7 @@
TEST(ValuesUtilTest, PopDoubleToIntDictionary) {
// Create test data.
const int32_t kValues[] = {0, 1, 1, 2, 3, 5, 8, 13, 21};
- const std::vector<int32_t> values(kValues, kValues + base::size(kValues));
+ const std::vector<int32_t> values(kValues, kValues + std::size(kValues));
std::vector<double> keys(values.size());
for (size_t i = 0; i != values.size(); ++i)
keys[i] = std::sqrt(values[i]);