refactor: improve and make more efficient some Message API (#432)

This commit is contained in:
Stanislav Angelovič
2024-04-24 20:20:29 +02:00
parent ef552ec089
commit 310161207a
9 changed files with 58 additions and 67 deletions
+2 -1
View File
@@ -44,6 +44,7 @@ using ::testing::ElementsAre;
using ::testing::Eq;
using namespace std::chrono_literals;
using namespace sdbus::test;
using namespace std::string_view_literals;
using ADirectConnection = TestFixtureWithDirectConnection;
@@ -157,7 +158,7 @@ TYPED_TEST(AConnection, WillNotPassToMatchCallbackMessagesThatDoNotMatchTheRule)
std::atomic<size_t> numberOfMatchingMessages{};
auto slot = this->s_proxyConnection->addMatch(matchRule, [&](sdbus::Message msg)
{
if(msg.getMemberName() == "simpleSignal")
if(msg.getMemberName() == "simpleSignal"sv)
numberOfMatchingMessages++;
});
auto adaptor2 = std::make_unique<TestAdaptor>(*this->s_adaptorConnection, OBJECT_PATH_2);
+10 -10
View File
@@ -32,8 +32,10 @@
#include <list>
using ::testing::Eq;
using ::testing::StrEq;
using ::testing::Gt;
using ::testing::DoubleEq;
using ::testing::IsNull;
using namespace std::string_literals;
namespace
@@ -465,11 +467,10 @@ TEST(AMessage, CanPeekASimpleType)
msg << 123;
msg.seal();
std::string type;
std::string contents;
msg.peekType(type, contents);
ASSERT_THAT(type, "i");
ASSERT_THAT(contents, "");
auto [type, contents] = msg.peekType();
ASSERT_THAT(type, Eq('i'));
ASSERT_THAT(contents, IsNull());
}
TEST(AMessage, CanPeekContainerContents)
@@ -478,11 +479,10 @@ TEST(AMessage, CanPeekContainerContents)
msg << std::map<int, std::string>{{1, "one"}, {2, "two"}};
msg.seal();
std::string type;
std::string contents;
msg.peekType(type, contents);
ASSERT_THAT(type, "a");
ASSERT_THAT(contents, "{is}");
auto [type, contents] = msg.peekType();
ASSERT_THAT(type, Eq('a'));
ASSERT_THAT(contents, StrEq("{is}"));
}
TEST(AMessage, CanCarryDBusArrayGivenAsCustomType)