SyncForkTest.cc 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 "SyncFork.h"
  13. SyncFork handle;
  14. class StatemachineTest : public ::testing::Test{
  15. protected:
  16. virtual void SetUp() {
  17. syncFork_init(&handle);
  18. }
  19. };
  20. TEST_F(StatemachineTest, syncForkTest) {
  21. syncFork_enter(&handle);
  22. EXPECT_TRUE(syncFork_isStateActive(&handle, SyncFork_main_region_A));
  23. syncForkIface_raise_f(&handle);
  24. syncFork_runCycle(&handle);
  25. EXPECT_TRUE(syncFork_isStateActive(&handle, SyncFork_main_region_B));
  26. EXPECT_TRUE(syncFork_isStateActive(&handle, SyncFork_main_region_B_r1_C1));
  27. EXPECT_TRUE(syncFork_isStateActive(&handle, SyncFork_main_region_B_r2_D1));
  28. syncForkIface_raise_f(&handle);
  29. syncFork_runCycle(&handle);
  30. EXPECT_TRUE(syncFork_isStateActive(&handle, SyncFork_main_region_B));
  31. EXPECT_TRUE(syncFork_isStateActive(&handle, SyncFork_main_region_B_r1_C2));
  32. EXPECT_TRUE(syncFork_isStateActive(&handle, SyncFork_main_region_B_r2_D2));
  33. syncForkIface_raise_e(&handle);
  34. syncFork_runCycle(&handle);
  35. EXPECT_TRUE(syncFork_isStateActive(&handle, SyncFork_main_region_A));
  36. syncForkIface_raise_f(&handle);
  37. syncFork_runCycle(&handle);
  38. EXPECT_TRUE(syncFork_isStateActive(&handle, SyncFork_main_region_B));
  39. EXPECT_TRUE(syncFork_isStateActive(&handle, SyncFork_main_region_B_r1_C1));
  40. EXPECT_TRUE(syncFork_isStateActive(&handle, SyncFork_main_region_B_r2_D1));
  41. }