EntryReactionActionTest.cc 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 "EntryReactionAction.h"
  13. static EntryReactionAction statechart;
  14. class StatemachineTest : public ::testing::Test{
  15. protected:
  16. virtual void SetUp() {
  17. entryReactionAction_init(&statechart);
  18. }
  19. };
  20. void init(){
  21. entryReactionAction_enter(&statechart);
  22. entryReactionActionIface_raise_b(&statechart);
  23. entryReactionAction_runCycle(&statechart);
  24. entryReactionActionIface_raise_d(&statechart);
  25. entryReactionAction_runCycle(&statechart);
  26. entryReactionActionIface_set_enteredR1(&statechart,false);
  27. entryReactionActionIface_set_enteredR2(&statechart,false);
  28. entryReactionActionIface_set_enteredBdefault(&statechart,false);
  29. entryReactionActionIface_set_enteredBother(&statechart,false);
  30. }
  31. TEST_F(StatemachineTest, entryTransitionActionOnStatechartEnter) {
  32. entryReactionAction_enter(&statechart);
  33. EXPECT_TRUE(entryReactionActionIface_get_enteredR1(&statechart));
  34. EXPECT_TRUE(entryReactionActionIface_get_enteredR2(&statechart));
  35. EXPECT_TRUE(entryReactionActionIface_get_enteredBdefault(&statechart));
  36. EXPECT_TRUE(!entryReactionActionIface_get_enteredBother(&statechart));
  37. }
  38. TEST_F(StatemachineTest, entryOnRTS) {
  39. init();
  40. entryReactionActionIface_raise_b(&statechart);
  41. entryReactionAction_runCycle(&statechart);
  42. EXPECT_TRUE(!entryReactionActionIface_get_enteredR1(&statechart));
  43. EXPECT_TRUE(!entryReactionActionIface_get_enteredR2(&statechart));
  44. EXPECT_TRUE(!entryReactionActionIface_get_enteredBdefault(&statechart));
  45. EXPECT_TRUE(entryReactionActionIface_get_enteredBother(&statechart));
  46. }
  47. TEST_F(StatemachineTest, noEntryTransitionActionOnHistory) {
  48. init();
  49. entryReactionActionIface_raise_d(&statechart);
  50. entryReactionAction_runCycle(&statechart);
  51. EXPECT_TRUE(!entryReactionActionIface_get_enteredR1(&statechart));
  52. EXPECT_TRUE(!entryReactionActionIface_get_enteredR2(&statechart));
  53. EXPECT_TRUE(!entryReactionActionIface_get_enteredBdefault(&statechart));
  54. EXPECT_TRUE(!entryReactionActionIface_get_enteredBother(&statechart));
  55. }