|
@@ -12,6 +12,7 @@
|
|
|
#include <ls-std/ls-std-io.hpp>
|
|
|
|
|
|
using namespace ls::std::core;
|
|
|
+using namespace ls::std::core::type;
|
|
|
using namespace ls::std::io;
|
|
|
using namespace ::std;
|
|
|
|
|
@@ -116,4 +117,84 @@ namespace
|
|
|
SectionPairRowListValue list{};
|
|
|
ASSERT_EQ(ls::std::io::SECTION_PAIR_ROW_LIST_VALUE, list.getType());
|
|
|
}
|
|
|
+
|
|
|
+ TEST_F(SectionPairRowListValueTest, marshal)
|
|
|
+ {
|
|
|
+ shared_ptr<SectionPairRowListValue> value = make_shared<SectionPairRowListValue>();
|
|
|
+ value->setSerializable(make_shared<SerializableSectionPairRowListValue>(value));
|
|
|
+ value->add("Drumming");
|
|
|
+ value->add("Reading");
|
|
|
+ value->add("Coding");
|
|
|
+
|
|
|
+ ::std::string expected = " Drumming" + NewLine::get() + " Reading" + NewLine::get() + " Coding" + NewLine::get();
|
|
|
+
|
|
|
+ ASSERT_STREQ(expected.c_str(), value->marshal().c_str());
|
|
|
+ }
|
|
|
+
|
|
|
+ TEST_F(SectionPairRowListValueTest, marshal_no_reference)
|
|
|
+ {
|
|
|
+ SectionPairRowListValue list{};
|
|
|
+
|
|
|
+ EXPECT_THROW(
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ byte_field data = list.marshal();
|
|
|
+ }
|
|
|
+ catch (const NullPointerException &_exception)
|
|
|
+ {
|
|
|
+ throw;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ NullPointerException);
|
|
|
+ }
|
|
|
+
|
|
|
+ TEST_F(SectionPairRowListValueTest, setSerializable_no_reference)
|
|
|
+ {
|
|
|
+ SectionPairRowListValue list{};
|
|
|
+
|
|
|
+ EXPECT_THROW(
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ list.setSerializable(nullptr);
|
|
|
+ }
|
|
|
+ catch (const IllegalArgumentException &_exception)
|
|
|
+ {
|
|
|
+ throw;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ IllegalArgumentException);
|
|
|
+ }
|
|
|
+
|
|
|
+ TEST_F(SectionPairRowListValueTest, unmarshal)
|
|
|
+ {
|
|
|
+ shared_ptr<SectionPairRowListValue> value = make_shared<SectionPairRowListValue>();
|
|
|
+ value->setSerializable(make_shared<SerializableSectionPairRowListValue>(value));
|
|
|
+ ::std::string serializedListValue = " Drumming" + NewLine::get() + " Reading" + NewLine::get() + " Coding" + NewLine::get();
|
|
|
+ value->unmarshal(serializedListValue);
|
|
|
+
|
|
|
+ ASSERT_EQ(3, value->getSize());
|
|
|
+ ASSERT_STREQ("Drumming", value->get(0).c_str());
|
|
|
+ ASSERT_STREQ("Reading", value->get(1).c_str());
|
|
|
+ ASSERT_STREQ("Coding", value->get(2).c_str());
|
|
|
+ }
|
|
|
+
|
|
|
+ TEST_F(SectionPairRowListValueTest, unmarshal_no_reference)
|
|
|
+ {
|
|
|
+ SectionPairRowListValue list{};
|
|
|
+
|
|
|
+ EXPECT_THROW(
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ list.unmarshal(" Blue\nYellow\n");
|
|
|
+ }
|
|
|
+ catch (const NullPointerException &_exception)
|
|
|
+ {
|
|
|
+ throw;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ NullPointerException);
|
|
|
+ }
|
|
|
}
|