| Alexander Hansen | 4aa58f5 | 2025-10-16 15:41:29 +0200 | [diff] [blame^] | 1 | #include "server/TestWithMethod/common.hpp" |
| 2 | |
| 3 | #include <print> |
| 4 | |
| 5 | #include <gtest/gtest.h> |
| 6 | |
| 7 | TEST(MethodNames, TestMethodNames) |
| 8 | { |
| 9 | // We can access the method name as a symbol. |
| 10 | // The property name is constexpr. |
| 11 | |
| 12 | constexpr auto methodName = |
| 13 | sdbusplus::common::server::TestWithMethod::method_names::update_value; |
| 14 | |
| 15 | // The method name can be used as part of error logs. |
| 16 | |
| 17 | std::println("error calling method {}\n", methodName); |
| 18 | |
| 19 | // If the method is removed from the interface definition, it will cause a |
| 20 | // build failure in applications still using that method. That can work |
| 21 | // even if the application is not (yet) using PDI-generated bindings for |
| 22 | // it's DBus interactions. |
| 23 | |
| 24 | std::println( |
| 25 | "using method {} \n", |
| 26 | sdbusplus::common::server::TestWithMethod::method_names::update_value); |
| 27 | |
| 28 | EXPECT_EQ( |
| 29 | sdbusplus::common::server::TestWithMethod::method_names::update_value, |
| 30 | "UpdateValue"); |
| 31 | } |