PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
Loading...
Searching...
No Matches
test_vendors.cpp
Go to the documentation of this file.
1
11
12#include <gtest/gtest.h>
13
14#include "profinet/vendors.h"
15
16using namespace profinet;
17
18class VendorsTest : public ::testing::Test
19{
20};
21
23TEST_F(VendorsTest, KnownVendorIdResolvesToName)
24{
25 // Siemens AG's PROFINET vendor ID is well-known and stable.
26 auto name = LookupVendor(0x002A);
27
28 ASSERT_TRUE(name.has_value());
29}
30
32TEST_F(VendorsTest, UnknownVendorIdReturnsNulloptOrFallbackString)
33{
34 // 0xFFFE is exceedingly unlikely to be assigned.
35 auto name = LookupVendor(0xFFFE);
36
37 if (!name.has_value())
38 {
39 EXPECT_EQ(GetVendorName(0xFFFE), "Unknown (0xFFFE)");
40 }
41}
std::optional< std::string > LookupVendor(std::uint16_t vendorId)
Look up a vendor name without a fallback string.
Definition vendors.cpp:15
TEST_F(AlarmListenerTests, InitializesWithEndpoint)
std::string GetVendorName(std::uint16_t vendorId)
Get the vendor name for a 16-bit PROFINET vendor ID.
Definition vendors.cpp:29
Declares PROFINET Vendor ID lookup utilities. The lookup table itself lives in vendors_data....