tests.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /**
  2. * @file tests/dtss/tests.cpp
  3. * @author The ARTIS Development Team
  4. * See the AUTHORS or Authors.txt file
  5. */
  6. /*
  7. * ARTIS - the multimodeling and simulation environment
  8. * This file is a part of the ARTIS environment
  9. *
  10. * Copyright (C) 2013-2019 ULCO http://www.univ-littoral.fr
  11. *
  12. * This program is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation, either version 3 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. */
  25. #include <tests/dtss/graph_manager.hpp>
  26. #include <tests/dtss/models.hpp>
  27. #include <artis-star/common/RootCoordinator.hpp>
  28. #include <artis-star/kernel/dtss/Policy.hpp>
  29. #define CATCH_CONFIG_MAIN
  30. #include <tests/catch.hpp>
  31. using namespace artis::tests::dtss;
  32. using namespace artis::common;
  33. TEST_CASE("dtss/only_one", "run")
  34. {
  35. artis::common::context::Context<artis::common::DoubleTime> context(0, 10);
  36. artis::common::RootCoordinator<
  37. DoubleTime, artis::dtss::Coordinator<
  38. DoubleTime,
  39. artis::dtss::LastBagPolicy,
  40. OnlyOneGraphManager,
  41. artis::dtss::Parameters<DoubleTime>,
  42. artis::common::NoParameters>
  43. > rc(context, "root", artis::dtss::Parameters<DoubleTime>(1), artis::common::NoParameters());
  44. artis::common::Trace<DoubleTime>::trace().clear();
  45. rc.run(context);
  46. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().
  47. filter_model_name("a").
  48. filter_type(artis::common::TraceType::START).size() == 1);
  49. for (double t = 0; t <= 10; ++t) {
  50. REQUIRE(artis::common::Trace<
  51. DoubleTime > ::trace().elements().
  52. filter_model_name("a").filter_time(t).
  53. filter_type(artis::common::TraceType::TRANSITION).size() == 1);
  54. REQUIRE(artis::common::Trace<
  55. DoubleTime > ::trace().elements().
  56. filter_model_name("a").filter_time(t).
  57. filter_type(artis::common::TraceType::LAMBDA).size() == 1);
  58. }
  59. }
  60. TEST_CASE("dtss/two", "run")
  61. {
  62. artis::common::context::Context<artis::common::DoubleTime> context(0, 10);
  63. artis::common::RootCoordinator<
  64. DoubleTime, artis::dtss::Coordinator<
  65. DoubleTime,
  66. artis::dtss::LastBagPolicy,
  67. TwoGraphManager,
  68. artis::dtss::Parameters<DoubleTime> >
  69. > rc(context, "root",
  70. artis::dtss::Parameters<DoubleTime>(1),
  71. artis::common::NoParameters());
  72. artis::common::Trace<DoubleTime>::trace().clear();
  73. rc.run(context);
  74. REQUIRE(artis::common::Trace<
  75. DoubleTime > ::trace().elements().
  76. filter_model_name("a").
  77. filter_type(artis::common::TraceType::START).size() == 1);
  78. for (unsigned int t = 0; t <= 10; ++t) {
  79. REQUIRE(artis::common::Trace<
  80. DoubleTime > ::trace().elements().
  81. filter_model_name("a").filter_time(t).
  82. filter_type(artis::common::TraceType::TRANSITION).size() == 1);
  83. REQUIRE(artis::common::Trace<
  84. DoubleTime > ::trace().elements().
  85. filter_model_name("a").filter_time(t).
  86. filter_type(artis::common::TraceType::LAMBDA).size() == 1);
  87. }
  88. REQUIRE(artis::common::Trace<
  89. DoubleTime > ::trace().elements().
  90. filter_model_name("b").
  91. filter_type(artis::common::TraceType::START).size() == 1);
  92. for (unsigned int t = 0; t <= 10; ++t) {
  93. REQUIRE(artis::common::Trace<
  94. DoubleTime > ::trace().elements().
  95. filter_model_name("b").filter_time(t).
  96. filter_type(artis::common::TraceType::TRANSITION).size() == 1);
  97. REQUIRE(artis::common::Trace<
  98. DoubleTime > ::trace().elements().
  99. filter_model_name("b").filter_time(t).
  100. filter_type(artis::common::TraceType::LAMBDA).size() == 1);
  101. }
  102. }