[BLE Refactor] Tune BleAdvertisement, BleAdvertisementHeader, BlePeripheral, AdvertisementReadResult, BleUtils.

PiperOrigin-RevId: 439365106
This commit is contained in:
edwinwu
2022-04-04 11:19:24 -07:00
committed by Copybara-Service
parent 7eded6c621
commit 0747c0a349
21 changed files with 411 additions and 135 deletions
+1
View File
@@ -197,6 +197,7 @@ cc_test(
":test_util",
"//internal/platform/implementation/g3", # build_cleaner: keep
"@com_github_protobuf_matchers//protobuf-matchers",
"@com_google_absl//absl/hash:hash_testing",
"@com_google_googletest//:gtest_main",
],
)
+6
View File
@@ -99,6 +99,12 @@ class ByteArray {
return absl::string_view(data(), size());
}
// Hashable
template <typename H>
friend H AbslHashValue(H h, const ByteArray& m) {
return H::combine(std::move(h), m.data_);
}
private:
std::string data_;
};
+10
View File
@@ -17,6 +17,7 @@
#include <cstring>
#include "gtest/gtest.h"
#include "absl/hash/hash_testing.h"
namespace {
@@ -95,4 +96,13 @@ TEST(ByteArrayTest, CreateFromAbslStringReturnsTheSame) {
EXPECT_EQ(bytes.AsStringView(), kTestString);
}
TEST(ByteArrayTest, Hash) {
EXPECT_TRUE(absl::VerifyTypeImplementsAbslHashCorrectly({
ByteArray(),
ByteArray("12345"),
ByteArray("ABCDE"),
ByteArray("A1B2Z"),
}));
}
} // namespace