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

          Line data    Source code
       1             : /**
       2             :  * @file test_Identity.cpp
       3             :  *
       4             :  * @brief Tests for Identity class
       5             :  *
       6             :  * @author Tobias Lasser - main code
       7             :  */
       8             : 
       9             : #include "doctest/doctest.h"
      10             : #include "Identity.h"
      11             : #include "VolumeDescriptor.h"
      12             : 
      13             : using namespace elsa;
      14             : using namespace doctest;
      15             : 
      16             : TEST_SUITE_BEGIN("core");
      17             : 
      18          22 : TEST_CASE_TEMPLATE("Identity: Testing construction", data_t, float, double)
      19             : {
      20           8 :     GIVEN("a descriptor")
      21             :     {
      22           8 :         IndexVector_t numCoeff(3);
      23           4 :         numCoeff << 13, 45, 28;
      24           8 :         VolumeDescriptor dd(numCoeff);
      25             : 
      26           6 :         WHEN("instantiating an Identity operator")
      27             :         {
      28           4 :             Identity<data_t> idOp(dd);
      29             : 
      30           4 :             THEN("the DataDescriptors are as expected")
      31             :             {
      32           2 :                 REQUIRE(idOp.getDomainDescriptor() == dd);
      33           2 :                 REQUIRE(idOp.getRangeDescriptor() == dd);
      34             :             }
      35             :         }
      36             : 
      37           6 :         WHEN("cloning an  Identity operator")
      38             :         {
      39           4 :             Identity<data_t> idOp(dd);
      40           4 :             auto idOpClone = idOp.clone();
      41             : 
      42           4 :             THEN("everything matches")
      43             :             {
      44           2 :                 REQUIRE(idOpClone.get() != &idOp);
      45           2 :                 REQUIRE(*idOpClone == idOp);
      46             :             }
      47             :         }
      48             :     }
      49           4 : }
      50             : 
      51          42 : TEST_CASE_TEMPLATE("Identity: Testing apply", data_t, float, double, complex<float>,
      52             :                    complex<double>)
      53             : {
      54          24 :     GIVEN("some data")
      55             :     {
      56          24 :         IndexVector_t numCoeff(2);
      57          12 :         numCoeff << 11, 13;
      58          24 :         VolumeDescriptor dd(numCoeff);
      59          24 :         DataContainer<data_t> input(dd);
      60          12 :         input = 3.3f;
      61             : 
      62          24 :         Identity<data_t> idOp(dd);
      63             : 
      64          18 :         WHEN("applying the identity")
      65             :         {
      66          12 :             auto output = idOp.apply(input);
      67             : 
      68          12 :             THEN("the result is as expected")
      69             :             {
      70           6 :                 REQUIRE(output.getSize() == input.getSize());
      71           6 :                 REQUIRE(input == output);
      72             :             }
      73             :         }
      74             : 
      75          18 :         WHEN("applying the adjoint of identity")
      76             :         {
      77          12 :             auto output = idOp.applyAdjoint(input);
      78             : 
      79          12 :             THEN("the results is as expected")
      80             :             {
      81           6 :                 REQUIRE(output.getSize() == input.getSize());
      82           6 :                 REQUIRE(input == output);
      83             :             }
      84             :         }
      85             :     }
      86          12 : }
      87             : TEST_SUITE_END();

Generated by: LCOV version 1.15