1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- /*
- * Author: Patrick-Christopher Mattulat
- * Company: Lynar Studios
- * E-Mail: webmaster@lynarstudios.com
- * Created: 2020-09-05
- * Changed: 2020-09-05
- *
- * */
- #include <gtest/gtest.h>
- #include <memory>
- #include "../../../source/logic/State.hpp"
- namespace {
- class StateTest : public ::testing::Test {
- protected:
- StateTest() = default;
- ~StateTest() override = default;
- void SetUp() override {}
- void TearDown() override {}
- };
- TEST_F(StateTest, addStateConnection)
- {
- ls_std::State stateA {"A"};
- ls_std::State stateB {"B"};
- ASSERT_TRUE(stateA.addStateConnection(std::make_shared<ls_std::State>(stateB)));
- }
- TEST_F(StateTest, addStateConnectionNegative)
- {
- ls_std::State stateA {"A"};
- ls_std::State stateB {"B"};
- ASSERT_TRUE(stateA.addStateConnection(std::make_shared<ls_std::State>(stateB)));
- ASSERT_FALSE(stateA.addStateConnection(std::make_shared<ls_std::State>(stateB)));
- ASSERT_FALSE(stateA.addStateConnection(nullptr));
- }
- TEST_F(StateTest, getConnectedStates)
- {
- ls_std::State stateA {"A"};
- ls_std::State stateB {"B"};
- ASSERT_TRUE(stateA.addStateConnection(std::make_shared<ls_std::State>(stateB)));
- ASSERT_FALSE(stateA.getConnectedStates().empty());
- ASSERT_EQ(1, stateA.getConnectedStates().size());
- }
- TEST_F(StateTest, getConnectedStatesNegative)
- {
- ls_std::State stateA {"A"};
- ASSERT_TRUE(stateA.getConnectedStates().empty());
- ASSERT_EQ(0, stateA.getConnectedStates().size());
- }
- TEST_F(StateTest, getId)
- {
- ls_std::State stateA {"A"};
- ASSERT_STREQ("A", stateA.getId().c_str());
- }
- TEST_F(StateTest, isAccessible)
- {
- ls_std::State stateA {"A"};
- ASSERT_FALSE(stateA.isAccessible());
- }
- TEST_F(StateTest, removeStateConnection)
- {
- ls_std::State stateA {"A"};
- ls_std::State stateB {"B"};
- ASSERT_TRUE(stateA.addStateConnection(std::make_shared<ls_std::State>(stateB)));
- ASSERT_FALSE(stateA.getConnectedStates().empty());
- ASSERT_EQ(1, stateA.getConnectedStates().size());
- stateA.removeStateConnection("B");
- ASSERT_TRUE(stateA.getConnectedStates().empty());
- ASSERT_EQ(0, stateA.getConnectedStates().size());
- }
- TEST_F(StateTest, updateAccessCondition)
- {
- ls_std::State stateA {"A"};
- ASSERT_FALSE(stateA.isAccessible());
- stateA.updateAccessCondition(true);
- ASSERT_TRUE(stateA.isAccessible());
- }
- }
|