Procházet zdrojové kódy

Extended State class

- added setter method for id member
- added tests for State class
Patrick-Laptop před 3 roky
rodič
revize
7b1ab7de68
3 změnil soubory, kde provedl 18 přidání a 3 odebrání
  1. 6 1
      source/logic/State.cpp
  2. 2 1
      source/logic/State.hpp
  3. 10 1
      test/cases/logic/StateTest.cpp

+ 6 - 1
source/logic/State.cpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-09-05
- * Changed:         2020-09-10
+ * Changed:         2020-09-14
  *
  * */
 
@@ -37,6 +37,11 @@ ls_std::StateId ls_std::State::getId()
   return this->id;
 }
 
+void ls_std::State::setId(StateId _id)
+{
+  this->id = std::move(_id);
+}
+
 bool ls_std::State::_stateIsConnected(const std::string &_id)
 {
   return this->connectedStates.find(_id) != this->connectedStates.end();

+ 2 - 1
source/logic/State.hpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-09-05
- * Changed:         2020-09-10
+ * Changed:         2020-09-14
  *
  * */
 
@@ -26,6 +26,7 @@ namespace ls_std {
       bool addStateConnection(const StateConnectionId& _connectionId, const std::shared_ptr<State>& _connectedState);
       std::unordered_map<StateConnectionId, std::shared_ptr<StateConnection>> getConnectedStates();
       StateId getId();
+      void setId(StateId _id);
 
     private:
 

+ 10 - 1
test/cases/logic/StateTest.cpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-09-05
- * Changed:         2020-09-10
+ * Changed:         2020-09-14
  *
  * */
 
@@ -63,4 +63,13 @@ namespace {
     ls_std::State stateA {"A"};
     ASSERT_STREQ("A", stateA.getId().c_str());
   }
+
+  TEST_F(StateTest, setId)
+  {
+    ls_std::State stateA {"A"};
+    ASSERT_STREQ("A", stateA.getId().c_str());
+
+    stateA.setId("B");
+    ASSERT_STREQ("B", stateA.getId().c_str());
+  }
 }