RootOutputClosingCriteria_t.cc
Go to the documentation of this file.
1 #define BOOST_TEST_MODULE (RootOutputClosingCriteria_t)
3 
5 
6 #include <thread>
7 
10 
11 using file_size_t = unsigned;
12 using no_events_t = unsigned;
13 using seconds_t = std::chrono::seconds;
14 
15 namespace {
16  constexpr auto max_size = std::numeric_limits<file_size_t>::max();
17  constexpr auto max_events = std::numeric_limits<no_events_t>::max();
18  constexpr auto max_age = seconds_t::max();
19 
20  // The minimum duration a user can specify for output-file closing
21  // is 1 second. This is different than seconds_t::min().
22  constexpr auto
23  one_second()
24  {
25  return seconds_t{1};
26  }
27 
28 } // namespace
29 
30 BOOST_AUTO_TEST_SUITE(RootOutputClosingCriteria_t)
31 
33 {
34  FileProperties const closingCriteria{
35  max_events, -1u, -1u, -1u, max_size, max_age};
36  ClosingCriteria c{closingCriteria, "Unset"};
37 
38  FileProperties const fp{0, 0, 0, 0, 0, one_second()};
39  BOOST_CHECK(!c.should_close(fp));
40 }
41 
42 BOOST_AUTO_TEST_CASE(TwoSecondSleep)
43 {
44  using namespace std::chrono;
45  FileProperties const closingProperties{
46  max_events, -1u, -1u, -1u, max_size, one_second()};
47  ClosingCriteria c{closingProperties, "Unset"};
48 
49  auto const beginTime = steady_clock::now();
50  std::this_thread::sleep_for(seconds_t{2});
51  auto const age = steady_clock::now() - beginTime;
52 
53  FileProperties const currentProperties{
54  0, 0, 0, 0, 0, duration_cast<seconds>(age)};
55  BOOST_CHECK(c.should_close(currentProperties));
56 }
57 
58 BOOST_AUTO_TEST_SUITE_END()
std::chrono::seconds seconds_t
BOOST_AUTO_TEST_CASE(MaxCriteria)
unsigned no_events_t
unsigned file_size_t