ConstantsTests.cc 1.6 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 "Constants.h"
  14. #include "sc_types.h"
  15. static Constants* statechart;
  16. class StatemachineTest : public ::testing::Test{
  17. protected:
  18. virtual void SetUp() {
  19. statechart = new Constants();
  20. statechart->init();
  21. }
  22. virtual void TearDown() {
  23. delete statechart;
  24. }
  25. };
  26. TEST_F(StatemachineTest, constantDefinition) {
  27. statechart->enter();
  28. EXPECT_TRUE(statechart->isStateActive(Constants::main_region_A));
  29. EXPECT_TRUE(statechart->getDefaultSCI()->get_x()== 10l);
  30. EXPECT_TRUE(statechart->getDefaultSCI()->get_y()== 20l);
  31. EXPECT_TRUE(strcmp(statechart->getSCI_Named()->get_y(), "Hello World") == 0);
  32. statechart->getDefaultSCI()->raise_e();
  33. statechart->runCycle();;
  34. EXPECT_TRUE(statechart->getDefaultSCI()->get_result()== 20l);
  35. statechart->getDefaultSCI()->raise_e();
  36. statechart->runCycle();;
  37. EXPECT_TRUE(statechart->isStateActive(Constants::main_region_C));
  38. EXPECT_TRUE(statechart->getDefaultSCI()->get_result()== 100l);
  39. statechart->getDefaultSCI()->raise_e2( statechart->getDefaultSCI()->get_x());
  40. statechart->runCycle();;
  41. EXPECT_TRUE(statechart->getDefaultSCI()->get_result()== 1000l);
  42. EXPECT_TRUE(statechart->isStateActive(Constants::main_region_A));
  43. }