tests.cpp 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. // std::cout << artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  44. // "root").to_string() << std::endl;
  45. // std::cout << artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  46. // "beep2").to_string() << std::endl;
  47. // std::cout << artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  48. // "beep3").to_string() << std::endl;
  49. // std::cout << artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  50. // "executive").to_string() << std::endl;
  51. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  52. "beep").filter_function_type(artis::common::FunctionType::START).filter_time(0).size()
  53. == 1);
  54. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  55. "beep2").filter_function_type(artis::common::FunctionType::START).filter_time(1).size()
  56. == 1);
  57. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  58. "beep3").filter_function_type(artis::common::FunctionType::START).filter_time(3).size()
  59. == 1);
  60. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  61. "beep2").filter_function_type(artis::common::FunctionType::DELTA_INT).filter_time(
  62. 1).size()
  63. == 1);
  64. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  65. "beep2").filter_function_type(artis::common::FunctionType::TA).filter_time(1).size()
  66. == 1);
  67. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  68. "beep2").filter_function_type(artis::common::FunctionType::DELTA_INT).filter_time(
  69. 2.5).size()
  70. == 1);
  71. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  72. "beep2").filter_function_type(artis::common::FunctionType::DELTA_EXT).filter_time(
  73. 2.5).size()
  74. == 1);
  75. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  76. "beep2").filter_function_type(artis::common::FunctionType::TA).filter_time(2.5).size()
  77. == 2);
  78. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  79. "beep2").filter_function_type(artis::common::FunctionType::LAMBDA).filter_time(2.5).size()
  80. == 1);
  81. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  82. "beep2").filter_function_type(artis::common::FunctionType::DELTA_INT).filter_time(
  83. 6).size()
  84. == 1);
  85. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  86. "beep2").filter_function_type(artis::common::FunctionType::TA).filter_time(6).size()
  87. == 1);
  88. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  89. "beep2").filter_function_type(artis::common::FunctionType::LAMBDA).filter_time(6).size()
  90. == 1);
  91. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  92. "beep3").filter_function_type(artis::common::FunctionType::DELTA_INT).filter_time(
  93. 3).size()
  94. == 1);
  95. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  96. "beep3").filter_function_type(artis::common::FunctionType::TA).filter_time(3).size()
  97. == 1);
  98. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  99. "beep3").filter_function_type(artis::common::FunctionType::LAMBDA).filter_time(3).size()
  100. == 1);
  101. REQUIRE(artis::common::Trace<DoubleTime>::trace().elements().filter_model_name(
  102. "beep3").filter_function_type(artis::common::FunctionType::FINISH).filter_time(5).size()
  103. == 1);
  104. }