OutEventLifeCycleTest.cc 1.5 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 "OutEventLifeCycle.h"
  14. #include "sc_types.h"
  15. static OutEventLifeCycle* statechart;
  16. class StatemachineTest : public ::testing::Test{
  17. protected:
  18. virtual void SetUp() {
  19. statechart = new OutEventLifeCycle();
  20. statechart->init();
  21. }
  22. virtual void TearDown() {
  23. delete statechart;
  24. }
  25. };
  26. void init(bool sndCycle){
  27. statechart->enter();
  28. statechart->getDefaultSCI()->raise_e();
  29. statechart->runCycle();;
  30. if (sndCycle) {
  31. statechart->runCycle();;
  32. }
  33. }
  34. TEST_F(StatemachineTest, availableAfterCycle) {
  35. statechart->enter();
  36. statechart->getDefaultSCI()->raise_e();
  37. statechart->runCycle();;
  38. EXPECT_TRUE(statechart->getDefaultSCI()->isRaised_f());
  39. }
  40. TEST_F(StatemachineTest, availableWithinCycle) {
  41. init(false);
  42. EXPECT_TRUE(statechart->getDefaultSCI()->get_f_available_in_cycle());
  43. }
  44. TEST_F(StatemachineTest, unvailableWithin2ndCycle) {
  45. init(true);
  46. EXPECT_TRUE(!statechart->getDefaultSCI()->get_f_available_in_next_cycle());
  47. }
  48. TEST_F(StatemachineTest, unvailableAfter2ndCycle) {
  49. init(true);
  50. EXPECT_TRUE(!statechart->getDefaultSCI()->isRaised_f());
  51. }