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.
5 #include "device/bluetooth/bluetooth_device.h"
7 #include "base/macros.h"
8 #include "testing/gtest/include/gtest/gtest.h"
12 TEST(BluetoothDeviceTest
, CanonicalizeAddressFormat_AcceptsAllValidFormats
) {
13 // There are three valid separators (':', '-', and none).
14 // Case shouldn't matter.
15 const char* const kValidFormats
[] = {
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
]));
34 TEST(BluetoothDeviceTest
, CanonicalizeAddressFormat_RejectsInvalidFormats
) {
35 const char* const kValidFormats
[] = {
41 "1A:2B:3C:4D:5E:6F:70",
42 // Missing a separator.
46 // Invalid characters.
48 // Separators in the wrong place.
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
]));