EnterStateTest.cc 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**
  2. * Copyright (c) 2017 committers of YAKINDU and others.
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * http://www.eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors:
  9. * committers of YAKINDU - initial API and implementation
  10. */
  11. #include <string>
  12. #include "gtest/gtest.h"
  13. #include "EnterState.h"
  14. #include "sc_types.h"
  15. static EnterState* statechart;
  16. class StatemachineTest : public ::testing::Test{
  17. protected:
  18. virtual void SetUp() {
  19. statechart = new EnterState();
  20. statechart->init();
  21. }
  22. virtual void TearDown() {
  23. delete statechart;
  24. }
  25. };
  26. TEST_F(StatemachineTest, defaultEntry) {
  27. statechart->enter();
  28. EXPECT_TRUE(statechart->isStateActive(EnterState::r_A));
  29. statechart->getDefaultSCI()->raise_e();
  30. statechart->runCycle();;
  31. EXPECT_TRUE(statechart->isStateActive(EnterState::r_B_r_E));
  32. }
  33. TEST_F(StatemachineTest, namedEntryThroughNamedTransition) {
  34. statechart->enter();
  35. EXPECT_TRUE(statechart->isStateActive(EnterState::r_A));
  36. statechart->getDefaultSCI()->raise_f();
  37. statechart->runCycle();;
  38. EXPECT_TRUE(statechart->isStateActive(EnterState::r_B_r_F));
  39. }
  40. TEST_F(StatemachineTest, namedEntryThroughDefaultTransition) {
  41. statechart->enter();
  42. EXPECT_TRUE(statechart->isStateActive(EnterState::r_A));
  43. statechart->getDefaultSCI()->raise_g();
  44. statechart->runCycle();;
  45. EXPECT_TRUE(statechart->isStateActive(EnterState::r_B_r_E));
  46. }