LCOV - code coverage report
Current view: top level - UTests - testMethod.cpp (source / functions) Hit Total Coverage
Test: Coverage example Lines: 25 25 100.0 %
Date: 2021-12-02 17:21:05 Functions: 6 6 100.0 %

          Line data    Source code
       1             : ///////////////////////////////////////////////////////////////////////////
       2             : // Spetabaru - Berenger Bramas MPCDF - 2017
       3             : // Under LGPL Licence, please you must read the LICENCE file.
       4             : ///////////////////////////////////////////////////////////////////////////
       5             : 
       6             : #include "UTester.hpp"
       7             : 
       8             : #include "Data/SpDataAccessMode.hpp"
       9             : #include "Utils/SpUtils.hpp"
      10             : 
      11             : #include "Task/SpTask.hpp"
      12             : #include "Legacy/SpRuntime.hpp"
      13             : 
      14             : class MethodTest : public UTester< MethodTest > {
      15             :     using Parent = UTester< MethodTest >;
      16             : 
      17           1 :     void TestBasic(){
      18           1 :         const int NumThreads = SpUtils::DefaultNumThreads();
      19           2 :         SpRuntime runtime(NumThreads);
      20             : 
      21           1 :         const int initVal = 1;
      22           1 :         int writeVal = 0;
      23             : 
      24             :         class C_constint{
      25             :         public:
      26             :             C_constint() = default;
      27             :             C_constint(const C_constint&) = default;
      28             :             C_constint& operator=(const C_constint&) = default;
      29             :             C_constint(C_constint&&) = default;
      30             :             C_constint& operator=(C_constint&&) = default;
      31             : 
      32           1 :             void operator()(const int& /*initValParam*/) const{
      33             : 
      34           1 :             }
      35             :         };
      36             : 
      37             :         C_constint o1;
      38             :         {
      39           4 :             auto returnValue = runtime.task(SpRead(initVal), o1);
      40           1 :             returnValue.getValue();
      41             :         }
      42             : 
      43             :         class C_constint_intref{
      44             :         public:
      45             :             C_constint_intref() = default;
      46             :             C_constint_intref(const C_constint_intref&) = default;
      47             :             C_constint_intref& operator=(const C_constint_intref&) = default;
      48             :             C_constint_intref(C_constint_intref&&) = default;
      49             :             C_constint_intref& operator=(C_constint_intref&&) = default;
      50             : 
      51           1 :             bool operator()(const int& /*initValParam*/, int& /*writeValParam*/) const{
      52           1 :                 return true;
      53             :             }
      54             :         };
      55             : 
      56             :         C_constint_intref o2;
      57             :         {
      58           2 :             auto returnValue = runtime.task(SpRead(initVal), SpWrite(writeVal), o2);
      59           1 :             returnValue.wait();
      60           1 :             UASSERTETRUE(returnValue.getValue() == true);
      61             :         }
      62             : 
      63             :         class C_intref{
      64             :         public:
      65             :             C_intref() = default;
      66             :             C_intref(const C_intref&) = default;
      67             :             C_intref& operator=(const C_intref&) = default;
      68             :             C_intref(C_intref&&) = default;
      69             :             C_intref& operator=(C_intref&&) = default;
      70             : 
      71           1 :             int operator()(const int& /*writeValParam*/) const{
      72           1 :                 return 99;
      73             :             }
      74             :         };
      75             : 
      76             :         C_intref o3;
      77             :         {
      78           1 :             auto returnValue = runtime.task(SpRead(writeVal),o3);
      79           1 :             UASSERTETRUE(returnValue.getValue() == 99);
      80             :         }
      81             : 
      82           1 :         runtime.waitAllTasks();
      83             : 
      84           1 :         runtime.stopAllThreads();
      85           1 :     }
      86             : 
      87           1 :     void SetTests() {
      88           1 :         Parent::AddTest(&MethodTest::TestBasic, "Basic test for vec type");
      89           1 :     }
      90             : };
      91             : 
      92             : // You must do this
      93           1 : TestClass(MethodTest)
      94             : 
      95             : 

Generated by: LCOV version 1.14