Alexander Hansen | 8d9e6da | 2025-01-14 14:17:19 +0100 | [diff] [blame^] | 1 | |
| 2 | #include "common/include/device_config.hpp" |
| 3 | |
| 4 | #include <fcntl.h> |
| 5 | #include <inttypes.h> |
| 6 | #include <unistd.h> |
| 7 | |
| 8 | #include <phosphor-logging/lg2.hpp> |
| 9 | |
| 10 | #include <cassert> |
| 11 | #include <cstdlib> |
| 12 | #include <cstring> |
| 13 | |
| 14 | #include <gtest/gtest.h> |
| 15 | |
| 16 | TEST(DeviceConfig, success) |
| 17 | { |
| 18 | DeviceConfig config(0x0324, "com.example.SampleCorp", "ConfigType", |
| 19 | "SampleComponent"); |
| 20 | |
| 21 | ASSERT_EQ(config.vendorIANA, 0x0324); |
| 22 | ASSERT_EQ(config.compatibleHardware, "com.example.SampleCorp"); |
| 23 | } |
| 24 | |
| 25 | TEST(DeviceConfig, failureCompatibleNoDot) |
| 26 | { |
| 27 | try |
| 28 | { |
| 29 | DeviceConfig config(0x0324, "comexamplesamplecorp", "ConfigType", |
| 30 | "SampleComponent"); |
| 31 | ASSERT_FALSE(true); |
| 32 | } |
| 33 | catch (std::exception& /*unused*/) |
| 34 | {} |
| 35 | } |
| 36 | |
| 37 | TEST(DeviceConfig, failureCompatibleInvalidChar) |
| 38 | { |
| 39 | try |
| 40 | { |
| 41 | DeviceConfig config(0x0324, "com-examplesamplecorp#", "ConfigType", |
| 42 | "SampleComponent"); |
| 43 | ASSERT_FALSE(true); |
| 44 | } |
| 45 | catch (std::exception& /*unused*/) |
| 46 | {} |
| 47 | } |