ReadOnlyVariableTest.cc 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /**
  2. * Copyright (c) 2016 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 "ReadOnlyVariable.h"
  14. TEST(StatemachineTest, ReadOnlyVariableTest) {
  15. ReadOnlyVariable* statechart = new ReadOnlyVariable();
  16. statechart->init();
  17. statechart->enter();
  18. EXPECT_TRUE(statechart->isStateActive(ReadOnlyVariable::main_region_StateA));
  19. EXPECT_TRUE(statechart->getDefaultSCI()->get_myInt()== 0l);
  20. EXPECT_TRUE(strcmp(statechart->getDefaultSCI()->get_myString(), "testString") == 0);
  21. EXPECT_TRUE(statechart->getDefaultSCI()->get_myBool()== true);
  22. EXPECT_TRUE(statechart->getDefaultSCI()->get_myReal()== 1.1);
  23. EXPECT_TRUE(statechart->getSCI_A()->get_myInt()== 0l);
  24. EXPECT_TRUE(strcmp(statechart->getSCI_A()->get_myString(), "testString") == 0);
  25. EXPECT_TRUE(statechart->getSCI_A()->get_myBool()== true);
  26. EXPECT_TRUE(statechart->getSCI_A()->get_myReal()== 1.1);
  27. statechart->runCycle();
  28. EXPECT_TRUE(statechart->isStateActive(ReadOnlyVariable::main_region_StateB));
  29. EXPECT_TRUE(statechart->getDefaultSCI()->get_myInt()== 100l);
  30. EXPECT_TRUE(strcmp(statechart->getDefaultSCI()->get_myString(), "fail") == 0);
  31. EXPECT_TRUE(statechart->getDefaultSCI()->get_myBool()== false);
  32. EXPECT_TRUE(statechart->getDefaultSCI()->get_myReal()== 6.6);
  33. EXPECT_TRUE(statechart->getSCI_A()->get_myInt()== 200l);
  34. EXPECT_TRUE(strcmp(statechart->getSCI_A()->get_myString(), "A_fail") == 0);
  35. EXPECT_TRUE(statechart->getSCI_A()->get_myBool()== false);
  36. EXPECT_TRUE(statechart->getSCI_A()->get_myReal()== 7.7);
  37. delete statechart;
  38. }