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

Unified 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, 9 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 side-by-side diff with in-line comments
Download patch
Index: device/bluetooth/bluetooth_uuid_unittest.cc
diff --git a/device/bluetooth/bluetooth_uuid_unittest.cc b/device/bluetooth/bluetooth_uuid_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0b98cd371b8dfb3a843c17834539dc70e608449b
--- /dev/null
+++ b/device/bluetooth/bluetooth_uuid_unittest.cc
@@ -0,0 +1,69 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "device/bluetooth/bluetooth_uuid.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace device {
+
+TEST(BluetoothUUIDTest, MainTest) {
+ const char kValid128Bit0[] = "12345678-1234-5678-9abc-def123456789";
+ const char kValid128Bit1[] = "00001101-0000-1000-8000-00805f9b34fb";
+ const char kInvalid36Char[] = "1234567-1234-5678-9abc-def123456789";
+ const char kInvalid4Char[] = "Z101";
+ const char kValid16Bit[] = "0x1101";
+ const char kValid32Bit[] = "00001101";
+
+ // Valid 128-bit custom UUID.
+ BluetoothUUID uuid0(kValid128Bit0);
+ EXPECT_TRUE(uuid0.IsValid());
+ EXPECT_EQ(BluetoothUUID::kFormat128Bit, uuid0.format());
+ EXPECT_EQ(uuid0.value(), uuid0.canonical_value());
+
+ // Valid 128-bit UUID.
+ BluetoothUUID uuid1(kValid128Bit1);
+ EXPECT_TRUE(uuid1.IsValid());
+ EXPECT_EQ(BluetoothUUID::kFormat128Bit, uuid1.format());
+ EXPECT_EQ(uuid1.value(), uuid1.canonical_value());
+
+ EXPECT_NE(uuid0, uuid1);
+
+ // Invalid 128-bit UUID.
+ BluetoothUUID uuid2(kInvalid36Char);
+ EXPECT_FALSE(uuid2.IsValid());
+ EXPECT_EQ(BluetoothUUID::kFormatInvalid, uuid2.format());
+ EXPECT_TRUE(uuid2.value().empty());
+ EXPECT_TRUE(uuid2.canonical_value().empty());
+
+ // Invalid 16-bit UUID.
+ BluetoothUUID uuid3(kInvalid4Char);
+ EXPECT_FALSE(uuid3.IsValid());
+ EXPECT_EQ(BluetoothUUID::kFormatInvalid, uuid3.format());
+ EXPECT_TRUE(uuid3.value().empty());
+ EXPECT_TRUE(uuid3.canonical_value().empty());
+
+ // Valid 16-bit UUID.
+ BluetoothUUID uuid4(kValid16Bit);
+ EXPECT_TRUE(uuid4.IsValid());
+ EXPECT_EQ(BluetoothUUID::kFormat16Bit, uuid4.format());
+ EXPECT_NE(uuid4.value(), uuid4.canonical_value());
+ EXPECT_EQ("1101", uuid4.value());
+ EXPECT_EQ(kValid128Bit1, uuid4.canonical_value());
+
+ // Valid 32-bit UUID.
+ BluetoothUUID uuid5(kValid32Bit);
+ EXPECT_TRUE(uuid5.IsValid());
+ EXPECT_EQ(BluetoothUUID::kFormat32Bit, uuid5.format());
+ EXPECT_NE(uuid5.value(), uuid5.canonical_value());
+ EXPECT_EQ("00001101", uuid5.value());
+ EXPECT_EQ(kValid128Bit1, uuid5.canonical_value());
+
+ // uuid4, uuid5, and uuid1 are equivalent.
+ EXPECT_EQ(uuid4, uuid5);
+ EXPECT_EQ(uuid1, uuid4);
+ EXPECT_EQ(uuid1, uuid5);
+}
+
+
+} // namespace device

Powered by Google App Engine
This is Rietveld 408576698