#include "device/bluetooth/cast/bluetooth_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace device {
TEST(BluetoothUtilsTest, TestGetCanonicalBluetoothAddress) {
ASSERT_EQ("AA:BB:CC:DD:EE:FF", GetCanonicalBluetoothAddress(
{{0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xaa}}));
ASSERT_EQ("44:55:66:77:88:99", GetCanonicalBluetoothAddress(
{{0x99, 0x88, 0x77, 0x66, 0x55, 0x44}}));
ASSERT_EQ("00:00:00:00:00:00", GetCanonicalBluetoothAddress(
{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}));
}
TEST(BluetoothUtilsTest, TestUuidToBluetoothUUID_128bit) {
BluetoothUUID uuid =
UuidToBluetoothUUID({{0x12, 0x3e, 0x45, 0x67, 0xe8, 0x9b, 0x12, 0xd3,
0xa4, 0x56, 0x42, 0x66, 0x55, 0x44, 0x00, 0x00}});
ASSERT_TRUE(uuid.IsValid());
ASSERT_EQ(BluetoothUUID::kFormat128Bit, uuid.format());
ASSERT_EQ("123e4567-e89b-12d3-a456-426655440000", uuid.value());
ASSERT_EQ("123e4567-e89b-12d3-a456-426655440000", uuid.canonical_value());
}
TEST(BluetoothUtilsTest, TestUuidToBluetoothUUID_16bit) {
BluetoothUUID uuid =
UuidToBluetoothUUID({{0x00, 0x00, 0xfe, 0x34, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB}});
ASSERT_TRUE(uuid.IsValid());
ASSERT_EQ(BluetoothUUID::kFormat128Bit, uuid.format());
ASSERT_EQ("0000fe34-0000-1000-8000-00805f9b34fb", uuid.value());
ASSERT_EQ("0000fe34-0000-1000-8000-00805f9b34fb", uuid.canonical_value());
}
TEST(BluetoothUtilsTest, TestGetCanonicalBluetoothUuid) {
std::string uuid = GetCanonicalBluetoothUuid(
{{0x12, 0x3e, 0x45, 0x67, 0xe8, 0x9b, 0x12, 0xd3, 0xa4, 0x56, 0x42, 0x66,
0x55, 0x44, 0x00, 0x00}});
ASSERT_EQ("123e4567-e89b-12d3-a456-426655440000", uuid);
}
}