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

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

Issue 288903003: [Bluetooth] Standardize Bluetooth device address format to XX:XX:XX:XX:XX:XX. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ChromeOS tests too 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « device/bluetooth/bluetooth_device_mac.mm ('k') | device/bluetooth/bluetooth_device_win.cc » ('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 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_device.h"
6
7 #include "base/macros.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 namespace device {
11
12 TEST(BluetoothDeviceTest, CanonicalizeAddressFormat_AcceptsAllValidFormats) {
13 // There are three valid separators (':', '-', and none).
14 // Case shouldn't matter.
15 const char* const kValidFormats[] = {
16 "1A:2B:3C:4D:5E:6F",
17 "1a:2B:3c:4D:5e:6F",
18 "1a:2b:3c:4d:5e:6f",
19 "1A-2B-3C-4D-5E-6F",
20 "1a-2B-3c-4D-5e-6F",
21 "1a-2b-3c-4d-5e-6f",
22 "1A2B3C4D5E6F",
23 "1a2B3c4D5e6F",
24 "1a2b3c4d5e6f",
25 };
26
27 for (size_t i = 0; i < arraysize(kValidFormats); ++i) {
28 SCOPED_TRACE(std::string("Input format: '") + kValidFormats[i] + "'");
29 EXPECT_EQ("1A:2B:3C:4D:5E:6F",
30 BluetoothDevice::CanonicalizeAddress(kValidFormats[i]));
31 }
32 }
33
34 TEST(BluetoothDeviceTest, CanonicalizeAddressFormat_RejectsInvalidFormats) {
35 const char* const kValidFormats[] = {
36 // Empty string.
37 "",
38 // Too short.
39 "1A:2B:3C:4D:5E",
40 // Too long.
41 "1A:2B:3C:4D:5E:6F:70",
42 // Missing a separator.
43 "1A:2B:3C:4D:5E6F",
44 // Mixed separators.
45 "1A:2B-3C:4D-5E:6F",
46 // Invalid characters.
47 "1A:2B-3C:4D-5E:6X",
48 // Separators in the wrong place.
49 "1:A2:B3:C4:D5:E6F",
50 };
51
52 for (size_t i = 0; i < arraysize(kValidFormats); ++i) {
53 SCOPED_TRACE(std::string("Input format: '") + kValidFormats[i] + "'");
54 EXPECT_EQ(std::string(),
55 BluetoothDevice::CanonicalizeAddress(kValidFormats[i]));
56 }
57 }
58
59 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_device_mac.mm ('k') | device/bluetooth/bluetooth_device_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698