mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
[BLE Refactor] Tune BleAdvertisement, BleAdvertisementHeader, BlePeripheral, AdvertisementReadResult, BleUtils.
PiperOrigin-RevId: 439365106
This commit is contained in:
committed by
Copybara-Service
parent
7eded6c621
commit
0747c0a349
@@ -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",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -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_;
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user