diff options
author | Jakub Pawlowski <jpawlowski@google.com> | 2017-10-12 13:29:04 -0700 |
---|---|---|
committer | Myles Watson <mylesgw@google.com> | 2017-10-12 20:38:58 +0000 |
commit | bf1ddfc833108c921639271eb2149203ccbbbbd2 (patch) | |
tree | 578ab29c60eae7030a0c6b33e1b468e624078054 /types/test | |
parent | 98c0494449165f7e10c1f6f589946dd2a7a745c4 (diff) | |
download | bt-bf1ddfc833108c921639271eb2149203ccbbbbd2.tar.gz |
make Uuid::kBase into local constexpr
This fixes a bug where From128BitBE is used before kBase is initialized
Bug: 67671467
Test: Share a picture using Bluetooth
Change-Id: Ifb5b5f90dbca9646f117b9ff5d01439407424597
Diffstat (limited to 'types/test')
-rw-r--r-- | types/test/bluetooth/uuid_unittest.cc | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/types/test/bluetooth/uuid_unittest.cc b/types/test/bluetooth/uuid_unittest.cc index a2de1c6a0..2cdaf5416 100644 --- a/types/test/bluetooth/uuid_unittest.cc +++ b/types/test/bluetooth/uuid_unittest.cc @@ -29,13 +29,17 @@ static const Uuid SEQUENTIAL = Uuid::From128BitBE( Uuid::UUID128Bit{{0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x89}}); +constexpr Uuid kBase = Uuid::From128BitBE( + Uuid::UUID128Bit{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, + 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb}}); + TEST(UuidTest, IsEmpty) { EXPECT_TRUE(Uuid::kEmpty.IsEmpty()); - EXPECT_FALSE(Uuid::kBase.IsEmpty()); + EXPECT_FALSE(kBase.IsEmpty()); } TEST(UuidTest, GetShortestRepresentationSize) { - EXPECT_TRUE(Uuid::kNumBytes16 == Uuid::kBase.GetShortestRepresentationSize()); + EXPECT_TRUE(Uuid::kNumBytes16 == kBase.GetShortestRepresentationSize()); EXPECT_TRUE(Uuid::kNumBytes32 == Uuid::From32Bit(0x01234567).GetShortestRepresentationSize()); EXPECT_TRUE(Uuid::kNumBytes128 == @@ -46,26 +50,26 @@ TEST(UuidTest, As16Bit) { // Even though this is is not 16bit UUID, we should be able to get proper bits EXPECT_EQ((uint16_t)0x1111, ONES.As16Bit()); EXPECT_EQ((uint16_t)0x4567, SEQUENTIAL.As16Bit()); - EXPECT_EQ((uint16_t)0x0000, Uuid::kBase.As16Bit()); + EXPECT_EQ((uint16_t)0x0000, kBase.As16Bit()); } TEST(UuidTest, As32Bit) { // Even though this is is not 32bit UUID, we should be able to get proper bits EXPECT_EQ((uint32_t)0x11111111, ONES.As32Bit()); EXPECT_EQ((uint32_t)0x01234567, SEQUENTIAL.As32Bit()); - EXPECT_EQ((uint32_t)0x00000000, Uuid::kBase.As32Bit()); + EXPECT_EQ((uint32_t)0x00000000, kBase.As32Bit()); EXPECT_EQ((uint32_t)0x12345678, Uuid::From32Bit(0x12345678).As32Bit()); } TEST(UuidTest, Is16Bit) { EXPECT_FALSE(ONES.Is16Bit()); EXPECT_FALSE(SEQUENTIAL.Is16Bit()); - EXPECT_TRUE(Uuid::kBase.Is16Bit()); + EXPECT_TRUE(kBase.Is16Bit()); EXPECT_TRUE(Uuid::FromString("1ae8").Is16Bit()); } TEST(UuidTest, From16Bit) { - EXPECT_EQ(Uuid::From16Bit(0x0000), Uuid::kBase); + EXPECT_EQ(Uuid::From16Bit(0x0000), kBase); const uint8_t u2[] = {0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb}; @@ -84,7 +88,7 @@ TEST(UuidTest, From16Bit) { } TEST(UuidTest, From32Bit) { - EXPECT_EQ(Uuid::From32Bit(0x00000000), Uuid::kBase); + EXPECT_EQ(Uuid::From32Bit(0x00000000), kBase); const uint8_t u2[] = {0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb}; @@ -108,7 +112,7 @@ TEST(UuidTest, ToString) { const std::string UUID_ONES_STR = "11111111-1111-1111-1111-111111111111"; const std::string UUID_SEQ_STR = "01234567-89ab-cdef-abcd-ef0123456789"; - EXPECT_EQ(UUID_BASE_STR, Uuid::kBase.ToString()); + EXPECT_EQ(UUID_BASE_STR, kBase.ToString()); EXPECT_EQ(UUID_EMP_STR, Uuid::kEmpty.ToString()); EXPECT_EQ(UUID_ONES_STR, ONES.ToString()); EXPECT_EQ(UUID_SEQ_STR, SEQUENTIAL.ToString()); |