43 lines
1.1 KiB
C++
43 lines
1.1 KiB
C++
|
#include <gtest/gtest.h>
|
||
|
|
||
|
#include <larra/serialization/auto.hpp>
|
||
|
#include <larra/xml_language.hpp>
|
||
|
|
||
|
namespace larra::xmpp {
|
||
|
|
||
|
namespace tests::message {
|
||
|
|
||
|
struct SomeStruct {
|
||
|
static constexpr auto kDefaultName = "some";
|
||
|
XmlLanguage language;
|
||
|
friend auto operator<<(xmlpp::Element*, const SomeStruct&) -> void;
|
||
|
static auto Parse(xmlpp::Element* node) -> SomeStruct;
|
||
|
};
|
||
|
|
||
|
} // namespace tests::message
|
||
|
template <>
|
||
|
constexpr auto serialization::kSerializationConfig<tests::message::SomeStruct> =
|
||
|
serialization::SerializationConfig<tests::message::SomeStruct>{};
|
||
|
|
||
|
namespace tests::message {
|
||
|
|
||
|
auto SomeStruct::Parse(xmlpp::Element* element) -> SomeStruct {
|
||
|
return serialization::Parse<SomeStruct>(element);
|
||
|
}
|
||
|
|
||
|
auto operator<<(xmlpp::Element* element, const SomeStruct& some) -> void {
|
||
|
serialization::Serialize(element, some);
|
||
|
};
|
||
|
|
||
|
} // namespace tests::message
|
||
|
|
||
|
TEST(Parse, XmlLanguage) {
|
||
|
xmlpp::Document doc;
|
||
|
auto node = doc.create_root_node("some");
|
||
|
node->set_attribute("lang", "en", "xml");
|
||
|
auto value = Serialization<tests::message::SomeStruct>::Parse(node);
|
||
|
EXPECT_EQ(value.language, "en");
|
||
|
}
|
||
|
|
||
|
} // namespace larra::xmpp
|