EntryExitSelfTransitionTest.cc 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 "EntryExitSelfTransition.h"
  14. #include "sc_types.h"
  15. EntryExitSelfTransition* statechart;
  16. class StatemachineTest : public ::testing::Test{
  17. protected:
  18. virtual void SetUp() {
  19. statechart = new EntryExitSelfTransition();
  20. statechart->init();
  21. }
  22. virtual void TearDown() {
  23. delete statechart;
  24. }
  25. };
  26. void init(){
  27. statechart->enter();
  28. statechart->runCycle();
  29. EXPECT_TRUE(statechart->getDefaultSCI()->get_entries()== 1l);
  30. EXPECT_TRUE(statechart->isStateActive(EntryExitSelfTransition::main_region_A__region0_B));
  31. statechart->getDefaultSCI()->set_entries(0l);
  32. }
  33. TEST_F(StatemachineTest, SelfTransitionToChildState) {
  34. init();
  35. statechart->raise_e();
  36. statechart->runCycle();
  37. EXPECT_TRUE(statechart->getDefaultSCI()->get_entries()== 1l);
  38. EXPECT_TRUE(statechart->getDefaultSCI()->get_exits()== 1l);
  39. EXPECT_TRUE(statechart->isStateActive(EntryExitSelfTransition::main_region_A__region0_C));
  40. }
  41. TEST_F(StatemachineTest, SelfTransitionFromChildState) {
  42. init();
  43. statechart->raise_e1();
  44. statechart->runCycle();
  45. EXPECT_TRUE(statechart->getDefaultSCI()->get_entries()== 0l);
  46. EXPECT_TRUE(statechart->getDefaultSCI()->get_exits()== 0l);
  47. EXPECT_TRUE(statechart->isStateActive(EntryExitSelfTransition::main_region_A__region0_C));
  48. statechart->raise_e1();
  49. statechart->runCycle();
  50. EXPECT_TRUE(statechart->isStateActive(EntryExitSelfTransition::main_region_A__region0_B));
  51. EXPECT_TRUE(statechart->getDefaultSCI()->get_entries()== 1l);
  52. EXPECT_TRUE(statechart->getDefaultSCI()->get_exits()== 1l);
  53. }