@@ -194,23 +194,6 @@ void test_remove_labeled_vertex()
194194 BOOST_ASSERT (v2 == nullptr );
195195}
196196
197- void test_multiple_associative_container ()
198- {
199- typedef labeled_graph<adjacency_list<listS, multisetS, directedS>, string, multimapS> Graph;
200-
201- Graph g;
202- g.add_vertex (" test" );
203- g.add_vertex (" test" );
204-
205- BOOST_ASSERT (num_vertices (g) == 2 );
206-
207- g.remove_vertex (" test" );
208- BOOST_ASSERT (num_vertices (g) == 1 );
209-
210- g.remove_vertex (" test" );
211- BOOST_ASSERT (num_vertices (g) == 0 );
212- }
213-
214197template <typename LabeledGraph, typename Label>
215198void test_remove_vertex_suite (Label l1, Label l2, Label l3)
216199{
@@ -455,3 +438,129 @@ void test_remove_vertex_all_types()
455438 // labeled_graph<adjacency_list<listS, listS, directedS>*, unsigned, vecS>
456439 // >(0u, 1u, 2u);
457440}
441+
442+ template <typename LabeledGraph, typename Label>
443+ void test_multimap_suite (Label l1, Label l2)
444+ {
445+ // Duplicate labels, remove one at a time
446+ {
447+ LabeledGraph g;
448+ g.add_vertex (l1);
449+ g.add_vertex (l1);
450+ BOOST_ASSERT (num_vertices (g) == 2 );
451+
452+ g.remove_vertex (l1);
453+ BOOST_ASSERT (num_vertices (g) == 1 );
454+
455+ g.remove_vertex (l1);
456+ BOOST_ASSERT (num_vertices (g) == 0 );
457+ }
458+
459+ // Duplicates + unique mixed
460+ {
461+ LabeledGraph g;
462+ g.add_vertex (l1);
463+ g.add_vertex (l1);
464+ g.add_vertex (l2);
465+ BOOST_ASSERT (num_vertices (g) == 3 );
466+
467+ g.remove_vertex (l1);
468+ BOOST_ASSERT (num_vertices (g) == 2 );
469+ BOOST_ASSERT (g.vertex (l2) != LabeledGraph::null_vertex ());
470+
471+ g.remove_vertex (l1);
472+ BOOST_ASSERT (num_vertices (g) == 1 );
473+ BOOST_ASSERT (g.vertex (l2) != LabeledGraph::null_vertex ());
474+ }
475+
476+ // Reuse label after removing all duplicates
477+ {
478+ LabeledGraph g;
479+ g.add_vertex (l1);
480+ g.add_vertex (l1);
481+ g.remove_vertex (l1);
482+ g.remove_vertex (l1);
483+ BOOST_ASSERT (num_vertices (g) == 0 );
484+
485+ g.add_vertex (l1);
486+ BOOST_ASSERT (num_vertices (g) == 1 );
487+ BOOST_ASSERT (g.vertex (l1) != LabeledGraph::null_vertex ());
488+ }
489+ }
490+
491+ template <typename Graph, typename LabeledGraph, typename Label>
492+ void test_multimap_suite_ptr (Label l1, Label l2)
493+ {
494+ // Duplicate labels, remove one at a time
495+ {
496+ Graph graph;
497+ LabeledGraph g (&graph);
498+ g.add_vertex (l1);
499+ g.add_vertex (l1);
500+ BOOST_ASSERT (num_vertices (g) == 2 );
501+
502+ g.remove_vertex (l1);
503+ BOOST_ASSERT (num_vertices (g) == 1 );
504+
505+ g.remove_vertex (l1);
506+ BOOST_ASSERT (num_vertices (g) == 0 );
507+ }
508+
509+ // Duplicates + unique mixed
510+ {
511+ Graph graph;
512+ LabeledGraph g (&graph);
513+ g.add_vertex (l1);
514+ g.add_vertex (l1);
515+ g.add_vertex (l2);
516+ BOOST_ASSERT (num_vertices (g) == 3 );
517+
518+ g.remove_vertex (l1);
519+ BOOST_ASSERT (num_vertices (g) == 2 );
520+ BOOST_ASSERT (g.vertex (l2) != LabeledGraph::null_vertex ());
521+
522+ g.remove_vertex (l1);
523+ BOOST_ASSERT (num_vertices (g) == 1 );
524+ BOOST_ASSERT (g.vertex (l2) != LabeledGraph::null_vertex ());
525+ }
526+
527+ // Reuse label after removing all duplicates
528+ {
529+ Graph graph;
530+ LabeledGraph g (&graph);
531+ g.add_vertex (l1);
532+ g.add_vertex (l1);
533+ g.remove_vertex (l1);
534+ g.remove_vertex (l1);
535+ BOOST_ASSERT (num_vertices (g) == 0 );
536+
537+ g.add_vertex (l1);
538+ BOOST_ASSERT (num_vertices (g) == 1 );
539+ BOOST_ASSERT (g.vertex (l1) != LabeledGraph::null_vertex ());
540+ }
541+ }
542+
543+ void test_multiple_associative_container ()
544+ {
545+ // Owning multimapS
546+ test_multimap_suite<
547+ labeled_graph<adjacency_list<listS, multisetS, directedS>, string, multimapS>
548+ >(" a" , " b" );
549+
550+ // Owning hash_multimapS
551+ test_multimap_suite<
552+ labeled_graph<adjacency_list<listS, multisetS, directedS>, string, hash_multimapS>
553+ >(" a" , " b" );
554+
555+ // Pointer multimapS
556+ test_multimap_suite_ptr<
557+ adjacency_list<listS, multisetS, directedS>,
558+ labeled_graph<adjacency_list<listS, multisetS, directedS>*, string, multimapS>
559+ >(" a" , " b" );
560+
561+ // Pointer hash_multimapS
562+ test_multimap_suite_ptr<
563+ adjacency_list<listS, multisetS, directedS>,
564+ labeled_graph<adjacency_list<listS, multisetS, directedS>*, string, hash_multimapS>
565+ >(" a" , " b" );
566+ }
0 commit comments