blob: d9afabe56ffdcf444862d8f8d812b99ea6917253 [file] [log] [blame]
Alexander Hansen673b9812024-08-01 15:21:34 +02001/**
2 * Copyright © 2024 9elements
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "interfaces/internal_interface.hpp"
18#include "sysfs.hpp"
19
20#include <gtest/gtest.h>
21
22using namespace phosphor::led;
23using namespace phosphor::led::sysfs;
24
25TEST(DbusName, Has3Parts)
26{
27 LedDescr d = {"devicename", "color", "function"};
28
29 std::string name = interface::InternalInterface::getDbusName(d);
30
31 ASSERT_EQ("devicename_function_color", name);
32}
33
34TEST(DbusName, WithDash)
35{
36 LedDescr d = {"enclosure-identify", std::nullopt, std::nullopt};
37
38 std::string name = interface::InternalInterface::getDbusName(d);
39
40 ASSERT_EQ("enclosure_identify", name);
41}
42
43TEST(DbusName, With2Dashes)
44{
45 LedDescr d = {"enclosure-identify-fault", std::nullopt, std::nullopt};
46
47 std::string name = interface::InternalInterface::getDbusName(d);
48
49 ASSERT_EQ("enclosure_identify_fault", name);
50}
51
52TEST(DbusName, WithUnderscore)
53{
54 LedDescr d = {"enclosure_identify", std::nullopt, std::nullopt};
55
56 std::string name = interface::InternalInterface::getDbusName(d);
57
58 ASSERT_EQ("enclosure_identify", name);
59}