Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'udpor-phase5' into 'master'
[simgrid.git] / src / mc / explo / udpor / Unfolding_test.cpp
1 /* Copyright (c) 2017-2023. The SimGrid Team. All rights reserved.               */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include "src/3rd-party/catch.hpp"
7 #include "src/mc/explo/udpor/Unfolding.hpp"
8 #include "src/mc/explo/udpor/udpor_tests_private.hpp"
9
10 using namespace simgrid::mc::udpor;
11
12 TEST_CASE("simgrid::mc::udpor::Unfolding: Creating an unfolding")
13 {
14   Unfolding unfolding;
15   REQUIRE(unfolding.size() == 0);
16   REQUIRE(unfolding.empty());
17 }
18
19 TEST_CASE("simgrid::mc::udpor::Unfolding: Inserting and removing events with an unfolding")
20 {
21   Unfolding unfolding;
22   auto e1              = std::make_unique<UnfoldingEvent>();
23   auto e2              = std::make_unique<UnfoldingEvent>();
24   const auto e1_handle = e1.get();
25   const auto e2_handle = e2.get();
26
27   unfolding.insert(std::move(e1));
28   REQUIRE(unfolding.size() == 1);
29   REQUIRE_FALSE(unfolding.empty());
30
31   unfolding.insert(std::move(e2));
32   REQUIRE(unfolding.size() == 2);
33   REQUIRE_FALSE(unfolding.empty());
34
35   unfolding.remove(e1_handle);
36   REQUIRE(unfolding.size() == 1);
37   REQUIRE_FALSE(unfolding.empty());
38
39   unfolding.remove(e2_handle);
40   REQUIRE(unfolding.size() == 0);
41   REQUIRE(unfolding.empty());
42 }