ValuedEventsTest.cc 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 <string>
  12. #include "gtest/gtest.h"
  13. #include "ValuedEvents.h"
  14. #include "sc_types.h"
  15. static ValuedEvents* statechart;
  16. class StatemachineTest : public ::testing::Test{
  17. protected:
  18. virtual void SetUp() {
  19. statechart = new ValuedEvents();
  20. statechart->init();
  21. }
  22. virtual void TearDown() {
  23. delete statechart;
  24. }
  25. };
  26. TEST_F(StatemachineTest, valuedEventsTest) {
  27. statechart->enter();
  28. statechart->runCycle();;
  29. EXPECT_TRUE(strcmp(statechart->getDefaultSCI()->get_myString(), "sct") == 0);
  30. statechart->getDefaultSCI()->raise_integerEvent( 23l);
  31. statechart->getDefaultSCI()->raise_booleanEvent( false);
  32. statechart->getDefaultSCI()->raise_realEvent( 20l);
  33. statechart->getDefaultSCI()->raise_stringEvent( "tool");
  34. statechart->runCycle();;
  35. EXPECT_TRUE(statechart->isStateActive(ValuedEvents::integer_region_D));
  36. EXPECT_TRUE(statechart->isStateActive(ValuedEvents::string_region_D));
  37. EXPECT_TRUE(statechart->isStateActive(ValuedEvents::boolean_region_D));
  38. EXPECT_TRUE(statechart->isStateActive(ValuedEvents::real_region_D));
  39. EXPECT_TRUE(statechart->getDefaultSCI()->get_myInt()== 23l);
  40. EXPECT_TRUE(statechart->getDefaultSCI()->get_myBool()== false);
  41. EXPECT_TRUE(statechart->getDefaultSCI()->get_myReal()== 20l);
  42. EXPECT_TRUE(strcmp(statechart->getDefaultSCI()->get_myString(), "tool") == 0);
  43. }