ValuedEventsTest.cc 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 "ValuedEvents.h"
  13. static ValuedEvents statechart;
  14. class StatemachineTest : public ::testing::Test{
  15. protected:
  16. virtual void SetUp() {
  17. valuedEvents_init(&statechart);
  18. }
  19. };
  20. TEST_F(StatemachineTest, valuedEventsTest) {
  21. valuedEvents_enter(&statechart);
  22. valuedEvents_runCycle(&statechart);
  23. EXPECT_TRUE(strcmp(valuedEventsIface_get_myString(&statechart), "sct") == 0);
  24. valuedEventsIface_raise_integerEvent(&statechart, 23l);
  25. valuedEventsIface_raise_booleanEvent(&statechart, false);
  26. valuedEventsIface_raise_realEvent(&statechart, 20l);
  27. valuedEventsIface_raise_stringEvent(&statechart, "tool");
  28. valuedEvents_runCycle(&statechart);
  29. EXPECT_TRUE(valuedEvents_isStateActive(&statechart, ValuedEvents_integer_region_D));
  30. EXPECT_TRUE(valuedEvents_isStateActive(&statechart, ValuedEvents_string_region_D));
  31. EXPECT_TRUE(valuedEvents_isStateActive(&statechart, ValuedEvents_boolean_region_D));
  32. EXPECT_TRUE(valuedEvents_isStateActive(&statechart, ValuedEvents_real_region_D));
  33. EXPECT_TRUE(valuedEventsIface_get_myInt(&statechart)== 23l);
  34. EXPECT_TRUE(valuedEventsIface_get_myBool(&statechart)== false);
  35. EXPECT_TRUE(valuedEventsIface_get_myReal(&statechart)== 20l);
  36. EXPECT_TRUE(strcmp(valuedEventsIface_get_myString(&statechart), "tool") == 0);
  37. }