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

          Line data    Source code
       1             : /**
       2             :  * @file test_Constraint.cpp
       3             :  *
       4             :  * @brief Tests for the Constraint class
       5             :  *
       6             :  * @author Andi Braimllari
       7             :  */
       8             : 
       9             : #include <doctest/doctest.h>
      10             : 
      11             : #include "testHelpers.h"
      12             : #include "Constraint.h"
      13             : #include "Identity.h"
      14             : #include "Scaling.h"
      15             : #include "VolumeDescriptor.h"
      16             : 
      17             : using namespace elsa;
      18             : using namespace doctest;
      19             : 
      20           4 : TYPE_TO_STRING(complex<float>);
      21           4 : TYPE_TO_STRING(complex<double>);
      22             : 
      23             : TEST_SUITE_BEGIN("functionals");
      24             : 
      25          28 : TEST_CASE_TEMPLATE("Constraint: Testing construction and clone", TestType, float, complex<float>,
      26             :                    double, complex<double>)
      27             : {
      28          16 :     GIVEN("an Identity, a Scaling operator and a DataContainer")
      29             :     {
      30          16 :         IndexVector_t numCoeff(3);
      31           8 :         numCoeff << 13, 11, 24;
      32          16 :         VolumeDescriptor dd(numCoeff);
      33             : 
      34          16 :         Identity<TestType> A(dd);
      35          16 :         Scaling<TestType> B(dd, -1);
      36          16 :         DataContainer<TestType> c(dd);
      37           8 :         c = 0;
      38             : 
      39          16 :         WHEN("instantiating")
      40             :         {
      41          16 :             Constraint<TestType> constraint(A, B, c);
      42             : 
      43          12 :             THEN("the Constraint is as expected")
      44             :             {
      45           4 :                 REQUIRE_EQ(constraint.getOperatorA(), A);
      46           4 :                 REQUIRE_EQ(constraint.getOperatorB(), B);
      47           4 :                 REQUIRE_UNARY(isApprox(constraint.getDataVectorC(), c));
      48             :             }
      49             : 
      50          12 :             THEN("a clone behaves as expected")
      51             :             {
      52           8 :                 auto constraintClone = constraint.clone();
      53             : 
      54           4 :                 REQUIRE_NE(constraintClone.get(), &constraint);
      55           4 :                 REQUIRE_EQ(*constraintClone, constraint);
      56             :             }
      57             :         }
      58             :     }
      59           8 : }
      60             : 
      61             : TEST_SUITE_END();

Generated by: LCOV version 1.15