Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add tests for the Unfolding object
[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
9 using namespace simgrid::mc::udpor;
10
11 TEST_CASE("simgrid::mc::udpor::Unfolding: Creating an unfolding")
12 {
13   Unfolding unfolding;
14   REQUIRE(unfolding.size() == 0);
15   REQUIRE(unfolding.empty());
16 }
17
18 TEST_CASE("simgrid::mc::udpor::Unfolding: Inserting and removing events with an unfolding")
19 {
20   Unfolding unfolding;
21   auto e1        = std::make_unique<UnfoldingEvent>();
22   auto e2        = std::make_unique<UnfoldingEvent>();
23   auto e1_handle = e1.get();
24   auto e2_handle = e2.get();
25
26   unfolding.insert(std::move(e1));
27   REQUIRE(unfolding.size() == 1);
28   REQUIRE_FALSE(unfolding.empty());
29
30   unfolding.insert(std::move(e2));
31   REQUIRE(unfolding.size() == 2);
32   REQUIRE_FALSE(unfolding.empty());
33
34   unfolding.remove(e1_handle);
35   REQUIRE(unfolding.size() == 1);
36   REQUIRE_FALSE(unfolding.empty());
37
38   unfolding.remove(e2_handle);
39   REQUIRE(unfolding.size() == 0);
40   REQUIRE(unfolding.empty());
41 }