SyncForkTest.cc 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 "SyncFork.h"
  14. #include "sc_types.h"
  15. static SyncFork* statechart;
  16. class StatemachineTest : public ::testing::Test{
  17. protected:
  18. virtual void SetUp() {
  19. statechart = new SyncFork();
  20. statechart->init();
  21. }
  22. virtual void TearDown() {
  23. delete statechart;
  24. }
  25. };
  26. TEST_F(StatemachineTest, syncForkTest) {
  27. statechart->enter();
  28. EXPECT_TRUE(statechart->isStateActive(SyncFork::main_region_A));
  29. statechart->getDefaultSCI()->raise_f();
  30. statechart->runCycle();;
  31. EXPECT_TRUE(statechart->isStateActive(SyncFork::main_region_B));
  32. EXPECT_TRUE(statechart->isStateActive(SyncFork::main_region_B_r1_C1));
  33. EXPECT_TRUE(statechart->isStateActive(SyncFork::main_region_B_r2_D1));
  34. statechart->getDefaultSCI()->raise_f();
  35. statechart->runCycle();;
  36. EXPECT_TRUE(statechart->isStateActive(SyncFork::main_region_B));
  37. EXPECT_TRUE(statechart->isStateActive(SyncFork::main_region_B_r1_C2));
  38. EXPECT_TRUE(statechart->isStateActive(SyncFork::main_region_B_r2_D2));
  39. statechart->getDefaultSCI()->raise_e();
  40. statechart->runCycle();;
  41. EXPECT_TRUE(statechart->isStateActive(SyncFork::main_region_A));
  42. statechart->getDefaultSCI()->raise_f();
  43. statechart->runCycle();;
  44. EXPECT_TRUE(statechart->isStateActive(SyncFork::main_region_B));
  45. EXPECT_TRUE(statechart->isStateActive(SyncFork::main_region_B_r1_C1));
  46. EXPECT_TRUE(statechart->isStateActive(SyncFork::main_region_B_r2_D1));
  47. }