GuardedExitTest.cc 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 "GuardedExit.h"
  13. GuardedExit handle;
  14. class StatemachineTest : public ::testing::Test{
  15. protected:
  16. virtual void SetUp() {
  17. guardedExit_init(&handle);
  18. }
  19. };
  20. void checkDone(bool shouldBeDone){
  21. guardedExitIface_raise_e(&handle);
  22. guardedExit_runCycle(&handle);
  23. EXPECT_TRUE(guardedExit_isStateActive(&handle, GuardedExit_main_region_B));
  24. EXPECT_TRUE(shouldBeDone ? guardedExitIface_get_done(&handle) : !guardedExitIface_get_done(&handle));
  25. }
  26. TEST_F(StatemachineTest, ExitTaken) {
  27. guardedExit_enter(&handle);
  28. EXPECT_TRUE(guardedExit_isStateActive(&handle, GuardedExit_main_region_A));
  29. EXPECT_TRUE(!guardedExitIface_get_guard(&handle));
  30. checkDone(false);
  31. }
  32. TEST_F(StatemachineTest, ExitNotTaken) {
  33. guardedExit_enter(&handle);
  34. EXPECT_TRUE(guardedExit_isStateActive(&handle, GuardedExit_main_region_A));
  35. guardedExitIface_set_guard(&handle,true);
  36. checkDone(true);
  37. }