test: add integration tests for std::variant (#427)

This also introduces `always_false` technique instead of `sizeof` trick for unsupported D-Bus type representation static assert. This one is more expressive and leads to more specific, more revealing compiler error messages.
This commit is contained in:
Stanislav Angelovič
2024-04-02 16:44:45 +02:00
committed by GitHub
parent a73eb9b8c1
commit b9088cc801
6 changed files with 26 additions and 9 deletions
@@ -98,6 +98,13 @@ TEST_F(SdbusTestObject, CallsMethodWithVariantSuccesfully)
ASSERT_THAT(variantRes.get<int32_t>(), Eq(static_cast<int32_t>(DOUBLE_VALUE)));
}
TEST_F(SdbusTestObject, CallsMethodWithStdVariantSuccesfully)
{
std::variant<int32_t, double, std::string> v{DOUBLE_VALUE};
auto variantRes = m_proxy->processVariant(v);
ASSERT_THAT(std::get<int32_t>(variantRes), Eq(static_cast<int32_t>(DOUBLE_VALUE)));
}
TEST_F(SdbusTestObject, CallsMethodWithStructVariantsAndGetMapSuccesfully)
{
std::vector<int32_t> x{-2, 0, 2};