1 // Copyright 2023 The Pigweed Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
5 // the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
13 // the License.
14
15 #include "pw_bluetooth_sapphire/internal/host/hci-spec/util.h"
16
17 #include "pw_unit_test/framework.h"
18
19 namespace bt::hci_spec {
20 namespace {
21
TEST(UtilTest,LinkKeyTypeToString)22 TEST(UtilTest, LinkKeyTypeToString) {
23 std::string link_key_type =
24 LinkKeyTypeToString(hci_spec::LinkKeyType::kCombination);
25 EXPECT_EQ("kCombination", link_key_type);
26
27 link_key_type = LinkKeyTypeToString(hci_spec::LinkKeyType::kLocalUnit);
28 EXPECT_EQ("kLocalUnit", link_key_type);
29
30 link_key_type = LinkKeyTypeToString(hci_spec::LinkKeyType::kRemoteUnit);
31 EXPECT_EQ("kRemoteUnit", link_key_type);
32
33 link_key_type = LinkKeyTypeToString(hci_spec::LinkKeyType::kDebugCombination);
34 EXPECT_EQ("kDebugCombination", link_key_type);
35
36 link_key_type = LinkKeyTypeToString(
37 hci_spec::LinkKeyType::kUnauthenticatedCombination192);
38 EXPECT_EQ("kUnauthenticatedCombination192", link_key_type);
39
40 link_key_type =
41 LinkKeyTypeToString(hci_spec::LinkKeyType::kAuthenticatedCombination192);
42 EXPECT_EQ("kAuthenticatedCombination192", link_key_type);
43
44 link_key_type =
45 LinkKeyTypeToString(hci_spec::LinkKeyType::kChangedCombination);
46 EXPECT_EQ("kChangedCombination", link_key_type);
47
48 link_key_type = LinkKeyTypeToString(
49 hci_spec::LinkKeyType::kUnauthenticatedCombination256);
50 EXPECT_EQ("kUnauthenticatedCombination256", link_key_type);
51
52 link_key_type =
53 LinkKeyTypeToString(hci_spec::LinkKeyType::kAuthenticatedCombination256);
54 EXPECT_EQ("kAuthenticatedCombination256", link_key_type);
55
56 // Unknown link key type
57 link_key_type = LinkKeyTypeToString(static_cast<hci_spec::LinkKeyType>(0xFF));
58 EXPECT_EQ("(Unknown)", link_key_type);
59 }
60
61 } // namespace
62 } // namespace bt::hci_spec
63