# HG changeset patch # User Peter Kovacs # Date 1254212511 -7200 # Node ID 819ca5b50de0c849d6097a3bf933060bbf21404d # Parent 456fa5bc32569263c32886a2f1ebbc62b50e2500 Add a warning for List(Di)Graph::Snapshot (#311) and extend tests for snapshots diff -r 456fa5bc3256 -r 819ca5b50de0 lemon/list_graph.h --- a/lemon/list_graph.h Sun Aug 23 11:13:21 2009 +0200 +++ b/lemon/list_graph.h Tue Sep 29 10:21:51 2009 +0200 @@ -751,6 +751,9 @@ /// /// This function undos the changes until the last snapshot /// created by save() or Snapshot(ListDigraph&). + /// + /// \warning This method invalidates the snapshot, i.e. repeated + /// restoring is not supported unless you call save() again. void restore() { detach(); for(std::list::iterator it = added_arcs.begin(); @@ -1550,6 +1553,9 @@ /// /// This function undos the changes until the last snapshot /// created by save() or Snapshot(ListGraph&). + /// + /// \warning This method invalidates the snapshot, i.e. repeated + /// restoring is not supported unless you call save() again. void restore() { detach(); for(std::list::iterator it = added_edges.begin(); diff -r 456fa5bc3256 -r 819ca5b50de0 test/digraph_test.cc --- a/test/digraph_test.cc Sun Aug 23 11:13:21 2009 +0200 +++ b/test/digraph_test.cc Tue Sep 29 10:21:51 2009 +0200 @@ -286,6 +286,14 @@ G.addArc(G.addNode(), G.addNode()); snapshot.restore(); + snapshot.save(G); + + checkGraphNodeList(G, 4); + checkGraphArcList(G, 4); + + G.addArc(G.addNode(), G.addNode()); + + snapshot.restore(); checkGraphNodeList(G, 4); checkGraphArcList(G, 4); diff -r 456fa5bc3256 -r 819ca5b50de0 test/graph_test.cc --- a/test/graph_test.cc Sun Aug 23 11:13:21 2009 +0200 +++ b/test/graph_test.cc Tue Sep 29 10:21:51 2009 +0200 @@ -259,6 +259,15 @@ G.addEdge(G.addNode(), G.addNode()); snapshot.restore(); + snapshot.save(G); + + checkGraphNodeList(G, 4); + checkGraphEdgeList(G, 3); + checkGraphArcList(G, 6); + + G.addEdge(G.addNode(), G.addNode()); + + snapshot.restore(); checkGraphNodeList(G, 4); checkGraphEdgeList(G, 3);