From a7e545ce27022a954bef0ff034859dcdbf2ebad9 Mon Sep 17 00:00:00 2001
From: Olivier BICHLER <olivier.bichler@cea.fr>
Date: Sun, 3 Dec 2023 12:32:32 +0100
Subject: [PATCH] Fixed test on Windows

---
 src/graph/Testing.cpp               | 5 +++++
 unit_tests/graph/Test_GraphView.cpp | 5 ++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/graph/Testing.cpp b/src/graph/Testing.cpp
index 349b1e345..ad193f000 100644
--- a/src/graph/Testing.cpp
+++ b/src/graph/Testing.cpp
@@ -40,6 +40,11 @@ std::pair<Aidge::NodePtr, std::set<Aidge::NodePtr>> Aidge::RandomGraph::gen(std:
 
     for (size_t i = 0; i < nbNodes; ++i) {
         for (size_t j = (acyclic) ? i + 1 : 0; j < nbNodes; ++j) {
+            if (i == j) {
+                // Do not connected node to itself in case of cyclic graph!
+                continue;
+            }
+
             for (size_t outId = 0; outId < nodes[i]->nbOutputs(); ++outId) {
                 for (size_t inId = 0; inId < nodes[j]->nbInputs(); ++inId) {
                     if (dLink(gen)) {
diff --git a/unit_tests/graph/Test_GraphView.cpp b/unit_tests/graph/Test_GraphView.cpp
index 66f110cb1..25aa4b461 100644
--- a/unit_tests/graph/Test_GraphView.cpp
+++ b/unit_tests/graph/Test_GraphView.cpp
@@ -123,7 +123,10 @@ TEST_CASE("clone_with_delete") {
     // graphs keep the same inputs/outputs despites the deleted nodes
     // (meaning the deleted nodes are not input/output of the graph).
     // Otherwise, the last two REQUIRE are not garanteed to be true!
-    std::mt19937::result_type seed(42);
+    // Warning: distributions are not required to behave the same way by the standard,
+    // therefore the seed has to work for both GCC and MSVC...
+    // See https://stackoverflow.com/questions/38532927/why-gcc-and-msvc-stdnormal-distribution-are-different
+    std::mt19937::result_type seed(243);
 
     for (int test = 0; test < nbTests; ++test) {
         RandomGraph randGraph;
-- 
GitLab