Guard.cc 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /**
  2. * Copyright (c) 2013 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 "Guard.h"
  14. TEST(StatemachineTest, guardTest) {
  15. Guard handle;
  16. guard_init(&handle);
  17. guard_enter(&handle);
  18. EXPECT_TRUE(guard_isActive(&handle, Guard_main_region_A));
  19. guardIface_raise_event1(&handle);
  20. guard_runCycle(&handle);
  21. EXPECT_TRUE(guard_isActive(&handle, Guard_main_region_A));
  22. guardIface_raise_event2(&handle);
  23. guard_runCycle(&handle);
  24. EXPECT_TRUE(guard_isActive(&handle, Guard_main_region_B));
  25. guardIface_raise_return(&handle);
  26. guard_runCycle(&handle);
  27. EXPECT_TRUE(guard_isActive(&handle, Guard_main_region_A));
  28. guardIface_raise_event1(&handle);
  29. guard_runCycle(&handle);
  30. EXPECT_TRUE(guard_isActive(&handle, Guard_main_region_B));
  31. guardIface_raise_return(&handle);
  32. guard_runCycle(&handle);
  33. EXPECT_TRUE(guard_isActive(&handle, Guard_main_region_A));
  34. }