LCOV - code coverage report
Current view: top level - UTests - testReturn.cpp (source / functions) Hit Total Coverage
Test: Coverage example Lines: 28 30 93.3 %
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 ReturnTest : public UTester< ReturnTest > {
      15             :     using Parent = UTester< ReturnTest >;
      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             :         {
      25           0 :             auto returnValue = runtime.task(SpRead(initVal),
      26           2 :                          [this, &initVal](const int& initValParam){
      27           1 :                 UASSERTETRUE(&initValParam == &initVal);
      28           5 :             });
      29           1 :             returnValue.getValue();
      30             :         }
      31             : 
      32             :         {
      33           1 :             auto returnValue = runtime.task(SpRead(initVal), SpWrite(writeVal),
      34           1 :                          [](const int& initValParam, int& writeValParam) -> bool {
      35           1 :                 writeValParam += initValParam;
      36           1 :                 return true;
      37           2 :             });
      38           1 :             returnValue.wait();
      39           1 :             UASSERTETRUE(returnValue.getValue() == true);
      40             :         }
      41             : 
      42             :         {
      43           0 :             auto returnValue = runtime.task(SpRead(writeVal),
      44           1 :                          [this](const int& writeValParam) -> int {
      45           1 :                 UASSERTETRUE(writeValParam == initVal);
      46           1 :                 return 99;
      47           1 :             });
      48           1 :             UASSERTETRUE(returnValue.getValue() == 99);
      49             :         }
      50             : 
      51           1 :         runtime.waitAllTasks();
      52             : 
      53           1 :         runtime.stopAllThreads();
      54           1 :     }
      55             : 
      56           1 :     void SetTests() {
      57           1 :         Parent::AddTest(&ReturnTest::TestBasic, "Basic test for vec type");
      58           1 :     }
      59             : };
      60             : 
      61             : // You must do this
      62           1 : TestClass(ReturnTest)
      63             : 
      64             : 

Generated by: LCOV version 1.14