Darwin  1.0
Event loop based prototype framework
Looper.cc File Reference
#include <boost/test/included/unit_test.hpp>
#include <boost/exception/all.hpp>
#include <TTree.h>
#include "Looper.h"
+ Include dependency graph for Looper.cc:

Macros

#define DOXYGEN_SHOULD_SKIP_THIS
 
#define BOOST_TEST_MODULE   testLooper
 

Functions

 BOOST_AUTO_TEST_CASE (shared)
 
 BOOST_AUTO_TEST_CASE (unique)
 

Macro Definition Documentation

◆ BOOST_TEST_MODULE

#define BOOST_TEST_MODULE   testLooper

◆ DOXYGEN_SHOULD_SKIP_THIS

#define DOXYGEN_SHOULD_SKIP_THIS

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/2]

BOOST_AUTO_TEST_CASE ( shared  )
16  {
17  auto t = make_unique<TTree>("events", "events");
18 
19  // call empty tree
20  BOOST_REQUIRE_THROW( Looper(t, Slice{1,0}), boost::wrapexcept<invalid_argument> );
21 
22  // normal call (filling 100 events in two steps)
23  for (Looper looper(100ll, {2,0}); looper(); ++looper) t->Fill();
24  for (Looper looper(100ll, {2,1}); looper(); ++looper) t->Fill();
25 
26  // normal call
27  BOOST_REQUIRE_NO_THROW( Looper(t, {10,5}) ); // 10 slices, take here the fifth, covering [50,60[
28 
29  // wrong order (5 slices, 10th slice)
30  BOOST_REQUIRE_THROW( Looper(t, {5,10}), boost::wrapexcept<invalid_argument> );
31 
32  // too many slices (1000 > 100)
33  BOOST_REQUIRE_THROW( Looper(t, {1000,0}), boost::wrapexcept<invalid_argument> );
34 
35  {
36  Looper looper(t, {10,5});
37  BOOST_TEST( *looper == 50 );
38  BOOST_TEST( looper() );
39  ++looper;
40  BOOST_TEST( *looper == 51 );
41  }
42 
43  long long i = 50;
44  for (Looper looper(t, {10,5}); looper(); ++looper) {
45  BOOST_TEST( *looper == i );
46  ++i;
47  if (i == 54) break; // a warning should be printed
48  }
49  }

◆ BOOST_AUTO_TEST_CASE() [2/2]

BOOST_AUTO_TEST_CASE ( unique  )
52  {
53  // Test constructor with a unique_ptr argument
54  auto t = make_unique<TTree>("events", "events");
55  BOOST_REQUIRE_THROW( Looper(t, Slice{1,0}), boost::wrapexcept<invalid_argument> );
56  }
Darwin::Tools::Slice
std::pair< unsigned, unsigned > Slice
current slice (>=0) / total number of slices (>0)
Definition: Looper.h:21
Darwin::Tools::Looper
Facility to loop over a n-tuple, including parallelisation and printing.
Definition: Looper.h:33