Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Define each identifier in a dedicated statement (sonar).
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 11 Apr 2023 09:13:59 +0000 (11:13 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 2 May 2023 14:26:27 +0000 (16:26 +0200)
src/mc/explo/udpor/EventSet_test.cpp
src/mc/explo/udpor/maximal_subsets_iterator.cpp
src/mc/explo/udpor/maximal_subsets_iterator.hpp

index d414b60..3fc7349 100644 (file)
@@ -41,7 +41,9 @@ TEST_CASE("simgrid::mc::udpor::EventSet: Initial conditions when creating sets")
 
   SECTION("Initialization with one or more elements")
   {
-    UnfoldingEvent e1, e2, e3;
+    UnfoldingEvent e1;
+    UnfoldingEvent e2;
+    UnfoldingEvent e3;
 
     SECTION("Set initializer")
     {
@@ -68,7 +70,9 @@ TEST_CASE("simgrid::mc::udpor::EventSet: Initial conditions when creating sets")
 TEST_CASE("simgrid::mc::udpor::EventSet: Insertions")
 {
   EventSet event_set;
-  UnfoldingEvent e1, e2, e3;
+  UnfoldingEvent e1;
+  UnfoldingEvent e2;
+  UnfoldingEvent e3;
 
   SECTION("Inserting unique elements")
   {
@@ -192,7 +196,9 @@ TEST_CASE("simgrid::mc::udpor::EventSet: Set Equality")
   UnfoldingEvent e2;
   UnfoldingEvent e3;
   UnfoldingEvent e4;
-  EventSet A{&e1, &e2, &e3}, B{&e1, &e2, &e3}, C{&e1, &e2, &e3};
+  EventSet A{&e1, &e2, &e3};
+  EventSet B{&e1, &e2, &e3};
+  EventSet C{&e1, &e2, &e3};
 
   SECTION("Equality implies containment")
   {
@@ -267,10 +273,16 @@ TEST_CASE("simgrid::mc::udpor::EventSet: Set Equality")
 
 TEST_CASE("simgrid::mc::udpor::EventSet: Set Union Tests")
 {
-  UnfoldingEvent e1, e2, e3, e4;
+  UnfoldingEvent e1;
+  UnfoldingEvent e2;
+  UnfoldingEvent e3;
+  UnfoldingEvent e4;
 
   // C = A + B
-  EventSet A{&e1, &e2, &e3}, B{&e2, &e3, &e4}, C{&e1, &e2, &e3, &e4}, D{&e1, &e3};
+  EventSet A{&e1, &e2, &e3};
+  EventSet B{&e2, &e3, &e4};
+  EventSet C{&e1, &e2, &e3, &e4};
+  EventSet D{&e1, &e3};
 
   SECTION("Unions with no effect")
   {
@@ -395,7 +407,12 @@ TEST_CASE("simgrid::mc::udpor::EventSet: Set Difference Tests")
   // D is a subset of A and C
   // E is a subset of B and C
   // F is a subset of A, C, and D
-  EventSet A{&e1, &e2, &e3}, B{&e2, &e3, &e4}, C{&e1, &e2, &e3, &e4}, D{&e1, &e3}, E{&e4}, F{&e1};
+  EventSet A{&e1, &e2, &e3};
+  EventSet B{&e2, &e3, &e4};
+  EventSet C{&e1, &e2, &e3, &e4};
+  EventSet D{&e1, &e3};
+  EventSet E{&e4};
+  EventSet F{&e1};
 
   SECTION("Difference with no effect")
   {
@@ -465,7 +482,10 @@ TEST_CASE("simgrid::mc::udpor::EventSet: Set Difference Tests")
 
 TEST_CASE("simgrid::mc::udpor::EventSet: Subset Tests")
 {
-  UnfoldingEvent e1, e2, e3, e4;
+  UnfoldingEvent e1;
+  UnfoldingEvent e2;
+  UnfoldingEvent e3;
+  UnfoldingEvent e4;
 
   // A is a subset of C only
   // B is a subset of C only
@@ -473,7 +493,12 @@ TEST_CASE("simgrid::mc::udpor::EventSet: Subset Tests")
   // D is NOT a subset of B
   // B is NOT a subset of D
   // ...
-  EventSet A{&e1, &e2, &e3}, B{&e2, &e3, &e4}, C{&e1, &e2, &e3, &e4}, D{&e1, &e3}, E{&e2, &e3}, F{&e1, &e2, &e3};
+  EventSet A{&e1, &e2, &e3};
+  EventSet B{&e2, &e3, &e4};
+  EventSet C{&e1, &e2, &e3, &e4};
+  EventSet D{&e1, &e3};
+  EventSet E{&e2, &e3};
+  EventSet F{&e1, &e2, &e3};
 
   SECTION("Subset operator properties")
   {
index 3e4a76a..b613955 100644 (file)
@@ -110,7 +110,7 @@ maximal_subsets_iterator::continue_traversal_of_maximal_events_tree()
   return topological_ordering.end();
 }
 
-bool maximal_subsets_iterator::bookkeeper::is_candidate_event(const UnfoldingEvent* e) const
+bool maximal_subsets_iterator::Bookkeeper::is_candidate_event(const UnfoldingEvent* e) const
 {
   if (const auto e_count = event_counts.find(e); e_count != event_counts.end()) {
     return e_count->second == 0;
@@ -153,13 +153,13 @@ bool maximal_subsets_iterator::can_grow_maximal_set() const
 }
 
 maximal_subsets_iterator::topological_order_position
-maximal_subsets_iterator::bookkeeper::find_next_candidate_event(topological_order_position first,
+maximal_subsets_iterator::Bookkeeper::find_next_candidate_event(topological_order_position first,
                                                                 topological_order_position last) const
 {
   return std::find_if(first, last, [&](const UnfoldingEvent* e) { return is_candidate_event(e); });
 }
 
-void maximal_subsets_iterator::bookkeeper::mark_included_in_maximal_set(const UnfoldingEvent* e)
+void maximal_subsets_iterator::Bookkeeper::mark_included_in_maximal_set(const UnfoldingEvent* e)
 {
   const auto e_local_config = e->get_local_config();
   for (const auto e_hist : e_local_config) {
@@ -167,7 +167,7 @@ void maximal_subsets_iterator::bookkeeper::mark_included_in_maximal_set(const Un
   }
 }
 
-void maximal_subsets_iterator::bookkeeper::mark_removed_from_maximal_set(const UnfoldingEvent* e)
+void maximal_subsets_iterator::Bookkeeper::mark_removed_from_maximal_set(const UnfoldingEvent* e)
 {
   const auto e_local_config = e->get_local_config();
   for (const auto e_hist : e_local_config) {
@@ -182,4 +182,4 @@ void maximal_subsets_iterator::bookkeeper::mark_removed_from_maximal_set(const U
   }
 }
 
-} // namespace simgrid::mc::udpor
\ No newline at end of file
+} // namespace simgrid::mc::udpor
index 617b2e2..d172eda 100644 (file)
@@ -70,7 +70,7 @@ private:
    * with events that are its current maximal event set (i.e.
    * its `current_maximal_set`)
    */
-  struct bookkeeper {
+  struct Bookkeeper {
   public:
     using topological_order_position = maximal_subsets_iterator::topological_order_position;
 
@@ -86,7 +86,8 @@ private:
     /// bookkeeping that has been done thus far, can be added to the
     /// current candidate maximal set
     bool is_candidate_event(const UnfoldingEvent*) const;
-  } bookkeeper;
+  };
+  Bookkeeper bookkeeper;
 
   void add_element_to_current_maximal_set(const UnfoldingEvent*);
   void remove_element_from_current_maximal_set(const UnfoldingEvent*);