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

Unified Diff: device/bluetooth/bluetooth_uuid_unittest.cc

Issue 285633003: Bluetooth UUIDs should be case-insensitive. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
« no previous file with comments | « device/bluetooth/bluetooth_uuid.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/bluetooth_uuid_unittest.cc
diff --git a/device/bluetooth/bluetooth_uuid_unittest.cc b/device/bluetooth/bluetooth_uuid_unittest.cc
index d4838bbc99cbef2df71d786d6db1a152e29675d3..c59ab1c934e4a96abfca74cadb38c8fcb42940dc 100644
--- a/device/bluetooth/bluetooth_uuid_unittest.cc
+++ b/device/bluetooth/bluetooth_uuid_unittest.cc
@@ -2,12 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/macros.h"
#include "device/bluetooth/bluetooth_uuid.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace device {
-TEST(BluetoothUUIDTest, MainTest) {
+TEST(BluetoothUUIDTest, BluetoothUUID) {
const char kValid128Bit0[] = "12345678-1234-5678-9abc-def123456789";
const char kValid128Bit1[] = "00001101-0000-1000-8000-00805f9b34fb";
const char kInvalid36Char0[] = "1234567-1234-5678-9abc-def123456789";
@@ -73,4 +74,34 @@ TEST(BluetoothUUIDTest, MainTest) {
EXPECT_EQ(uuid1, uuid6);
}
+// Verify that UUIDs are parsed case-insensitively
+TEST(BluetoothUUIDTest, BluetoothUUID_CaseInsensitive) {
+ const char k16Bit[] = "1abc";
+ const char k32Bit[] = "00001abc";
+ const char k128Bit[] = "00001abc-0000-1000-8000-00805f9b34fb";
+
+ struct TestCase {
+ const std::string input_uuid;
+ const std::string expected_value;
+ } test_cases[] = {
+ { "1abc", k16Bit },
+ { "1ABC", k16Bit },
+ { "1aBc", k16Bit },
+ { "00001abc", k32Bit },
+ { "00001ABC", k32Bit },
+ { "00001aBc", k32Bit },
+ { "00001abc-0000-1000-8000-00805f9b34fb", k128Bit },
+ { "00001ABC-0000-1000-8000-00805F9B34FB", k128Bit },
+ { "00001aBc-0000-1000-8000-00805F9b34fB", k128Bit },
+ };
+
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
+ SCOPED_TRACE("Input UUID: " + test_cases[i].input_uuid);
+ BluetoothUUID uuid(test_cases[i].input_uuid);
+ EXPECT_TRUE(uuid.IsValid());
+ EXPECT_EQ(test_cases[i].expected_value, uuid.value());
+ EXPECT_EQ(k128Bit, uuid.canonical_value());
+ }
+}
+
} // namespace device
« no previous file with comments | « device/bluetooth/bluetooth_uuid.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698