Added some more tests for the max_cost_assignment() function.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%404185
This commit is contained in:
Davis King 2011-03-23 00:32:15 +00:00
parent 4f46a90104
commit 926c2afa6f
1 changed files with 14 additions and 1 deletions

View File

@ -117,9 +117,21 @@ namespace
std::vector<long> assign = brute_force_max_cost_assignment(cost); std::vector<long> assign = brute_force_max_cost_assignment(cost);
const T true_eval = assignment_cost(cost, assign); T true_eval = assignment_cost(cost, assign);
assign = max_cost_assignment(cost); assign = max_cost_assignment(cost);
DLIB_TEST(assignment_cost(cost,assign) == true_eval);
assign = max_cost_assignment(matrix_cast<char>(cost));
DLIB_TEST(assignment_cost(cost,assign) == true_eval);
cost = matrix_cast<T>(randm(size,size,rnd)*range);
assign = brute_force_max_cost_assignment(cost);
true_eval = assignment_cost(cost, assign);
assign = max_cost_assignment(cost);
DLIB_TEST(assignment_cost(cost,assign) == true_eval);
assign = max_cost_assignment(matrix_cast<unsigned char>(cost));
DLIB_TEST(assignment_cost(cost,assign) == true_eval);
assign = max_cost_assignment(matrix_cast<typename unsigned_type<T>::type>(cost));
DLIB_TEST(assignment_cost(cost,assign) == true_eval); DLIB_TEST(assignment_cost(cost,assign) == true_eval);
} }
@ -131,6 +143,7 @@ namespace
if ((i%100) == 0) if ((i%100) == 0)
print_spinner(); print_spinner();
test_hungarian<short>();
test_hungarian<int>(); test_hungarian<int>();
test_hungarian<long>(); test_hungarian<long>();
} }