From 5a4e1599ee1fd87c43e81e990625e919c9aa6def Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Del=20Pino?= <stephane.delpino44@gmail.com>
Date: Tue, 15 Feb 2022 19:14:49 +0100
Subject: [PATCH] Add missing tests for the isSynchronized utility functions

---
 tests/test_ItemArrayUtils.cpp | 48 +++++++++++++++++++++++++++++++++++
 tests/test_ItemValueUtils.cpp |  5 ++++
 2 files changed, 53 insertions(+)

diff --git a/tests/test_ItemArrayUtils.cpp b/tests/test_ItemArrayUtils.cpp
index af91ecb70..85e2e6e07 100644
--- a/tests/test_ItemArrayUtils.cpp
+++ b/tests/test_ItemArrayUtils.cpp
@@ -68,6 +68,9 @@ TEST_CASE("ItemArrayUtils", "[mesh]")
 
               REQUIRE(is_valid);
               REQUIRE(not is_synchronized);
+              if (parallel::size() > 1) {
+                REQUIRE(not isSynchronized(node_array));
+              }
             }
 
             synchronize(weak_node_array);
@@ -86,6 +89,7 @@ TEST_CASE("ItemArrayUtils", "[mesh]")
               }
 
               REQUIRE(is_synchronized);
+              REQUIRE(isSynchronized(node_array));
             }
           }
 
@@ -129,6 +133,9 @@ TEST_CASE("ItemArrayUtils", "[mesh]")
 
               REQUIRE(is_valid);
               REQUIRE(not is_synchronized);
+              if (parallel::size() > 1) {
+                REQUIRE(not isSynchronized(edge_array));
+              }
             }
 
             synchronize(weak_edge_array);
@@ -148,6 +155,7 @@ TEST_CASE("ItemArrayUtils", "[mesh]")
 
               REQUIRE(is_synchronized);
             }
+            REQUIRE(isSynchronized(edge_array));
           }
 
           SECTION("face")
@@ -190,6 +198,9 @@ TEST_CASE("ItemArrayUtils", "[mesh]")
 
               REQUIRE(is_valid);
               REQUIRE(not is_synchronized);
+              if (parallel::size() > 1) {
+                REQUIRE(not isSynchronized(face_array));
+              }
             }
 
             synchronize(weak_face_array);
@@ -209,6 +220,7 @@ TEST_CASE("ItemArrayUtils", "[mesh]")
 
               REQUIRE(is_synchronized);
             }
+            REQUIRE(isSynchronized(face_array));
           }
 
           SECTION("cell")
@@ -251,6 +263,9 @@ TEST_CASE("ItemArrayUtils", "[mesh]")
 
               REQUIRE(is_valid);
               REQUIRE(not is_synchronized);
+              if (parallel::size() > 1) {
+                REQUIRE(not isSynchronized(cell_array));
+              }
             }
 
             synchronize(weak_cell_array);
@@ -270,6 +285,7 @@ TEST_CASE("ItemArrayUtils", "[mesh]")
 
               REQUIRE(is_synchronized);
             }
+            REQUIRE(isSynchronized(cell_array));
           }
         }
       }
@@ -326,6 +342,9 @@ TEST_CASE("ItemArrayUtils", "[mesh]")
 
               REQUIRE(is_valid);
               REQUIRE(not is_synchronized);
+              if (parallel::size() > 1) {
+                REQUIRE(not isSynchronized(node_array));
+              }
             }
 
             synchronize(weak_node_array);
@@ -344,6 +363,7 @@ TEST_CASE("ItemArrayUtils", "[mesh]")
               }
 
               REQUIRE(is_synchronized);
+              REQUIRE(isSynchronized(node_array));
             }
           }
 
@@ -387,6 +407,9 @@ TEST_CASE("ItemArrayUtils", "[mesh]")
 
               REQUIRE(is_valid);
               REQUIRE(not is_synchronized);
+              if (parallel::size() > 1) {
+                REQUIRE(not isSynchronized(edge_array));
+              }
             }
 
             synchronize(weak_edge_array);
@@ -406,6 +429,7 @@ TEST_CASE("ItemArrayUtils", "[mesh]")
 
               REQUIRE(is_synchronized);
             }
+            REQUIRE(isSynchronized(edge_array));
           }
 
           SECTION("face")
@@ -448,6 +472,9 @@ TEST_CASE("ItemArrayUtils", "[mesh]")
 
               REQUIRE(is_valid);
               REQUIRE(not is_synchronized);
+              if (parallel::size() > 1) {
+                REQUIRE(not isSynchronized(face_array));
+              }
             }
 
             synchronize(weak_face_array);
@@ -467,6 +494,7 @@ TEST_CASE("ItemArrayUtils", "[mesh]")
 
               REQUIRE(is_synchronized);
             }
+            REQUIRE(isSynchronized(face_array));
           }
 
           SECTION("cell")
@@ -509,6 +537,9 @@ TEST_CASE("ItemArrayUtils", "[mesh]")
 
               REQUIRE(is_valid);
               REQUIRE(not is_synchronized);
+              if (parallel::size() > 1) {
+                REQUIRE(not isSynchronized(cell_array));
+              }
             }
 
             synchronize(weak_cell_array);
@@ -528,6 +559,7 @@ TEST_CASE("ItemArrayUtils", "[mesh]")
 
               REQUIRE(is_synchronized);
             }
+            REQUIRE(isSynchronized(cell_array));
           }
         }
       }
@@ -584,6 +616,9 @@ TEST_CASE("ItemArrayUtils", "[mesh]")
 
               REQUIRE(is_valid);
               REQUIRE(not is_synchronized);
+              if (parallel::size() > 1) {
+                REQUIRE(not isSynchronized(node_array));
+              }
             }
 
             synchronize(weak_node_array);
@@ -603,6 +638,7 @@ TEST_CASE("ItemArrayUtils", "[mesh]")
 
               REQUIRE(is_synchronized);
             }
+            REQUIRE(isSynchronized(node_array));
           }
 
           SECTION("edge")
@@ -645,6 +681,9 @@ TEST_CASE("ItemArrayUtils", "[mesh]")
 
               REQUIRE(is_valid);
               REQUIRE(not is_synchronized);
+              if (parallel::size() > 1) {
+                REQUIRE(not isSynchronized(edge_array));
+              }
             }
 
             synchronize(weak_edge_array);
@@ -664,6 +703,7 @@ TEST_CASE("ItemArrayUtils", "[mesh]")
 
               REQUIRE(is_synchronized);
             }
+            REQUIRE(isSynchronized(edge_array));
           }
 
           SECTION("face")
@@ -706,6 +746,9 @@ TEST_CASE("ItemArrayUtils", "[mesh]")
 
               REQUIRE(is_valid);
               REQUIRE(not is_synchronized);
+              if (parallel::size() > 1) {
+                REQUIRE(not isSynchronized(face_array));
+              }
             }
 
             synchronize(weak_face_array);
@@ -725,6 +768,7 @@ TEST_CASE("ItemArrayUtils", "[mesh]")
 
               REQUIRE(is_synchronized);
             }
+            REQUIRE(isSynchronized(face_array));
           }
 
           SECTION("cell")
@@ -767,6 +811,9 @@ TEST_CASE("ItemArrayUtils", "[mesh]")
 
               REQUIRE(is_valid);
               REQUIRE(not is_synchronized);
+              if (parallel::size() > 1) {
+                REQUIRE(not isSynchronized(cell_array));
+              }
             }
 
             synchronize(weak_cell_array);
@@ -786,6 +833,7 @@ TEST_CASE("ItemArrayUtils", "[mesh]")
 
               REQUIRE(is_synchronized);
             }
+            REQUIRE(isSynchronized(cell_array));
           }
         }
       }
diff --git a/tests/test_ItemValueUtils.cpp b/tests/test_ItemValueUtils.cpp
index bee143e75..fd90c2733 100644
--- a/tests/test_ItemValueUtils.cpp
+++ b/tests/test_ItemValueUtils.cpp
@@ -47,6 +47,10 @@ TEST_CASE("ItemValueUtils", "[mesh]")
           }
         }
 
+        if (parallel::size() > 1) {
+          REQUIRE(not isSynchronized(face_value));
+        }
+
         synchronize(weak_face_value);
 
         {   // after synchronization
@@ -57,6 +61,7 @@ TEST_CASE("ItemValueUtils", "[mesh]")
             REQUIRE(face_owner[i_face] == face_value[i_face]);
           }
         }
+        REQUIRE(isSynchronized(face_value));
       }
     }
   }
-- 
GitLab