EntryReactionAction.cc 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /**
  2. * Copyright (c) 2016 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 "EntryReactionAction.h"
  14. EntryReactionAction handle;
  15. TEST(StatemachineTest, entryTransitionActionOnStatechartEnter) {
  16. entryReactionAction_init(&handle);
  17. entryReactionAction_enter(&handle);
  18. EXPECT_TRUE(entryReactionActionIface_get_enteredR1(&handle) );
  19. EXPECT_TRUE(entryReactionActionIface_get_enteredR2(&handle) );
  20. EXPECT_TRUE(entryReactionActionIface_get_enteredBdefault(&handle) );
  21. EXPECT_TRUE(!entryReactionActionIface_get_enteredBother(&handle) );
  22. }
  23. TEST(StatemachineTest, entryOnRTS) {
  24. entryReactionAction_init(&handle);
  25. entryReactionAction_enter(&handle);
  26. entryReactionActionIface_raise_b(&handle);
  27. entryReactionAction_runCycle(&handle);
  28. entryReactionActionIface_raise_d(&handle);
  29. entryReactionAction_runCycle(&handle);
  30. entryReactionActionIface_set_enteredR1(&handle, false);
  31. entryReactionActionIface_set_enteredR2(&handle, false);
  32. entryReactionActionIface_set_enteredBdefault(&handle, false);
  33. entryReactionActionIface_set_enteredBother(&handle, false);
  34. entryReactionActionIface_raise_b(&handle);
  35. entryReactionAction_runCycle(&handle);
  36. EXPECT_TRUE(!entryReactionActionIface_get_enteredR1(&handle) );
  37. EXPECT_TRUE(!entryReactionActionIface_get_enteredR2(&handle) );
  38. EXPECT_TRUE(!entryReactionActionIface_get_enteredBdefault(&handle) );
  39. EXPECT_TRUE(entryReactionActionIface_get_enteredBother(&handle) );
  40. }
  41. TEST(StatemachineTest, noEntryTransitionActionOnHistory) {
  42. entryReactionAction_init(&handle);
  43. entryReactionAction_enter(&handle);
  44. entryReactionActionIface_raise_b(&handle);
  45. entryReactionAction_runCycle(&handle);
  46. entryReactionActionIface_raise_d(&handle);
  47. entryReactionAction_runCycle(&handle);
  48. entryReactionActionIface_set_enteredR1(&handle, false);
  49. entryReactionActionIface_set_enteredR2(&handle, false);
  50. entryReactionActionIface_set_enteredBdefault(&handle, false);
  51. entryReactionActionIface_set_enteredBother(&handle, false);
  52. entryReactionActionIface_raise_d(&handle);
  53. entryReactionAction_runCycle(&handle);
  54. EXPECT_TRUE(!entryReactionActionIface_get_enteredR1(&handle) );
  55. EXPECT_TRUE(!entryReactionActionIface_get_enteredR2(&handle) );
  56. EXPECT_TRUE(!entryReactionActionIface_get_enteredBdefault(&handle) );
  57. EXPECT_TRUE(!entryReactionActionIface_get_enteredBother(&handle) );
  58. }