1 /* Copyright (c) 2017-2023. The SimGrid Team. All rights reserved. */
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. */
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"
10 using namespace simgrid::mc;
11 using namespace simgrid::mc::udpor;
13 TEST_CASE("simgrid::mc::udpor::Unfolding: Creating an unfolding")
16 REQUIRE(unfolding.size() == 0);
17 REQUIRE(unfolding.empty());
20 TEST_CASE("simgrid::mc::udpor::Unfolding: Inserting and removing events with an unfolding")
23 auto e1 = std::make_unique<UnfoldingEvent>();
24 auto e2 = std::make_unique<UnfoldingEvent>();
25 const auto e1_handle = e1.get();
26 const auto e2_handle = e2.get();
28 unfolding.insert(std::move(e1));
29 REQUIRE(unfolding.size() == 1);
30 REQUIRE_FALSE(unfolding.empty());
32 unfolding.insert(std::move(e2));
33 REQUIRE(unfolding.size() == 2);
34 REQUIRE_FALSE(unfolding.empty());
36 unfolding.remove(e1_handle);
37 REQUIRE(unfolding.size() == 1);
38 REQUIRE_FALSE(unfolding.empty());
40 unfolding.remove(e2_handle);
41 REQUIRE(unfolding.size() == 0);
42 REQUIRE(unfolding.empty());
45 TEST_CASE("simgrid::mc::udpor::Unfolding: Checking for semantically equivalent events")
48 auto e1 = std::make_unique<UnfoldingEvent>(
49 EventSet(), std::make_shared<IndependentAction>(Transition::Type::BARRIER_ASYNC_LOCK, 6, 2));
50 auto e2 = std::make_unique<UnfoldingEvent>(
51 EventSet(), std::make_shared<IndependentAction>(Transition::Type::BARRIER_ASYNC_LOCK, 6, 2));
53 // e1 and e2 are equivalent
56 const auto e1_handle = e1.get();
57 const auto e2_handle = e2.get();
58 unfolding.insert(std::move(e1));
60 REQUIRE(unfolding.contains_event_equivalent_to(e1_handle));
61 REQUIRE(unfolding.contains_event_equivalent_to(e2_handle));
64 TEST_CASE("simgrid::mc::udpor::Unfolding: Checking all immediate conflicts restricted to an unfolding") {}