 #include <gtest/gtest.h>
 #include "horizontal_path_aggregation.hpp"
+#include "internal.h"
 #include "path_aggregation_test.hpp"
 #include "generator.hpp"
 #include "test_utility.hpp"
 
 #include "debug.hpp"
 
-TEST(HorizontalPathAggregationTest, RandomLeft2Right){
+class HorizontalPathAggregation : public testing::TestWithParam<std::tuple<int, int, int>>
+{
+public:
+	int min_disp_;
+	int p1_, p2_;
+
+	virtual void SetUp(){
+		std::tie(min_disp_, p1_, p2_) = GetParam();
+	}
+};
+
+TEST_P(HorizontalPathAggregation, RandomLeft2Right){
 	static constexpr size_t width = 631, height = 479, disparity = 128;
-	static constexpr unsigned int p1 = 20, p2 = 100;
+
 	const auto left  = generate_random_sequence<sgm::feature_type>(width * height);
 	const auto right = generate_random_sequence<sgm::feature_type>(width * height);
 	const auto expect = path_aggregation(
-		left, right, width, height, disparity, p1, p2, 1, 0);
+		left, right, width, height, disparity, min_disp_, p1_, p2_, 1, 0);
 
 	const auto d_left = to_device_vector(left);
 	const auto d_right = to_device_vector(right);

		d_cost.data().get(),
		d_left.data().get(),
		d_right.data().get(),
		width, height, p1, p2, 0, 0);
	cudaStreamSynchronize(0);

	const auto actual = to_host_vector(d_cost);
	EXPECT_EQ(actual, expect);
	debug_compare(actual.data(), expect.data(), width, height, disparity);
}

TEST(HorizontalPathAggregationTest, RandomRight2Left){
	static constexpr size_t width = 640, height = 480, disparity = 64;
	static constexpr unsigned int p1 = 20, p2 = 40;
	const auto left  = generate_random_sequence<sgm::feature_type>(width * height);
	const auto right = generate_random_sequence<sgm::feature_type>(width * height);
	const auto expect = path_aggregation(
		left, right, width, height, disparity, p1, p2, -1, 0);

	const auto d_left = to_device_vector(left);
	const auto d_right = to_device_vector(right);

		d_cost.data().get(),
		d_left.data().get(),
		d_right.data().get(),
		width, height, p1_, p2_, min_disp_, 0);
	cudaStreamSynchronize(0);
	CudaKernelCheck();

	const auto actual = to_host_vector(d_cost);
	EXPECT_EQ(actual, expect);
	debug_compare(actual.data(), expect.data(), width, height, disparity);
}

INSTANTIATE_TEST_CASE_P(HorizontalPathAggregationTest, HorizontalPathAggregation, testing::Combine(
	testing::Values(0, 1, 10),
	testing::Values(10, 20),
	testing::Values(120, 40)
));
