|
@@ -3,12 +3,13 @@
|
|
|
* Company: Lynar Studios
|
|
|
* E-Mail: webmaster@lynarstudios.com
|
|
|
* Created: 2020-08-14
|
|
|
- * Changed: 2020-08-21
|
|
|
+ * Changed: 2020-08-30
|
|
|
*
|
|
|
* */
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
#include "../../../source/boxing/String.hpp"
|
|
|
+#include "../../../source/serialization/boxing/SerializableJSONString.hpp"
|
|
|
|
|
|
namespace {
|
|
|
class StringTest : public ::testing::Test {
|
|
@@ -91,6 +92,19 @@ namespace {
|
|
|
|
|
|
// implementation
|
|
|
|
|
|
+ TEST_F(StringTest, marshal)
|
|
|
+ {
|
|
|
+ std::shared_ptr<ls_std::String> x = std::make_shared<ls_std::String>("Hello!");
|
|
|
+
|
|
|
+ auto serializable = std::make_shared<ls_std::SerializableJSONString>(x);
|
|
|
+ x->setSerializable(std::dynamic_pointer_cast<ls_std::ISerializable>(serializable));
|
|
|
+
|
|
|
+ ASSERT_STREQ(R"({"class":"String","value":"Hello!"})", x->marshal().c_str());
|
|
|
+
|
|
|
+ *x = "Test!";
|
|
|
+ ASSERT_STREQ(R"({"class":"String","value":"Test!"})", x->marshal().c_str());
|
|
|
+ }
|
|
|
+
|
|
|
TEST_F(StringTest, parse)
|
|
|
{
|
|
|
ls_std::String text {};
|
|
@@ -106,6 +120,19 @@ namespace {
|
|
|
ASSERT_STREQ("Hello!", text.toString().c_str());
|
|
|
}
|
|
|
|
|
|
+ TEST_F(StringTest, unmarshal)
|
|
|
+ {
|
|
|
+ std::shared_ptr<ls_std::String> x = std::make_shared<ls_std::String>("Hello!");
|
|
|
+ ASSERT_STREQ("Hello!", *x);
|
|
|
+
|
|
|
+ auto serializable = std::make_shared<ls_std::SerializableJSONString>(x);
|
|
|
+ x->setSerializable(std::dynamic_pointer_cast<ls_std::ISerializable>(serializable));
|
|
|
+
|
|
|
+ x->unmarshal(R"({"class":"String","value":"Test!"})");
|
|
|
+
|
|
|
+ ASSERT_STREQ("Test!", *x);
|
|
|
+ }
|
|
|
+
|
|
|
// additional functionality
|
|
|
|
|
|
TEST_F(StringTest, contains)
|