summaryrefslogtreecommitdiff
path: root/test/redfish-core/include/utils/location_utils_test.cpp
blob: 538db1bfe7704b9cc535925246c4f104d3f488fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "utils/location_utils.hpp"

#include <optional>

#include "gtest/gtest.h"

namespace redfish::location_util
{
namespace
{

TEST(LocationUtility, ValidLocationType)
{
    EXPECT_EQ(getLocationType("xyz.openbmc_project.Inventory.Connector.Slot"),
              "Slot");
    EXPECT_EQ(
        getLocationType("xyz.openbmc_project.Inventory.Connector.Embedded"),
        "Embedded");
}

TEST(LocationUtility, InvalidLocationType)
{
    EXPECT_EQ(getLocationType(""), std::nullopt);
    EXPECT_EQ(getLocationType("xyz.openbmc_project.Inventory.Connector.RANDOM"),
              std::nullopt);
    EXPECT_EQ(getLocationType("xyz.openbmc_project.Inventory.Connector"),
              std::nullopt);
    EXPECT_EQ(getLocationType("xyz.openbmc_project.Inventory."), std::nullopt);
    EXPECT_EQ(getLocationType("xyz.openbmc_project.Item.Connector"),
              std::nullopt);
    EXPECT_EQ(getLocationType("xyz.openbmc_project.Inventory.Connector.BAY"),
              std::nullopt);
    EXPECT_EQ(getLocationType("xyz.openbmc_project.Inventory.Connector.Bay2"),
              std::nullopt);
}

} // namespace
} // namespace redfish::location_util