EntryReactionActionTest.cc 2.6 KB

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