tests.cpp 4.7 KB

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