OutEventLifeCycleTest.cc 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 "OutEventLifeCycle.h"
  13. OutEventLifeCycle handle;
  14. class StatemachineTest : public ::testing::Test{
  15. protected:
  16. virtual void SetUp() {
  17. outEventLifeCycle_init(&handle);
  18. }
  19. };
  20. void init(bool sndCycle){
  21. outEventLifeCycle_enter(&handle);
  22. outEventLifeCycleIface_raise_e(&handle);
  23. outEventLifeCycle_runCycle(&handle);
  24. if (sndCycle) {
  25. outEventLifeCycle_runCycle(&handle);
  26. }
  27. }
  28. TEST_F(StatemachineTest, availableAfterCycle) {
  29. outEventLifeCycle_enter(&handle);
  30. outEventLifeCycleIface_raise_e(&handle);
  31. outEventLifeCycle_runCycle(&handle);
  32. EXPECT_TRUE(outEventLifeCycleIface_israised_f(&handle));
  33. }
  34. TEST_F(StatemachineTest, availableWithinCycle) {
  35. init(false);
  36. EXPECT_TRUE(outEventLifeCycleIface_get_f_available_in_cycle(&handle));
  37. }
  38. TEST_F(StatemachineTest, unvailableWithin2ndCycle) {
  39. init(true);
  40. EXPECT_TRUE(!outEventLifeCycleIface_get_f_available_in_next_cycle(&handle));
  41. }
  42. TEST_F(StatemachineTest, unvailableAfter2ndCycle) {
  43. init(true);
  44. EXPECT_TRUE(!outEventLifeCycleIface_israised_f(&handle));
  45. }