tests.cpp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. #define CATCH_CONFIG_MAIN
  29. #include <tests/catch.hpp>
  30. using namespace artis::tests::dtss;
  31. using namespace artis::common;
  32. TEST_CASE("dtss/only_one", "run")
  33. {
  34. artis::common::context::Context<artis::common::DoubleTime> context(0, 10);
  35. artis::common::RootCoordinator<
  36. DoubleTime, artis::dtss::Coordinator<
  37. DoubleTime,
  38. Policy,
  39. OnlyOneGraphManager,
  40. artis::dtss::Parameters<DoubleTime>,
  41. artis::common::NoParameters>
  42. > rc(context, "root", artis::dtss::Parameters<DoubleTime>(1), artis::common::NoParameters());
  43. artis::common::Trace<DoubleTime>::trace().clear();
  44. rc.run(context);
  45. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().
  46. filter_model_name("a").
  47. filter_type(artis::common::TraceType::START).size() == 1);
  48. for (double t = 0; t <= 10; ++t) {
  49. REQUIRE(artis::common::Trace<
  50. DoubleTime > ::trace().elements().
  51. filter_model_name("a").filter_time(t).
  52. filter_type(artis::common::TraceType::DELTA_INT).size() == 1);
  53. REQUIRE(artis::common::Trace<
  54. DoubleTime > ::trace().elements().
  55. filter_model_name("a").filter_time(t).
  56. filter_type(artis::common::TraceType::LAMBDA).size() == 1);
  57. }
  58. }
  59. TEST_CASE("dtss/two", "run")
  60. {
  61. artis::common::context::Context<artis::common::DoubleTime> context(0, 10);
  62. artis::common::RootCoordinator<
  63. DoubleTime, artis::dtss::Coordinator<
  64. DoubleTime,
  65. Policy,
  66. TwoGraphManager,
  67. artis::dtss::Parameters<DoubleTime> >
  68. > rc(context, "root",
  69. artis::dtss::Parameters<DoubleTime>(1),
  70. artis::common::NoParameters());
  71. artis::common::Trace<DoubleTime>::trace().clear();
  72. rc.run(context);
  73. REQUIRE(artis::common::Trace<
  74. DoubleTime > ::trace().elements().
  75. filter_model_name("a").
  76. filter_type(artis::common::TraceType::START).size() == 1);
  77. for (unsigned int t = 0; t <= 10; ++t) {
  78. REQUIRE(artis::common::Trace<
  79. DoubleTime > ::trace().elements().
  80. filter_model_name("a").filter_time(t).
  81. filter_type(artis::common::TraceType::DELTA_INT).size() == 1);
  82. REQUIRE(artis::common::Trace<
  83. DoubleTime > ::trace().elements().
  84. filter_model_name("a").filter_time(t).
  85. filter_type(artis::common::TraceType::LAMBDA).size() == 1);
  86. }
  87. REQUIRE(artis::common::Trace<
  88. DoubleTime > ::trace().elements().
  89. filter_model_name("b").
  90. filter_type(artis::common::TraceType::START).size() == 1);
  91. for (unsigned int t = 0; t <= 10; ++t) {
  92. REQUIRE(artis::common::Trace<
  93. DoubleTime > ::trace().elements().
  94. filter_model_name("b").filter_time(t).
  95. filter_type(artis::common::TraceType::DELTA_INT).size() == 1);
  96. REQUIRE(artis::common::Trace<
  97. DoubleTime > ::trace().elements().
  98. filter_model_name("b").filter_time(t).
  99. filter_type(artis::common::TraceType::LAMBDA).size() == 1);
  100. }
  101. }