Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: device/bluetooth/bluetooth_uuid_unittest.cc

Issue 220323004: device/bluetooth: Rename device::bluetooth_utils::UUID to device::BluetoothUUID (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "device/bluetooth/bluetooth_uuid.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7
8 namespace device {
9
10 TEST(BluetoothUUIDTest, MainTest) {
11 const char kValid128Bit0[] = "12345678-1234-5678-9abc-def123456789";
12 const char kValid128Bit1[] = "00001101-0000-1000-8000-00805f9b34fb";
13 const char kInvalid36Char[] = "1234567-1234-5678-9abc-def123456789";
14 const char kInvalid4Char[] = "Z101";
15 const char kValid16Bit[] = "0x1101";
16 const char kValid32Bit[] = "00001101";
17
18 // Valid 128-bit custom UUID.
19 BluetoothUUID uuid0(kValid128Bit0);
20 EXPECT_TRUE(uuid0.IsValid());
21 EXPECT_EQ(BluetoothUUID::kFormat128Bit, uuid0.format());
22 EXPECT_EQ(uuid0.value(), uuid0.canonical_value());
23
24 // Valid 128-bit UUID.
25 BluetoothUUID uuid1(kValid128Bit1);
26 EXPECT_TRUE(uuid1.IsValid());
27 EXPECT_EQ(BluetoothUUID::kFormat128Bit, uuid1.format());
28 EXPECT_EQ(uuid1.value(), uuid1.canonical_value());
29
30 EXPECT_NE(uuid0, uuid1);
31
32 // Invalid 128-bit UUID.
33 BluetoothUUID uuid2(kInvalid36Char);
34 EXPECT_FALSE(uuid2.IsValid());
35 EXPECT_EQ(BluetoothUUID::kFormatInvalid, uuid2.format());
36 EXPECT_TRUE(uuid2.value().empty());
37 EXPECT_TRUE(uuid2.canonical_value().empty());
38
39 // Invalid 16-bit UUID.
40 BluetoothUUID uuid3(kInvalid4Char);
41 EXPECT_FALSE(uuid3.IsValid());
42 EXPECT_EQ(BluetoothUUID::kFormatInvalid, uuid3.format());
43 EXPECT_TRUE(uuid3.value().empty());
44 EXPECT_TRUE(uuid3.canonical_value().empty());
45
46 // Valid 16-bit UUID.
47 BluetoothUUID uuid4(kValid16Bit);
48 EXPECT_TRUE(uuid4.IsValid());
49 EXPECT_EQ(BluetoothUUID::kFormat16Bit, uuid4.format());
50 EXPECT_NE(uuid4.value(), uuid4.canonical_value());
51 EXPECT_EQ("1101", uuid4.value());
52 EXPECT_EQ(kValid128Bit1, uuid4.canonical_value());
53
54 // Valid 32-bit UUID.
55 BluetoothUUID uuid5(kValid32Bit);
56 EXPECT_TRUE(uuid5.IsValid());
57 EXPECT_EQ(BluetoothUUID::kFormat32Bit, uuid5.format());
58 EXPECT_NE(uuid5.value(), uuid5.canonical_value());
59 EXPECT_EQ("00001101", uuid5.value());
60 EXPECT_EQ(kValid128Bit1, uuid5.canonical_value());
61
62 // uuid4, uuid5, and uuid1 are equivalent.
63 EXPECT_EQ(uuid4, uuid5);
64 EXPECT_EQ(uuid1, uuid4);
65 EXPECT_EQ(uuid1, uuid5);
66 }
67
68
69 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698