{
UnfoldingEvent* handle = e.get();
auto loc = this->global_events_.find(handle);
- if (loc == this->global_events_.end()) {
+ if (loc != this->global_events_.end()) {
// This is bad: someone wrapped the raw event address twice
// in two different unique ptrs and attempted to
// insert it into the unfolding...
#include "src/3rd-party/catch.hpp"
#include "src/mc/explo/udpor/Unfolding.hpp"
+using namespace simgrid::mc::udpor;
+
TEST_CASE("simgrid::mc::udpor::Unfolding: Creating an unfolding")
{
- using namespace simgrid::mc::udpor;
+ Unfolding unfolding;
+ REQUIRE(unfolding.size() == 0);
+ REQUIRE(unfolding.empty());
+}
+TEST_CASE("simgrid::mc::udpor::Unfolding: Inserting and removing events with an unfolding")
+{
Unfolding unfolding;
- CHECK(unfolding.empty());
+ auto e1 = std::make_unique<UnfoldingEvent>();
+ auto e2 = std::make_unique<UnfoldingEvent>();
+ auto e1_handle = e1.get();
+ auto e2_handle = e2.get();
+
+ unfolding.insert(std::move(e1));
+ REQUIRE(unfolding.size() == 1);
+ REQUIRE_FALSE(unfolding.empty());
+
+ unfolding.insert(std::move(e2));
+ REQUIRE(unfolding.size() == 2);
+ REQUIRE_FALSE(unfolding.empty());
+
+ unfolding.remove(e1_handle);
+ REQUIRE(unfolding.size() == 1);
+ REQUIRE_FALSE(unfolding.empty());
+
+ unfolding.remove(e2_handle);
REQUIRE(unfolding.size() == 0);
+ REQUIRE(unfolding.empty());
}
\ No newline at end of file