tests.cpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /**
  2. * @file tests/dsde/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/dsde/graph_manager.hpp>
  26. #include <tests/dsde/models.hpp>
  27. #include <artis-star/common/RootCoordinator.hpp>
  28. #define CATCH_CONFIG_MAIN
  29. #include <tests/catch.hpp>
  30. using namespace artis::tests::dsde;
  31. using namespace artis::common;
  32. TEST_CASE("dsde/flat", "run") {
  33. artis::common::context::Context<artis::common::DoubleTime> context(0, 10);
  34. artis::common::RootCoordinator<
  35. DoubleTime, artis::dsde::Coordinator<
  36. DoubleTime,
  37. artis::tests::dsde::FlatGraphManager,
  38. artis::tests::dsde::Executive>
  39. > rc(context, "root");
  40. artis::common::Trace<DoubleTime>::trace().clear();
  41. rc.run(context);
  42. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  43. "beep").filter_function_type(artis::common::FunctionType::START).filter_time(0).size()
  44. == 1);
  45. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  46. "beep2").filter_function_type(artis::common::FunctionType::START).filter_time(1).size()
  47. == 1);
  48. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  49. "beep3").filter_function_type(artis::common::FunctionType::START).filter_time(3).size()
  50. == 1);
  51. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  52. "beep2").filter_function_type(artis::common::FunctionType::DELTA_INT).filter_time(
  53. 1).size()
  54. == 1);
  55. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  56. "beep2").filter_function_type(artis::common::FunctionType::TA).filter_time(1).size()
  57. == 2);
  58. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  59. "beep2").filter_function_type(artis::common::FunctionType::DELTA_INT).filter_time(
  60. 2.5).size()
  61. == 1);
  62. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  63. "beep2").filter_function_type(artis::common::FunctionType::DELTA_EXT).filter_time(
  64. 2.5).size()
  65. == 1);
  66. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  67. "beep2").filter_function_type(artis::common::FunctionType::TA).filter_time(2.5).size()
  68. == 2);
  69. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  70. "beep2").filter_function_type(artis::common::FunctionType::LAMBDA).filter_time(2.5).size()
  71. == 1);
  72. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  73. "beep2").filter_function_type(artis::common::FunctionType::DELTA_INT).filter_time(
  74. 6).size()
  75. == 1);
  76. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  77. "beep2").filter_function_type(artis::common::FunctionType::TA).filter_time(6).size()
  78. == 1);
  79. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  80. "beep2").filter_function_type(artis::common::FunctionType::LAMBDA).filter_time(6).size()
  81. == 1);
  82. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  83. "beep3").filter_function_type(artis::common::FunctionType::DELTA_INT).filter_time(
  84. 3).size()
  85. == 1);
  86. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  87. "beep3").filter_function_type(artis::common::FunctionType::TA).filter_time(3).size()
  88. == 2);
  89. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  90. "beep3").filter_function_type(artis::common::FunctionType::LAMBDA).filter_time(3).size()
  91. == 1);
  92. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  93. "beep3").filter_function_type(artis::common::FunctionType::FINISH).filter_time(5).size()
  94. == 1);
  95. }