LCOV - code coverage report
Current view: top level - generators/tests - test_NoiseGenerators.cpp (source / functions) Hit Total Coverage
Test: test_coverage.info.cleaned Lines: 15 15 100.0 %
Date: 2022-02-28 03:37:41 Functions: 5 5 100.0 %

          Line data    Source code
       1             : #include "doctest/doctest.h"
       2             : #include "NoiseGenerators.h"
       3             : #include "VolumeDescriptor.h"
       4             : #include "testHelpers.h"
       5             : 
       6             : using namespace elsa;
       7             : using namespace doctest;
       8             : 
       9             : TEST_SUITE_BEGIN("generators");
      10             : 
      11          12 : TEST_CASE_TEMPLATE("Noise generators:", data_t, float, double)
      12             : {
      13          12 :     GIVEN("A random data container")
      14             :     {
      15          18 :         auto [dc, mat] =
      16             :             generateRandomContainer<data_t>(VolumeDescriptor({32, 32}), DataHandlerType::CPU);
      17             : 
      18           8 :         WHEN("Adding no noise (NoNoiseGenerator)")
      19             :         {
      20             :             auto generator = NoNoiseGenerator{};
      21           4 :             auto not_noisy = generator(dc);
      22             : 
      23           2 :             THEN("Nothing happens") { CHECK_UNARY(isCwiseApprox(dc, not_noisy)); }
      24             :         }
      25             : 
      26           8 :         WHEN("Adding Gaussian noise (GaussianNoiseGenerator)")
      27             :         {
      28           2 :             auto generator = GaussianNoiseGenerator{0, 0.25};
      29           4 :             auto noisy = generator(dc);
      30             : 
      31             :             // TODO: Find a way to properly test this!
      32           2 :             THEN("Something happens") { CHECK_UNARY_FALSE(isCwiseApprox(dc, noisy)); }
      33             :         }
      34             : 
      35           8 :         WHEN("Adding Poisson noise (PoissonNoiseGenerator)")
      36             :         {
      37           2 :             auto generator = PoissonNoiseGenerator{0};
      38           4 :             auto noisy = generator(dc);
      39             : 
      40             :             // TODO: Find a way to properly test this!
      41           2 :             THEN("Something happens") { CHECK_UNARY_FALSE(isCwiseApprox(dc, noisy)); }
      42             :         }
      43             :     }
      44           6 : }
      45             : 
      46             : TEST_SUITE_END();

Generated by: LCOV version 1.15