28 lines
1,003 B
C++
28 lines
1,003 B
C++
#include <gtest/gtest.h>
|
|
|
|
#include <larra/serialization.hpp>
|
|
#include <larra/stream_error.hpp>
|
|
|
|
namespace larra::xmpp {
|
|
|
|
TEST(Parse, Variant) {
|
|
xmlpp::Document doc;
|
|
auto node = doc.create_root_node("stream:error");
|
|
node->add_child_element("unsupported-stanza-type");
|
|
node->set_namespace_declaration("urn:ietf:params:xml:ns:xmpp-streams");
|
|
auto streamError = Serialization<StreamError>::Parse(node);
|
|
EXPECT_TRUE(std::get_if<error::stream::UnsupportedStanzaType>(&streamError));
|
|
}
|
|
|
|
TEST(Serialize, Variant) {
|
|
using S = Serialization<StreamError>;
|
|
StreamError data = error::stream::UnsupportedStanzaType{};
|
|
xmlpp::Document doc;
|
|
auto node = doc.create_root_node("stream:error");
|
|
S::Serialize(node, data);
|
|
EXPECT_EQ(doc.write_to_string(),
|
|
std::string_view{"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<stream:error><unsupported-stanza-type "
|
|
"xmlns=\"urn:ietf:params:xml:ns:xmpp-streams\"/></stream:error>\n"});
|
|
}
|
|
|
|
} // namespace larra::xmpp
|