InternalEventLifeCycleTest.cc 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 "gtest/gtest.h"
  12. #include "InternalEventLifeCycle.h"
  13. static InternalEventLifeCycle statechart;
  14. class StatemachineTest : public ::testing::Test{
  15. protected:
  16. virtual void SetUp() {
  17. internalEventLifeCycle_init(&statechart);
  18. }
  19. };
  20. TEST_F(StatemachineTest, InternalEventLifeCycleTest) {
  21. internalEventLifeCycle_enter(&statechart);
  22. EXPECT_TRUE(internalEventLifeCycle_isStateActive(&statechart, InternalEventLifeCycle_r1_A));
  23. EXPECT_TRUE(internalEventLifeCycle_isStateActive(&statechart, InternalEventLifeCycle_r2_C));
  24. internalEventLifeCycleIface_raise_e(&statechart);
  25. internalEventLifeCycle_runCycle(&statechart);
  26. EXPECT_TRUE(internalEventLifeCycle_isStateActive(&statechart, InternalEventLifeCycle_r1_A));
  27. EXPECT_TRUE(internalEventLifeCycle_isStateActive(&statechart, InternalEventLifeCycle_r2_D));
  28. internalEventLifeCycle_runCycle(&statechart);
  29. EXPECT_TRUE(internalEventLifeCycle_isStateActive(&statechart, InternalEventLifeCycle_r1_A));
  30. EXPECT_TRUE(internalEventLifeCycle_isStateActive(&statechart, InternalEventLifeCycle_r2_D));
  31. internalEventLifeCycleIface_raise_f(&statechart);
  32. internalEventLifeCycle_runCycle(&statechart);
  33. EXPECT_TRUE(internalEventLifeCycle_isStateActive(&statechart, InternalEventLifeCycle_r1_A));
  34. EXPECT_TRUE(internalEventLifeCycle_isStateActive(&statechart, InternalEventLifeCycle_r2_C));
  35. internalEventLifeCycle_runCycle(&statechart);
  36. EXPECT_TRUE(internalEventLifeCycle_isStateActive(&statechart, InternalEventLifeCycle_r1_A));
  37. EXPECT_TRUE(internalEventLifeCycle_isStateActive(&statechart, InternalEventLifeCycle_r2_C));
  38. }