Remove clutter from C++ unit tests
This commit is contained in:
parent
ee14d45aa6
commit
3aa2b20a74
|
@ -497,222 +497,3 @@ BOOST_AUTO_TEST_CASE(test41_maxcard)
|
|||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
class TestCornerCases(unittest.TestCase):
|
||||
"""Test cases that would catch certain errors in the algorithm.
|
||||
|
||||
These graphs were generated semi-automatically to fail when
|
||||
specific bugs are introduced in the code.
|
||||
"""
|
||||
|
||||
def test1(self):
|
||||
pairs = mwm([(0,4,26), (1,3,31), (1,4,49)])
|
||||
self.assertEqual(pairs, [(0,4), (1,3)])
|
||||
|
||||
def test2(self):
|
||||
pairs = mwm([(0,2,42), (0,4,36), (2,3,26)])
|
||||
self.assertEqual(pairs, [(0,4), (2,3)])
|
||||
|
||||
def test3(self):
|
||||
pairs = mwm([(0,4,43), (1,4,28), (2,4,38)])
|
||||
self.assertEqual(pairs, [(0,4)])
|
||||
|
||||
def test4(self):
|
||||
pairs = mwm([(0,1,50), (0,3,46), (0,4,45)])
|
||||
self.assertEqual(pairs, [(0,1)])
|
||||
|
||||
def test5(self):
|
||||
pairs = mwm([(0,1,35), (0,3,36), (0,4,46)])
|
||||
self.assertEqual(pairs, [(0,4)])
|
||||
|
||||
def test6(self):
|
||||
pairs = mwm([(0,1,50), (0,4,51), (0,5,34), (1,2,43), (1,4,57), (2,5,47), (3,4,17)])
|
||||
self.assertEqual(pairs, [(0,1), (2,5), (3,4)])
|
||||
|
||||
def test7(self):
|
||||
pairs = mwm([(0,1,34), (0,3,19), (1,2,45), (1,3,30), (1,4,37), (2,4,36)])
|
||||
self.assertEqual(pairs, [(0,1), (2,4)])
|
||||
|
||||
def test8(self):
|
||||
pairs = mwm([(0,1,48), (0,3,42), (0,4,57), (1,3,51), (1,5,36), (2,3,23), (4,5,46)])
|
||||
self.assertEqual(pairs, [(0,1), (2,3), (4,5)])
|
||||
|
||||
def test9(self):
|
||||
pairs = mwm([(0,1,21), (0,2,25), (0,5,42), (1,4,40), (2,3,10), (2,5,40), (3,5,31), (4,5,58)])
|
||||
self.assertEqual(pairs, [(0,2), (1,4), (3,5)])
|
||||
|
||||
def test10(self):
|
||||
pairs = mwm([(0,2,7), (0,5,20), (1,2,50), (1,4,46), (2,3,35), (2,4,8), (2,5,25), (3,5,47)])
|
||||
self.assertEqual(pairs, [(0,5), (1,4), (2,3)])
|
||||
|
||||
def test11(self):
|
||||
pairs = mwm([(0,1,42), (0,2,60), (1,3,34), (1,4,58), (1,5,52), (2,5,60), (3,5,34), (4,5,57)])
|
||||
self.assertEqual(pairs, [(0,2), (1,4), (3,5)])
|
||||
|
||||
def test12(self):
|
||||
pairs = mwm([(0,1,23), (0,2,26), (0,3,22), (0,4,41), (2,4,36)])
|
||||
self.assertEqual(pairs, [(0,1), (2,4)])
|
||||
|
||||
def test13(self):
|
||||
pairs = mwm([(0,3,58), (0,4,49), (1,5,34), (2,3,22), (2,5,42), (4,5,36)])
|
||||
self.assertEqual(pairs, [(0,4), (1,5), (2,3)])
|
||||
|
||||
def test14(self):
|
||||
pairs = mwm([(0,1,29), (0,3,35), (0,4,42), (1,2,12), (2,4,29), (3,4,44)])
|
||||
self.assertEqual(pairs, [(0,1), (3,4)])
|
||||
|
||||
def test15(self):
|
||||
pairs = mwm([(0,4,53), (0,5,42), (1,4,45), (2,4,59), (2,6,39), (4,5,69), (4,6,52)])
|
||||
self.assertEqual(pairs, [(0,5), (1,4), (2,6)])
|
||||
|
||||
def test16(self):
|
||||
pairs = mwm([(0,2,13), (1,2,11), (2,3,39), (2,4,17), (3,4,35)])
|
||||
self.assertEqual(pairs, [(0,2), (3,4)])
|
||||
|
||||
def test17(self):
|
||||
pairs = mwm([(0,1,48), (0,2,44), (0,4,48), (1,4,36), (3,4,31)])
|
||||
self.assertEqual(pairs, [(0,2), (1,4)])
|
||||
|
||||
|
||||
class TestVerificationFail(unittest.TestCase):
|
||||
"""Test failure handling in verification routine."""
|
||||
|
||||
def _make_context(
|
||||
self,
|
||||
edges,
|
||||
vertex_mate,
|
||||
vertex_dual_2x,
|
||||
nontrivial_blossom):
|
||||
ctx = Mock(spec=mwmatching._MatchingContext)
|
||||
ctx.graph = mwmatching._GraphInfo(edges)
|
||||
ctx.vertex_mate = vertex_mate
|
||||
ctx.vertex_dual_2x = vertex_dual_2x
|
||||
ctx.nontrivial_blossom = nontrivial_blossom
|
||||
return ctx
|
||||
|
||||
def test_success(self):
|
||||
edges = [(0,1,10), (1,2,11)]
|
||||
ctx = self._make_context(
|
||||
edges,
|
||||
vertex_mate=[-1, 2, 1],
|
||||
vertex_dual_2x=[0, 20, 2],
|
||||
nontrivial_blossom=[])
|
||||
mwmatching._verify_optimum(ctx)
|
||||
|
||||
def test_asymmetric_matching(self):
|
||||
edges = [(0,1,10), (1,2,11)]
|
||||
ctx = self._make_context(
|
||||
edges,
|
||||
vertex_mate=[-1, 2, 0],
|
||||
vertex_dual_2x=[0, 20, 2],
|
||||
nontrivial_blossom=[])
|
||||
with self.assertRaises(mwmatching.MatchingError):
|
||||
mwmatching._verify_optimum(ctx)
|
||||
|
||||
def test_nonexistent_matched_edge(self):
|
||||
edges = [(0,1,10), (1,2,11)]
|
||||
ctx = self._make_context(
|
||||
edges,
|
||||
vertex_mate=[2, -1, 0],
|
||||
vertex_dual_2x=[11, 11, 11],
|
||||
nontrivial_blossom=[])
|
||||
with self.assertRaises(mwmatching.MatchingError):
|
||||
mwmatching._verify_optimum(ctx)
|
||||
|
||||
def test_negative_vertex_dual(self):
|
||||
edges = [(0,1,10), (1,2,11)]
|
||||
ctx = self._make_context(
|
||||
edges,
|
||||
vertex_mate=[-1, 2, 1],
|
||||
vertex_dual_2x=[-2, 22, 0],
|
||||
nontrivial_blossom=[])
|
||||
with self.assertRaises(mwmatching.MatchingError):
|
||||
mwmatching._verify_optimum(ctx)
|
||||
|
||||
def test_unmatched_nonzero_dual(self):
|
||||
edges = [(0,1,10), (1,2,11)]
|
||||
ctx = self._make_context(
|
||||
edges,
|
||||
vertex_mate=[-1, 2, 1],
|
||||
vertex_dual_2x=[9, 11, 11],
|
||||
nontrivial_blossom=[])
|
||||
with self.assertRaises(mwmatching.MatchingError):
|
||||
mwmatching._verify_optimum(ctx)
|
||||
|
||||
def test_negative_edge_slack(self):
|
||||
edges = [(0,1,10), (1,2,11)]
|
||||
ctx = self._make_context(
|
||||
edges,
|
||||
vertex_mate=[-1, 2, 1],
|
||||
vertex_dual_2x=[0, 11, 11],
|
||||
nontrivial_blossom=[])
|
||||
with self.assertRaises(mwmatching.MatchingError):
|
||||
mwmatching._verify_optimum(ctx)
|
||||
|
||||
def test_matched_edge_slack(self):
|
||||
edges = [(0,1,10), (1,2,11)]
|
||||
ctx = self._make_context(
|
||||
edges,
|
||||
vertex_mate=[-1, 2, 1],
|
||||
vertex_dual_2x=[0, 20, 11],
|
||||
nontrivial_blossom=[])
|
||||
with self.assertRaises(mwmatching.MatchingError):
|
||||
mwmatching._verify_optimum(ctx)
|
||||
|
||||
def test_negative_blossom_dual(self):
|
||||
#
|
||||
# [0]--7--[1]--9--[2]--6--[3]
|
||||
# \ /
|
||||
# \----8-----/
|
||||
#
|
||||
edges = [(0,1,7), (0,2,8), (1,2,9), (2,3,6)]
|
||||
blossom = mwmatching._NonTrivialBlossom(
|
||||
subblossoms=[
|
||||
mwmatching._Blossom(0),
|
||||
mwmatching._Blossom(1),
|
||||
mwmatching._Blossom(2)],
|
||||
edges=[0,2,1])
|
||||
for sub in blossom.subblossoms:
|
||||
sub.parent = blossom
|
||||
blossom.dual_var = -1
|
||||
ctx = self._make_context(
|
||||
edges,
|
||||
vertex_mate=[1, 0, 3, 2],
|
||||
vertex_dual_2x=[4, 6, 8, 4],
|
||||
nontrivial_blossom=[blossom])
|
||||
with self.assertRaises(mwmatching.MatchingError):
|
||||
mwmatching._verify_optimum(ctx)
|
||||
|
||||
def test_blossom_not_full(self):
|
||||
#
|
||||
# [3] [4]
|
||||
# | |
|
||||
# 8 8
|
||||
# | |
|
||||
# [0]--7--[1]--5--[2]
|
||||
# \ /
|
||||
# \----2-----/
|
||||
#
|
||||
edges = [(0,1,7), (0,2,2), (1,2,5), (0,3,8), (1,4,8)]
|
||||
blossom = mwmatching._NonTrivialBlossom(
|
||||
subblossoms=[
|
||||
mwmatching._Blossom(0),
|
||||
mwmatching._Blossom(1),
|
||||
mwmatching._Blossom(2)],
|
||||
edges=[0,2,1])
|
||||
for sub in blossom.subblossoms:
|
||||
sub.parent = blossom
|
||||
blossom.dual_var = 2
|
||||
ctx = self._make_context(
|
||||
edges,
|
||||
vertex_mate=[3, 4, -1, 0, 1],
|
||||
vertex_dual_2x=[4, 10, 0, 12, 6],
|
||||
nontrivial_blossom=[blossom])
|
||||
with self.assertRaises(mwmatching.MatchingError):
|
||||
mwmatching._verify_optimum(ctx)
|
||||
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue