LCOV - code coverage report
Current view: top level - elsa/operators/tests - test_Identity.cpp (source / functions) Hit Total Coverage
Test: coverage-all.lcov Lines: 56 56 100.0 %
Date: 2022-08-25 03:05:39 Functions: 6 6 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             : TEST_CASE_TEMPLATE("Identity: Testing construction", data_t, float, double)
      19           4 : {
      20           4 :     GIVEN("a descriptor")
      21           4 :     {
      22           4 :         IndexVector_t numCoeff(3);
      23           4 :         numCoeff << 13, 45, 28;
      24           4 :         VolumeDescriptor dd(numCoeff);
      25             : 
      26           4 :         WHEN("instantiating an Identity operator")
      27           4 :         {
      28           2 :             Identity<data_t> idOp(dd);
      29             : 
      30           2 :             THEN("the DataDescriptors are as expected")
      31           2 :             {
      32           2 :                 REQUIRE(idOp.getDomainDescriptor() == dd);
      33           2 :                 REQUIRE(idOp.getRangeDescriptor() == dd);
      34           2 :             }
      35           2 :         }
      36             : 
      37           4 :         WHEN("cloning an  Identity operator")
      38           4 :         {
      39           2 :             Identity<data_t> idOp(dd);
      40           2 :             auto idOpClone = idOp.clone();
      41             : 
      42           2 :             THEN("everything matches")
      43           2 :             {
      44           2 :                 REQUIRE(idOpClone.get() != &idOp);
      45           2 :                 REQUIRE(*idOpClone == idOp);
      46           2 :             }
      47           2 :         }
      48           4 :     }
      49           4 : }
      50             : 
      51             : TEST_CASE_TEMPLATE("Identity: Testing apply", data_t, float, double, complex<float>,
      52             :                    complex<double>)
      53           8 : {
      54           8 :     GIVEN("some data")
      55           8 :     {
      56           8 :         IndexVector_t numCoeff(2);
      57           8 :         numCoeff << 11, 13;
      58           8 :         VolumeDescriptor dd(numCoeff);
      59           8 :         DataContainer<data_t> input(dd);
      60           8 :         input = 3.3f;
      61             : 
      62           8 :         Identity<data_t> idOp(dd);
      63             : 
      64           8 :         WHEN("applying the identity")
      65           8 :         {
      66           4 :             auto output = idOp.apply(input);
      67             : 
      68           4 :             THEN("the result is as expected")
      69           4 :             {
      70           4 :                 REQUIRE(output.getSize() == input.getSize());
      71           4 :                 REQUIRE(input == output);
      72           4 :             }
      73           4 :         }
      74             : 
      75           8 :         WHEN("applying the adjoint of identity")
      76           8 :         {
      77           4 :             auto output = idOp.applyAdjoint(input);
      78             : 
      79           4 :             THEN("the results is as expected")
      80           4 :             {
      81           4 :                 REQUIRE(output.getSize() == input.getSize());
      82           4 :                 REQUIRE(input == output);
      83           4 :             }
      84           4 :         }
      85           8 :     }
      86           8 : }
      87             : TEST_SUITE_END();

Generated by: LCOV version 1.14