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

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

Issue 224893002: 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
« no previous file with comments | « device/bluetooth/bluetooth_uuid.cc ('k') | device/bluetooth/test/mock_bluetooth_device.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 kInvalid36Char0[] = "1234567-1234-5678-9abc-def123456789";
14 const char kInvalid36Char1[] = "0x00001101-0000-1000-8000-00805f9b34fb";
15 const char kInvalid4Char[] = "Z101";
16 const char kValid16Bit[] = "0x1101";
17 const char kValid32Bit[] = "00001101";
18
19 // Valid 128-bit custom UUID.
20 BluetoothUUID uuid0(kValid128Bit0);
21 EXPECT_TRUE(uuid0.IsValid());
22 EXPECT_EQ(BluetoothUUID::kFormat128Bit, uuid0.format());
23 EXPECT_EQ(uuid0.value(), uuid0.canonical_value());
24
25 // Valid 128-bit UUID.
26 BluetoothUUID uuid1(kValid128Bit1);
27 EXPECT_TRUE(uuid1.IsValid());
28 EXPECT_EQ(BluetoothUUID::kFormat128Bit, uuid1.format());
29 EXPECT_EQ(uuid1.value(), uuid1.canonical_value());
30
31 EXPECT_NE(uuid0, uuid1);
32
33 // Invalid 128-bit UUID.
34 BluetoothUUID uuid2(kInvalid36Char0);
35 EXPECT_FALSE(uuid2.IsValid());
36 EXPECT_EQ(BluetoothUUID::kFormatInvalid, uuid2.format());
37 EXPECT_TRUE(uuid2.value().empty());
38 EXPECT_TRUE(uuid2.canonical_value().empty());
39
40 // Invalid 128-bit UUID.
41 BluetoothUUID uuid3(kInvalid36Char1);
42 EXPECT_FALSE(uuid3.IsValid());
43 EXPECT_EQ(BluetoothUUID::kFormatInvalid, uuid3.format());
44 EXPECT_TRUE(uuid3.value().empty());
45 EXPECT_TRUE(uuid3.canonical_value().empty());
46
47 // Invalid 16-bit UUID.
48 BluetoothUUID uuid4(kInvalid4Char);
49 EXPECT_FALSE(uuid4.IsValid());
50 EXPECT_EQ(BluetoothUUID::kFormatInvalid, uuid4.format());
51 EXPECT_TRUE(uuid4.value().empty());
52 EXPECT_TRUE(uuid4.canonical_value().empty());
53
54 // Valid 16-bit UUID.
55 BluetoothUUID uuid5(kValid16Bit);
56 EXPECT_TRUE(uuid5.IsValid());
57 EXPECT_EQ(BluetoothUUID::kFormat16Bit, uuid5.format());
58 EXPECT_NE(uuid5.value(), uuid5.canonical_value());
59 EXPECT_EQ("1101", uuid5.value());
60 EXPECT_EQ(kValid128Bit1, uuid5.canonical_value());
61
62 // Valid 32-bit UUID.
63 BluetoothUUID uuid6(kValid32Bit);
64 EXPECT_TRUE(uuid6.IsValid());
65 EXPECT_EQ(BluetoothUUID::kFormat32Bit, uuid6.format());
66 EXPECT_NE(uuid6.value(), uuid6.canonical_value());
67 EXPECT_EQ("00001101", uuid6.value());
68 EXPECT_EQ(kValid128Bit1, uuid6.canonical_value());
69
70 // uuid5, uuid6, and uuid1 are equivalent.
71 EXPECT_EQ(uuid5, uuid6);
72 EXPECT_EQ(uuid1, uuid5);
73 EXPECT_EQ(uuid1, uuid6);
74 }
75
76 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_uuid.cc ('k') | device/bluetooth/test/mock_bluetooth_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698