PerformanceTestsTest.cc 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /**
  2. * Copyright (c) 2013 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 "PerformanceTest.hpp"
  14. TEST(StatemachineTest, test_100_000) {
  15. PerformanceTest* statechart = new PerformanceTest();
  16. statechart->init();
  17. statechart->enter();
  18. EXPECT_TRUE(statechart->isActive(PerformanceTest_mr_A));
  19. while (statechart->getSCInterface().get_c()< 100000) {
  20. if (isActive(PerformanceTest_mr_A)) {
  21. statechart->raise_e1();
  22. }
  23. else {
  24. if (getSCInterface().get_c()%2== 0) {
  25. statechart->raise_e2();
  26. }
  27. else {
  28. statechart->raise_e3();;
  29. }
  30. ;
  31. }
  32. statechart->runCycle();
  33. }
  34. EXPECT_TRUE(statechart->getSCInterface().get_a()> 2);
  35. delete statechart;
  36. }
  37. TEST(StatemachineTest, test_1_000_000) {
  38. PerformanceTest* statechart = new PerformanceTest();
  39. statechart->init();
  40. statechart->enter();
  41. EXPECT_TRUE(statechart->isActive(PerformanceTest_mr_A));
  42. while (statechart->getSCInterface().get_c()< 1000000) {
  43. if (isActive(PerformanceTest_mr_A)) {
  44. statechart->raise_e1();
  45. }
  46. else {
  47. if (getSCInterface().get_c()%2== 0) {
  48. statechart->raise_e2();
  49. }
  50. else {
  51. statechart->raise_e3();;
  52. }
  53. ;
  54. }
  55. statechart->runCycle();
  56. }
  57. EXPECT_TRUE(statechart->getSCInterface().get_a()> 2);
  58. delete statechart;
  59. }
  60. TEST(StatemachineTest, test_10_000_000) {
  61. PerformanceTest* statechart = new PerformanceTest();
  62. statechart->init();
  63. statechart->enter();
  64. EXPECT_TRUE(statechart->isActive(PerformanceTest_mr_A));
  65. while (statechart->getSCInterface().get_c()< 10000000) {
  66. if (isActive(PerformanceTest_mr_A)) {
  67. statechart->raise_e1();
  68. }
  69. else {
  70. if (getSCInterface().get_c()%2== 0) {
  71. statechart->raise_e2();
  72. }
  73. else {
  74. statechart->raise_e3();;
  75. }
  76. ;
  77. }
  78. statechart->runCycle();
  79. }
  80. EXPECT_TRUE(statechart->getSCInterface().get_a()> 2);
  81. delete statechart;
  82. }