tests are fixed; tests for integral_image_serial are implemented

This commit is contained in:
Dmitry Kokorin 2018-09-05 23:37:48 +03:00
parent f60ffee0bb
commit 163a9b1b5a

View file

@ -12,10 +12,35 @@ bool are_equal(const integral_image::Mat &lhv, const integral_image::Mat &rhv)
return cv::countNonZero(diff) == 0;
}
double spec_input_values[] = {0, 1, 2, 3, 4, 5};
double spec_expected_output_values[] = {0., 1., 2., 6., 6., 15.};
const integral_image::Mat spec_input(3, 2, spec_input_values);
const integral_image::Mat spec_expected_output(3, 2, spec_expected_output_values);
}
TEST_CASE("Integral image of an empty Mat is an empty Mat")
TEST_CASE("integral_image_serial can work with empty Mat", "[integral_image]")
{
using namespace integral_image;
Mat input;
auto output = integral_image_serial(input);
REQUIRE(output.data == NULL);
}
TEST_CASE("integral_image_serial correctly processes the example from the specification", "[integral_image]")
{
using namespace integral_image;
auto output = integral_image_serial(spec_input);
REQUIRE(are_equal(spec_expected_output, output));
}
TEST_CASE("integral_image_openmp can work with empty Mat", "[integral_image]")
{
using namespace integral_image;
@ -25,25 +50,10 @@ TEST_CASE("Integral image of an empty Mat is an empty Mat")
REQUIRE(output.data == NULL);
}
TEST_CASE("Integral image of a zero-valued Mat is the same sized zero-valued Mat")
TEST_CASE("integral_image_openmp correctly processes the example from the specification", "[integral_image]")
{
using namespace integral_image;
Mat input = Mat::zeros(20, 18);
auto output = integral_image_openmp(input);
REQUIRE(are_equal(input, output));
}
TEST_CASE("")
{
using namespace integral_image;
double input_values[] = {0, 1, 2, 3, 4, 5};
double expected_output_values[] = {0., 1., 2., 6., 6., 15.};
Mat input(3, 2, input_values);
Mat expected_output(3, 2, expected_output_values);
auto output = integral_image_openmp(input);
REQUIRE(are_equal(expected_output, output));
auto output = integral_image_openmp(spec_input);
REQUIRE(are_equal(spec_expected_output, output));
}