From 375a6a180de01606d98b945a48d7716f47828cd2 Mon Sep 17 00:00:00 2001 From: Olivier BICHLER <olivier.bichler@cea.fr> Date: Wed, 4 Sep 2024 17:25:36 +0200 Subject: [PATCH] Fixed unit test --- unit_tests/graph/Test_GraphView.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/unit_tests/graph/Test_GraphView.cpp b/unit_tests/graph/Test_GraphView.cpp index d9289c4aa..300712486 100644 --- a/unit_tests/graph/Test_GraphView.cpp +++ b/unit_tests/graph/Test_GraphView.cpp @@ -108,13 +108,6 @@ TEST_CASE("clone_with_delete", "[GraphView][cloneDelete]") { const size_t nbTests = 100; size_t nbClonedWithDelete = 0; - // Note: initial seed is chosen such that for nbTests=100, the generated - // 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! - // 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) { @@ -124,7 +117,21 @@ TEST_CASE("clone_with_delete", "[GraphView][cloneDelete]") { const auto g1 = std::make_shared<GraphView>("g1"); const bool unicity1 = g1->add(randGraph.gen(seed, 10)); - if (unicity1) { + bool stableInOut = true; + for (auto node : g1->inputNodes()) { + if (node->type() == "DelFictive") { + stableInOut = false; + break; + } + } + for (auto node : g1->outputNodes()) { + if (node->type() == "DelFictive") { + stableInOut = false; + break; + } + } + + if (unicity1 && stableInOut) { randGraph.omitType = "DelFictive"; const auto g2 = std::make_shared<GraphView>("g2"); const bool unicity2 = g2->add(randGraph.gen(seed, 10)); -- GitLab