From 3d5701d6becd0de546b1220d7652004be89ef61b Mon Sep 17 00:00:00 2001 From: Spiros Maggioros Date: Thu, 26 Dec 2024 02:56:02 +0200 Subject: [PATCH] [Unit tests] Added more unit tests for all the filters --- tests/machine_learning/image/average_filter.cc | 16 ++++++++++++++++ tests/machine_learning/image/gaussian_filter.cc | 16 ++++++++++++++++ tests/machine_learning/image/median_filter.cc | 16 ++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 tests/machine_learning/image/average_filter.cc create mode 100644 tests/machine_learning/image/gaussian_filter.cc create mode 100644 tests/machine_learning/image/median_filter.cc diff --git a/tests/machine_learning/image/average_filter.cc b/tests/machine_learning/image/average_filter.cc new file mode 100644 index 00000000..dc8b5704 --- /dev/null +++ b/tests/machine_learning/image/average_filter.cc @@ -0,0 +1,16 @@ +#include "../../../src/machine_learning/image/filters/average_filter.h" +#include "../../../third_party/catch.hpp" + +using namespace avg_filter; + +TEST_CASE("Testing average filter application") { + std::vector > image(50, std::vector(50, 42)); + + auto resulted = apply_avg_filter(image); + REQUIRE(resulted.size() != 0); +} + +TEST_CASE("Testing average filter application with empty image") { + std::vector > image; + CHECK_THROWS(apply_avg_filter(image)); +} diff --git a/tests/machine_learning/image/gaussian_filter.cc b/tests/machine_learning/image/gaussian_filter.cc new file mode 100644 index 00000000..8cf5a226 --- /dev/null +++ b/tests/machine_learning/image/gaussian_filter.cc @@ -0,0 +1,16 @@ +#include "../../../src/machine_learning/image/filters/gaussian_filter.h" +#include "../../../third_party/catch.hpp" + +using namespace gaussian_filter; + +TEST_CASE("Testing gaussian filter application") { + std::vector > image(50, std::vector(50, 42)); + + auto resulted = apply_gaussian_filter(image); + REQUIRE(resulted.size() != 0); +} + +TEST_CASE("Testing gaussian filter application with empty image") { + std::vector > image; + CHECK_THROWS(apply_gaussian_filter(image)); +} diff --git a/tests/machine_learning/image/median_filter.cc b/tests/machine_learning/image/median_filter.cc new file mode 100644 index 00000000..079364ea --- /dev/null +++ b/tests/machine_learning/image/median_filter.cc @@ -0,0 +1,16 @@ +#include "../../../src/machine_learning/image/filters/median_filter.h" +#include "../../../third_party/catch.hpp" + +using namespace median_filter; + +TEST_CASE("Testing median filter application") { + std::vector > image(50, std::vector(50, 42)); + + auto resulted = apply_median_filter(image); + REQUIRE(resulted.size() != 0); +} + +TEST_CASE("Testing median filter application with empty image") { + std::vector > image; + CHECK_THROWS(apply_median_filter(image)); +}