#define CATCH_CONFIG_MAIN #include #include "integral_image.h" namespace { bool are_equal(const integral_image::Mat &lhv, const integral_image::Mat &rhv) { auto diff = (lhv != 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_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; Mat input; auto output = integral_image_openmp(input); REQUIRE(output.data == NULL); } TEST_CASE("integral_image_openmp correctly processes the example from the specification", "[integral_image]") { using namespace integral_image; auto output = integral_image_openmp(spec_input); REQUIRE(are_equal(spec_expected_output, output)); }