ソースを参照

Reduced JSON complexity in ls_std::Long class

- reduced complexity of JSON serialization in ls_std::Long class by skipping
ls_std::Class serialization part
- adjusted tests
pcmattulat 4 年 前
コミット
7c52776acc

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

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

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

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

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

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