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/Configuration.hpp"
8 #include "src/mc/explo/udpor/EventSet.hpp"
9 #include "src/mc/explo/udpor/UnfoldingEvent.hpp"
11 using namespace simgrid::mc::udpor;
13 TEST_CASE("simgrid::mc::udpor::Configuration: Constructing Configurations")
15 SECTION("Creating a configuration without events")
18 REQUIRE(C.get_events().empty());
19 REQUIRE(C.get_latest_event() == nullptr);
22 SECTION("Creating a configuration with events")
24 // The following tests concern the given event structure:
33 UnfoldingEvent e2{&e1};
34 UnfoldingEvent e3{&e2};
35 UnfoldingEvent e4{&e3}, e5{&e3};
37 // 5 choose 0 = 1 test
38 REQUIRE_NOTHROW(Configuration({&e1}));
40 // 5 choose 1 = 5 tests
41 REQUIRE_THROWS_AS(Configuration({&e2}), std::invalid_argument);
42 REQUIRE_THROWS_AS(Configuration({&e3}), std::invalid_argument);
43 REQUIRE_THROWS_AS(Configuration({&e4}), std::invalid_argument);
44 REQUIRE_THROWS_AS(Configuration({&e5}), std::invalid_argument);
46 // 5 choose 2 = 10 tests
47 REQUIRE_NOTHROW(Configuration({&e1, &e2}));
48 REQUIRE_THROWS_AS(Configuration({&e1, &e3}), std::invalid_argument);
49 REQUIRE_THROWS_AS(Configuration({&e1, &e4}), std::invalid_argument);
50 REQUIRE_THROWS_AS(Configuration({&e1, &e5}), std::invalid_argument);
51 REQUIRE_THROWS_AS(Configuration({&e2, &e3}), std::invalid_argument);
52 REQUIRE_THROWS_AS(Configuration({&e2, &e4}), std::invalid_argument);
53 REQUIRE_THROWS_AS(Configuration({&e2, &e5}), std::invalid_argument);
54 REQUIRE_THROWS_AS(Configuration({&e3, &e4}), std::invalid_argument);
55 REQUIRE_THROWS_AS(Configuration({&e3, &e5}), std::invalid_argument);
56 REQUIRE_THROWS_AS(Configuration({&e4, &e5}), std::invalid_argument);
58 // 5 choose 3 = 10 tests
59 REQUIRE_NOTHROW(Configuration({&e1, &e2, &e3}));
60 REQUIRE_THROWS_AS(Configuration({&e1, &e2, &e4}), std::invalid_argument);
61 REQUIRE_THROWS_AS(Configuration({&e1, &e2, &e5}), std::invalid_argument);
62 REQUIRE_THROWS_AS(Configuration({&e1, &e3, &e4}), std::invalid_argument);
63 REQUIRE_THROWS_AS(Configuration({&e1, &e3, &e5}), std::invalid_argument);
64 REQUIRE_THROWS_AS(Configuration({&e1, &e4, &e5}), std::invalid_argument);
65 REQUIRE_THROWS_AS(Configuration({&e2, &e3, &e4}), std::invalid_argument);
66 REQUIRE_THROWS_AS(Configuration({&e2, &e3, &e5}), std::invalid_argument);
67 REQUIRE_THROWS_AS(Configuration({&e2, &e4, &e5}), std::invalid_argument);
68 REQUIRE_THROWS_AS(Configuration({&e3, &e4, &e5}), std::invalid_argument);
70 // 5 choose 4 = 5 tests
71 REQUIRE_NOTHROW(Configuration({&e1, &e2, &e3, &e4}));
72 REQUIRE_NOTHROW(Configuration({&e1, &e2, &e3, &e5}));
73 REQUIRE_THROWS_AS(Configuration({&e1, &e2, &e4, &e5}), std::invalid_argument);
74 REQUIRE_THROWS_AS(Configuration({&e1, &e3, &e4, &e5}), std::invalid_argument);
75 REQUIRE_THROWS_AS(Configuration({&e2, &e3, &e4, &e5}), std::invalid_argument);
77 // 5 choose 5 = 1 test
78 REQUIRE_NOTHROW(Configuration({&e1, &e2, &e3, &e4, &e5}));