Commit 51fdb28e authored by David Frank's avatar David Frank
Browse files

#20 Add initial tests for noise generators

parent 9f1bc656
...@@ -19,3 +19,4 @@ ELSA_DOCTEST(PhantomGenerator) ...@@ -19,3 +19,4 @@ ELSA_DOCTEST(PhantomGenerator)
ELSA_DOCTEST(CircleTrajectoryGenerator) ELSA_DOCTEST(CircleTrajectoryGenerator)
ELSA_DOCTEST(LimitedAngleTrajectoryGenerator) ELSA_DOCTEST(LimitedAngleTrajectoryGenerator)
ELSA_DOCTEST(SphereTrajectoryGenerator) ELSA_DOCTEST(SphereTrajectoryGenerator)
ELSA_DOCTEST(NoiseGenerators)
#include "doctest/doctest.h"
#include "NoiseGenerators.h"
#include "VolumeDescriptor.h"
#include "testHelpers.h"
using namespace elsa;
using namespace doctest;
TEST_SUITE_BEGIN("generators");
TEST_CASE_TEMPLATE("Noise generators:", data_t, float, double)
{
GIVEN("A random data container")
{
auto [dc, mat] =
generateRandomContainer<data_t>(VolumeDescriptor({32, 32}), DataHandlerType::CPU);
WHEN("Adding no noise (NoNoiseGenerator)")
{
auto generator = NoNoiseGenerator{};
auto not_noisy = generator(dc);
THEN("Nothing happens") { CHECK_UNARY(isCwiseApprox(dc, not_noisy)); }
}
WHEN("Adding Gaussian noise (GaussianNoiseGenerator)")
{
auto generator = GaussianNoiseGenerator{0, 0.25};
auto noisy = generator(dc);
// TODO: Find a way to properly test this!
THEN("Something happens") { CHECK_UNARY_FALSE(isCwiseApprox(dc, noisy)); }
}
WHEN("Adding Poisson noise (PoissonNoiseGenerator)")
{
auto generator = PoissonNoiseGenerator{0};
auto noisy = generator(dc);
// TODO: Find a way to properly test this!
THEN("Something happens") { CHECK_UNARY_FALSE(isCwiseApprox(dc, noisy)); }
}
}
}
TEST_SUITE_END();
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment