|
@@ -3,7 +3,7 @@
|
|
|
* Company: Lynar Studios
|
|
|
* E-Mail: webmaster@lynarstudios.com
|
|
|
* Created: 2020-09-15
|
|
|
- * Changed: 2020-09-15
|
|
|
+ * Changed: 2020-09-19
|
|
|
*
|
|
|
* */
|
|
|
|
|
@@ -58,4 +58,25 @@ namespace {
|
|
|
ASSERT_FALSE(x->getConnectedStates().at("AB")->isPassable());
|
|
|
ASSERT_STREQ("B", x->getConnectedStates().at("AB")->getStateId().c_str());
|
|
|
}
|
|
|
+
|
|
|
+ TEST_F(SerializableJSONStateTest, setValue)
|
|
|
+ {
|
|
|
+ std::shared_ptr<ls_std::State> x = std::make_shared<ls_std::State>("A");
|
|
|
+ x->addStateConnection(std::make_shared<ls_std::StateConnection>("AB", "B"));
|
|
|
+ x->addStateConnection(std::make_shared<ls_std::StateConnection>("AC", "C"));
|
|
|
+
|
|
|
+ ls_std::SerializableJSONState serializable {x};
|
|
|
+ ls_std::byte_field jsonString = serializable.marshal();
|
|
|
+
|
|
|
+ std::string expectedJSONString = R"({"connectedStates":{"AB":{"condition":false,"connectionId":"AB","stateId":"B"},"AC":{"condition":false,"connectionId":"AC","stateId":"C"}},"id":"A"})";
|
|
|
+ ASSERT_STREQ(expectedJSONString.c_str(), jsonString.c_str());
|
|
|
+
|
|
|
+ // setValue should now clear json
|
|
|
+
|
|
|
+ std::shared_ptr<ls_std::State> y = std::make_shared<ls_std::State>("B");
|
|
|
+ serializable.setValue(y);
|
|
|
+ jsonString = serializable.marshal();
|
|
|
+
|
|
|
+ ASSERT_STREQ(R"({"id":"B"})", jsonString.c_str());
|
|
|
+ }
|
|
|
}
|