]> granicus.if.org Git - graphviz/commitdiff
fix multiple layout test case using rvalue refs
authorMagnus Jacobsson <Magnus.Jacobsson@berotec.se>
Mon, 9 Aug 2021 17:41:35 +0000 (19:41 +0200)
committerMagnus Jacobsson <Magnus.Jacobsson@berotec.se>
Mon, 9 Aug 2021 18:51:44 +0000 (20:51 +0200)
The first layout of a graph must be destroyed before a second layout
is created.

This failure went undetected in CI since no test programs ran, which
in turn was caused by not archiving the test programs or the
CTestTestfile.cmake files in the preceding build job.

The error message was:

-------------------------------------------------------------------------------
Multiple layouts of the same graph can use different contexts passed as rvalue
refs
-------------------------------------------------------------------------------
../tests/test_GVLayout_construction.cpp:139
...............................................................................

../tests/test_GVLayout_construction.cpp:139: FAILED:
due to unexpected exception with message:
  Previous layout not yet destroyed

tests/test_GVLayout_construction.cpp

index 146ea7559f6a29265b2126de84496d0bbac7edb9..ffd5ce8b60b40d95a1197696994fe2dfa784df73 100644 (file)
@@ -143,10 +143,13 @@ TEST_CASE("Multiple layouts of the same graph can use different contexts "
   auto dot = "graph {}";
   auto g = std::make_shared<CGraph::AGraph>(dot);
 
-  const auto layout1 = GVC::GVLayout(std::move(gvc1), g, "dot");
+  // create a layout and automatically destroy it
+  { const auto layout1 = GVC::GVLayout(std::move(gvc1), g, "dot"); }
 
   auto gvc2 = GVC::GVContext(lt_preloaded_symbols, demand_loading);
-  const auto layout2 = GVC::GVLayout(std::move(gvc2), g, "dot");
+
+  // create another layout and automatically destroy it
+  { const auto layout2 = GVC::GVLayout(std::move(gvc2), g, "dot"); }
 }
 
 TEST_CASE("Layout with an unknown engine throws an exception") {