Skip to content

Commit

Permalink
[Unit tests] Added more unit tests for all the filters
Browse files Browse the repository at this point in the history
  • Loading branch information
spirosmaggioros committed Dec 26, 2024
1 parent 8d18ae8 commit 3d5701d
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/machine_learning/image/average_filter.cc
Original file line number Diff line number Diff line change
@@ -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<std::vector<int32_t> > image(50, std::vector<int32_t>(50, 42));

auto resulted = apply_avg_filter(image);
REQUIRE(resulted.size() != 0);
}

TEST_CASE("Testing average filter application with empty image") {
std::vector<std::vector<int32_t> > image;
CHECK_THROWS(apply_avg_filter(image));
}
16 changes: 16 additions & 0 deletions tests/machine_learning/image/gaussian_filter.cc
Original file line number Diff line number Diff line change
@@ -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<std::vector<int32_t> > image(50, std::vector<int32_t>(50, 42));

auto resulted = apply_gaussian_filter(image);
REQUIRE(resulted.size() != 0);
}

TEST_CASE("Testing gaussian filter application with empty image") {
std::vector<std::vector<int32_t> > image;
CHECK_THROWS(apply_gaussian_filter(image));
}
16 changes: 16 additions & 0 deletions tests/machine_learning/image/median_filter.cc
Original file line number Diff line number Diff line change
@@ -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<std::vector<int32_t> > image(50, std::vector<int32_t>(50, 42));

auto resulted = apply_median_filter(image);
REQUIRE(resulted.size() != 0);
}

TEST_CASE("Testing median filter application with empty image") {
std::vector<std::vector<int32_t> > image;
CHECK_THROWS(apply_median_filter(image));
}

0 comments on commit 3d5701d

Please sign in to comment.