49 lines
1 KiB
C++
49 lines
1 KiB
C++
#define CATCH_CONFIG_MAIN
|
|
#include <thirdparty/catch.hpp>
|
|
|
|
#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;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
TEST_CASE("Integral image of an empty Mat is an empty Mat")
|
|
{
|
|
using namespace integral_image;
|
|
|
|
Mat input;
|
|
auto output = integral_image_openmp(input);
|
|
|
|
REQUIRE(output.data == NULL);
|
|
}
|
|
|
|
TEST_CASE("Integral image of a zero-valued Mat is the same sized zero-valued Mat")
|
|
{
|
|
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));
|
|
}
|