|
@@ -3,7 +3,7 @@
|
|
* Company: Lynar Studios
|
|
* Company: Lynar Studios
|
|
* E-Mail: webmaster@lynarstudios.com
|
|
* E-Mail: webmaster@lynarstudios.com
|
|
* Created: 2020-08-14
|
|
* Created: 2020-08-14
|
|
- * Changed: 2021-07-01
|
|
|
|
|
|
+ * Changed: 2021-07-12
|
|
*
|
|
*
|
|
* */
|
|
* */
|
|
|
|
|
|
@@ -26,24 +26,6 @@ namespace
|
|
|
|
|
|
void TearDown() override
|
|
void TearDown() override
|
|
{}
|
|
{}
|
|
-
|
|
|
|
- static std::pair<std::shared_ptr<ls_std::File>, std::shared_ptr<ls_std::Double>> createPersistentTestDouble()
|
|
|
|
- {
|
|
|
|
- std::shared_ptr<ls_std::Double> number = std::make_shared<ls_std::Double>();
|
|
|
|
- std::string path = TestHelper::getResourcesFolderLocation() + "tmp_storable_double.json";
|
|
|
|
- std::shared_ptr<ls_std::File> file = std::make_shared<ls_std::File>(path);
|
|
|
|
- file->createNewFile();
|
|
|
|
- ls_std::FileWriter writer{*file};
|
|
|
|
- writer.write(R"({"value":3.14159})");
|
|
|
|
-
|
|
|
|
- auto serializable = std::make_shared<ls_std::SerializableJsonDouble>(number);
|
|
|
|
- number->setSerializable(std::dynamic_pointer_cast<ls_std::ISerializable>(serializable));
|
|
|
|
-
|
|
|
|
- auto storable = std::make_shared<ls_std::StorableFile>(path);
|
|
|
|
- number->setStorable(std::dynamic_pointer_cast<ls_std::IStorable>(storable));
|
|
|
|
-
|
|
|
|
- return std::pair<std::shared_ptr<ls_std::File>, std::shared_ptr<ls_std::Double>>(file, number);
|
|
|
|
- }
|
|
|
|
};
|
|
};
|
|
|
|
|
|
// assignment operators
|
|
// assignment operators
|
|
@@ -314,31 +296,6 @@ namespace
|
|
|
|
|
|
// implementation
|
|
// implementation
|
|
|
|
|
|
- TEST_F(DoubleTest, load)
|
|
|
|
- {
|
|
|
|
- // preparation
|
|
|
|
-
|
|
|
|
- auto storableDouble = createPersistentTestDouble();
|
|
|
|
-
|
|
|
|
- // check
|
|
|
|
-
|
|
|
|
- storableDouble.second->load();
|
|
|
|
- ASSERT_DOUBLE_EQ(3.14159, *storableDouble.second);
|
|
|
|
-
|
|
|
|
- storableDouble.first->remove();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- TEST_F(DoubleTest, marshal)
|
|
|
|
- {
|
|
|
|
- std::shared_ptr<ls_std::Double> number = std::make_shared<ls_std::Double>(3.14159);
|
|
|
|
-
|
|
|
|
- auto serializable = std::make_shared<ls_std::SerializableJsonDouble>(number);
|
|
|
|
- number->setSerializable(std::dynamic_pointer_cast<ls_std::ISerializable>(serializable));
|
|
|
|
- ls_std::String jsonString{number->marshal()};
|
|
|
|
-
|
|
|
|
- ASSERT_TRUE(jsonString.contains(R"({"value":3.14159)"));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
TEST_F(DoubleTest, parse_with_positive_value)
|
|
TEST_F(DoubleTest, parse_with_positive_value)
|
|
{
|
|
{
|
|
ls_std::Double x{};
|
|
ls_std::Double x{};
|
|
@@ -361,17 +318,6 @@ namespace
|
|
ASSERT_TRUE(x.toString().find("13.1543") != std::string::npos);
|
|
ASSERT_TRUE(x.toString().find("13.1543") != std::string::npos);
|
|
}
|
|
}
|
|
|
|
|
|
- TEST_F(DoubleTest, unmarshal)
|
|
|
|
- {
|
|
|
|
- std::shared_ptr<ls_std::Double> number = std::make_shared<ls_std::Double>(3.14159);
|
|
|
|
-
|
|
|
|
- auto serializable = std::make_shared<ls_std::SerializableJsonDouble>(number);
|
|
|
|
- number->setSerializable(std::dynamic_pointer_cast<ls_std::ISerializable>(serializable));
|
|
|
|
- number->unmarshal(R"({"value":17.4132})");
|
|
|
|
-
|
|
|
|
- ASSERT_DOUBLE_EQ(17.4132, *number);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
// additional functionality
|
|
// additional functionality
|
|
|
|
|
|
TEST_F(DoubleTest, getEpsilon)
|
|
TEST_F(DoubleTest, getEpsilon)
|
|
@@ -409,36 +355,4 @@ namespace
|
|
}
|
|
}
|
|
}, ls_std::IllegalArgumentException);
|
|
}, ls_std::IllegalArgumentException);
|
|
}
|
|
}
|
|
-
|
|
|
|
- TEST_F(DoubleTest, setSerializable_no_reference)
|
|
|
|
- {
|
|
|
|
- ls_std::Double x{};
|
|
|
|
-
|
|
|
|
- EXPECT_THROW({
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- x.setSerializable(nullptr);
|
|
|
|
- }
|
|
|
|
- catch (const ls_std::IllegalArgumentException &_exception)
|
|
|
|
- {
|
|
|
|
- throw;
|
|
|
|
- }
|
|
|
|
- }, ls_std::IllegalArgumentException);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- TEST_F(DoubleTest, setStorable_no_reference)
|
|
|
|
- {
|
|
|
|
- ls_std::Double x{};
|
|
|
|
-
|
|
|
|
- EXPECT_THROW({
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- x.setStorable(nullptr);
|
|
|
|
- }
|
|
|
|
- catch (const ls_std::IllegalArgumentException &_exception)
|
|
|
|
- {
|
|
|
|
- throw;
|
|
|
|
- }
|
|
|
|
- }, ls_std::IllegalArgumentException);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|