Jelajahi Sumber

Reduced JSON complexity in ls_std::Integer class

- reduced complexity of JSON serialization in ls_std::Integer class by skipping
ls_std::Class serialization part
- adjusted tests
pcmattulat 4 tahun lalu
induk
melakukan
4ff84b682f

+ 0 - 1
source/serialization/boxing/SerializableJSONInteger.cpp

@@ -33,7 +33,6 @@ void ls_std::SerializableJSONInteger::unmarshal(const ls_std::byte_field& _data)
 void ls_std::SerializableJSONInteger::_update()
 {
   this->jsonObject = {
-      {"class", this->value->getClassName()},
       {"value", this->value->getValue()}
   };
 }

+ 5 - 5
test/cases/boxing/IntegerTest.cpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-08-09
- * Changed:         2020-08-25
+ * Changed:         2020-09-04
  *
  * */
 
@@ -350,7 +350,7 @@ namespace {
     ls_std::File file {path};
     file.createNewFile();
     ls_std::FileWriter writer {file};
-    writer.write(R"({"class":"Integer","value":1990})");
+    writer.write(R"({"value":1990})");
 
     auto serializable = std::make_shared<ls_std::SerializableJSONInteger>(x);
     x->setSerializable(std::dynamic_pointer_cast<ls_std::ISerializable>(serializable));
@@ -373,10 +373,10 @@ namespace {
     auto serializable = std::make_shared<ls_std::SerializableJSONInteger>(x);
     x->setSerializable(std::dynamic_pointer_cast<ls_std::ISerializable>(serializable));
 
-    ASSERT_STREQ(R"({"class":"Integer","value":3})", x->marshal().c_str());
+    ASSERT_STREQ(R"({"value":3})", x->marshal().c_str());
 
     *x = 17;
-    ASSERT_STREQ(R"({"class":"Integer","value":17})", x->marshal().c_str());
+    ASSERT_STREQ(R"({"value":17})", x->marshal().c_str());
   }
 
   TEST_F(IntegerTest, parse)
@@ -404,7 +404,7 @@ namespace {
     auto serializable = std::make_shared<ls_std::SerializableJSONInteger>(x);
     x->setSerializable(std::dynamic_pointer_cast<ls_std::ISerializable>(serializable));
 
-    x->unmarshal(R"({"class":"Integer","value":1989})");
+    x->unmarshal(R"({"value":1989})");
 
     ASSERT_EQ(1989, *x);
   }

+ 3 - 3
test/cases/serialization/boxing/SerializableJSONIntegerTest.cpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-08-21
- * Changed:         2020-08-25
+ * Changed:         2020-09-04
  *
  * */
 
@@ -28,7 +28,7 @@ namespace {
     ls_std::SerializableJSONInteger serializable {std::make_shared<ls_std::Integer>(x)};
     ls_std::byte_field content = serializable.marshal();
 
-    ASSERT_STREQ(R"({"class":"Integer","value":3})", content.c_str());
+    ASSERT_STREQ(R"({"value":3})", content.c_str());
   }
 
   TEST_F(SerializableJSONIntegerTest, unmarshal)
@@ -37,7 +37,7 @@ namespace {
     ASSERT_EQ(13, *x);
 
     ls_std::SerializableJSONInteger serializable {x};
-    serializable.unmarshal(R"({"class":"Integer","value":1989})");
+    serializable.unmarshal(R"({"value":1989})");
 
     ASSERT_EQ(1989, *x);
   }