1
0
Fork 0

Add corner cases to C++ unit test

This commit is contained in:
Joris van Rantwijk 2023-07-07 22:25:36 +02:00
parent 4b7fab3f43
commit d8d44f6171
1 changed files with 126 additions and 0 deletions

View File

@ -363,6 +363,132 @@ BOOST_AUTO_TEST_CASE(test_fail_bad_graph)
BOOST_AUTO_TEST_SUITE_END()
/* ********** Test corner cases of maximum_weight_matching() ********** */
BOOST_AUTO_TEST_SUITE(test_corner_cases)
BOOST_AUTO_TEST_CASE(test1)
{
EdgeVectorLong edges = {{0, 4, 26}, {1, 3, 31}, {1, 4, 49}};
Matching expect = {{0, 4}, {1, 3}};
BOOST_TEST(mwmatching::maximum_weight_matching(edges) == expect);
}
BOOST_AUTO_TEST_CASE(test2)
{
EdgeVectorLong edges = {{0, 2, 42}, {0, 4, 36}, {2, 3, 26}};
Matching expect = {{0, 4}, {2, 3}};
BOOST_TEST(mwmatching::maximum_weight_matching(edges) == expect);
}
BOOST_AUTO_TEST_CASE(test3)
{
EdgeVectorLong edges = {{0, 4, 43}, {1, 4, 28}, {2, 4, 38}};
Matching expect = {{0, 4}};
BOOST_TEST(mwmatching::maximum_weight_matching(edges) == expect);
}
BOOST_AUTO_TEST_CASE(test4)
{
EdgeVectorLong edges = {{0, 1, 50}, {0, 3, 46}, {0, 4, 45}};
Matching expect = {{0, 1}};
BOOST_TEST(mwmatching::maximum_weight_matching(edges) == expect);
}
BOOST_AUTO_TEST_CASE(test5)
{
EdgeVectorLong edges = {{0, 1, 35}, {0, 3, 36}, {0, 4, 46}};
Matching expect = {{0, 4}};
BOOST_TEST(mwmatching::maximum_weight_matching(edges) == expect);
}
BOOST_AUTO_TEST_CASE(test6)
{
EdgeVectorLong edges = {{0, 1, 50}, {0, 4, 51}, {0, 5, 34}, {1, 2, 43}, {1, 4, 57}, {2, 5, 47}, {3, 4, 17}};
Matching expect = {{0, 1}, {2, 5}, {3, 4}};
BOOST_TEST(mwmatching::maximum_weight_matching(edges) == expect);
}
BOOST_AUTO_TEST_CASE(test7)
{
EdgeVectorLong edges = {{0, 1, 34}, {0, 3, 19}, {1, 2, 45}, {1, 3, 30}, {1, 4, 37}, {2, 4, 36}};
Matching expect = {{0, 1}, {2, 4}};
BOOST_TEST(mwmatching::maximum_weight_matching(edges) == expect);
}
BOOST_AUTO_TEST_CASE(test8)
{
EdgeVectorLong edges = {{0, 1, 48}, {0, 3, 42}, {0, 4, 57}, {1, 3, 51}, {1, 5, 36}, {2, 3, 23}, {4, 5, 46}};
Matching expect = {{0, 1}, {2, 3}, {4, 5}};
BOOST_TEST(mwmatching::maximum_weight_matching(edges) == expect);
}
BOOST_AUTO_TEST_CASE(test9)
{
EdgeVectorLong edges = {{0, 1, 21}, {0, 2, 25}, {1, 4, 40}, {2, 3, 10}, {2, 5, 40}, {3, 5, 31}, {4, 5, 58}};
Matching expect = {{0, 2}, {1, 4}, {3, 5}};
BOOST_TEST(mwmatching::maximum_weight_matching(edges) == expect);
}
BOOST_AUTO_TEST_CASE(test10)
{
EdgeVectorLong edges = {{0, 2, 7}, {0, 5, 20}, {1, 2, 50}, {1, 4, 46}, {2, 3, 35}, {2, 4, 8}, {2, 5, 25}, {3, 5, 47}};
Matching expect = {{0, 5}, {1, 4}, {2, 3}};
BOOST_TEST(mwmatching::maximum_weight_matching(edges) == expect);
}
BOOST_AUTO_TEST_CASE(test11)
{
EdgeVectorLong edges = {{0, 1, 42}, {0, 2, 60}, {1, 3, 34}, {1, 4, 58}, {1, 5, 52}, {2, 5, 60}, {3, 5, 34}, {4, 5, 57}};
Matching expect = {{0, 2}, {1, 4}, {3, 5}};
BOOST_TEST(mwmatching::maximum_weight_matching(edges) == expect);
}
BOOST_AUTO_TEST_CASE(test12)
{
EdgeVectorLong edges = {{0, 1, 23}, {0, 2, 26}, {0, 3, 2}, {0, 4, 41}, {2, 4, 36}};
Matching expect = {{0, 1}, {2, 4}};
BOOST_TEST(mwmatching::maximum_weight_matching(edges) == expect);
}
BOOST_AUTO_TEST_CASE(test13)
{
EdgeVectorLong edges = {{0, 3, 58}, {0, 4, 49}, {1, 5, 34}, {2, 3, 22}, {2, 5, 42}, {4, 5, 36}};
Matching expect = {{0, 4}, {1, 5}, {2, 3}};
BOOST_TEST(mwmatching::maximum_weight_matching(edges) == expect);
}
BOOST_AUTO_TEST_CASE(test14)
{
EdgeVectorLong edges = {{0, 1, 29}, {0, 3, 35}, {0, 4, 42}, {1, 2, 12}, {2, 4, 29}, {3, 4, 44}};
Matching expect = {{0, 1}, {3, 4}};
BOOST_TEST(mwmatching::maximum_weight_matching(edges) == expect);
}
BOOST_AUTO_TEST_CASE(test15)
{
EdgeVectorLong edges = {{0, 4, 53}, {0, 5, 42}, {1, 4, 45}, {2, 4, 59}, {2, 6, 39}, {4, 5, 69}, {4, 6, 52}};
Matching expect = {{0, 5}, {1, 4}, {2, 6}};
BOOST_TEST(mwmatching::maximum_weight_matching(edges) == expect);
}
BOOST_AUTO_TEST_CASE(test16)
{
EdgeVectorLong edges = {{0, 2, 13}, {1, 2, 11}, {2, 3, 39}, {2, 4, 17}, {3, 4, 35}};
Matching expect = {{0, 2}, {3, 4}};
BOOST_TEST(mwmatching::maximum_weight_matching(edges) == expect);
}
BOOST_AUTO_TEST_CASE(test17)
{
EdgeVectorLong edges = {{0, 1, 48}, {0, 2, 44}, {0, 4, 48}, {1, 4, 36}, {3, 4, 31}};
Matching expect = {{0, 2}, {1, 4}};
BOOST_TEST(mwmatching::maximum_weight_matching(edges) == expect);
}
BOOST_AUTO_TEST_SUITE_END()
/* ********** Test adjust_weights_for_maximum_cardinality_matching() ********** */
template <typename WeightType>