From f1a60febe7b62f6a2c8de230b7178bf99aeac951 Mon Sep 17 00:00:00 2001 From: Joris van Rantwijk Date: Sun, 12 Feb 2023 17:29:24 +0100 Subject: [PATCH] Improve test coverage to 100% --- python/test_matching.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/python/test_matching.py b/python/test_matching.py index f379eb6..09351b0 100644 --- a/python/test_matching.py +++ b/python/test_matching.py @@ -166,6 +166,21 @@ class TestMaximumWeightMatching(unittest.TestCase): mwm([(0,1,7), (0,2,7), (1,2,9), (0,3,7), (0,4,7), (3,4,9), (5,6,2)]), [(1,2), (3,4), (5,6)]) + def test44_blossom_redundant_edge(self): + """drop redundant edge while making a blossom""" + # + # [1]----9---[2] + # / | \ + # 7 8 \ + # / | 1 + # [0]--6--[4]--9--[3] | + # \ | + # \----1----[5] + # + self.assertEqual( + mwm([(0,1,7), (0,4,6), (1,2,9), (2,3,8), (3,4,9), (2,5,1), (4,5,1)]), + [(1,2), (3,4)]) + def test_fail_bad_input(self): """bad input values""" with self.assertRaises(TypeError): @@ -251,9 +266,6 @@ class TestMaximumCardinalityMatching(unittest.TestCase): class TestGraphInfo(unittest.TestCase): """Test _GraphInfo helper class.""" - # This is just to get 100% test coverage. - # This is _not_ intended as a real test of the _GraphInfo class. - def test_empty(self): graph = _GraphInfo([]) self.assertEqual(graph.num_vertex, 0)