#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "device/bluetooth/public/cpp/bluetooth_uuid.h"
#include <stddef.h>
#include <sstream>
#include "build/build_config.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#if BUILDFLAG(IS_WIN)
#include <rpc.h>
#endif
namespace device {
TEST(BluetoothUUIDTest, BluetoothUUID) { … }
#if BUILDFLAG(IS_WIN)
TEST(BluetoothUUIDTest, BluetoothUUID_GUID) {
const char kValid128Bit0[] = "12345678-1234-5678-9abc-def123456789";
GUID guid;
guid.Data1 = 0x12345678;
guid.Data2 = 0x1234;
guid.Data3 = 0x5678;
guid.Data4[0] = 0x9a;
guid.Data4[1] = 0xbc;
guid.Data4[2] = 0xde;
guid.Data4[3] = 0xf1;
guid.Data4[4] = 0x23;
guid.Data4[5] = 0x45;
guid.Data4[6] = 0x67;
guid.Data4[7] = 0x89;
BluetoothUUID uuid(guid);
EXPECT_TRUE(uuid.IsValid());
EXPECT_EQ(BluetoothUUID::kFormat128Bit, uuid.format());
EXPECT_EQ(kValid128Bit0, uuid.value());
EXPECT_EQ(kValid128Bit0, uuid.canonical_value());
}
TEST(BluetoothUUIDTest, GetCanonicalValueAsGUID) {
const char kValid128Bit0[] = "12345678-1234-5678-9abc-def123456789";
GUID guid = BluetoothUUID::GetCanonicalValueAsGUID(kValid128Bit0);
EXPECT_EQ(0x12345678u, guid.Data1);
EXPECT_EQ(0x1234, guid.Data2);
EXPECT_EQ(0x5678, guid.Data3);
EXPECT_EQ(0x9a, guid.Data4[0]);
EXPECT_EQ(0xbc, guid.Data4[1]);
EXPECT_EQ(0xde, guid.Data4[2]);
EXPECT_EQ(0xf1, guid.Data4[3]);
EXPECT_EQ(0x23, guid.Data4[4]);
EXPECT_EQ(0x45, guid.Data4[5]);
EXPECT_EQ(0x67, guid.Data4[6]);
EXPECT_EQ(0x89, guid.Data4[7]);
}
#endif
TEST(BluetoothUUIDTest, BluetoothUUID_CaseInsensitive) { … }
TEST(BluetoothUUIDTest, BluetoothUUID_stream_insertion_operator) { … }
}