ValuedEventsTest.cc 1.6 KB

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