30 lines
1,020 B
C++
30 lines
1,020 B
C++
#include <gtest/gtest.h>
|
|
|
|
#include <larra/roster.hpp>
|
|
#include <ranges>
|
|
|
|
#include "larra/jid.hpp"
|
|
|
|
namespace larra::xmpp {
|
|
|
|
TEST(Roster, SerializeAndParse) {
|
|
FullJid jid{.username = "test", .server = "server", .resource = "res"}; // NOLINT
|
|
auto roster = iq::MakeGetRoster(jid);
|
|
roster.payload.items.emplace_back("u1", "s1");
|
|
roster.payload.items.emplace_back("u2", "s2");
|
|
roster.payload.items.emplace_back("u3", "s3");
|
|
|
|
using S = Serialization<iq::GetRoster>;
|
|
xmlpp::Document doc;
|
|
auto node = doc.create_root_node("iq");
|
|
node << roster;
|
|
auto parse_res = iq::Roster::Parse(node);
|
|
|
|
ASSERT_EQ(roster.payload.items.size(), parse_res.items.size());
|
|
for(const auto& [idx, expect_el, parsed_el] : std::views::zip(std::views::iota(0), roster.payload.items, parse_res.items)) {
|
|
EXPECT_EQ(expect_el, parsed_el) << "Mismatched on idx: " << idx;
|
|
// std::cerr << " " << "idx: " << idx << "; expect_el: " << expect_el << "; parsed_el: " << parsed_el << '\n';
|
|
}
|
|
}
|
|
|
|
} // namespace larra::xmpp
|