LCOV - code coverage report
Current view: top level - tests - issue5.cpp (source / functions) Hit Total Coverage
Test: Lunchbox Lines: 16 16 100.0 %
Date: 2016-03-29 17:09:06 Functions: 3 3 100.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2012, Stefan.Eilemann@epfl.ch
       3             :  *
       4             :  * This library is free software; you can redistribute it and/or modify it under
       5             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       6             :  * by the Free Software Foundation.
       7             :  *
       8             :  * This library is distributed in the hope that it will be useful, but WITHOUT
       9             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      10             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      11             :  * details.
      12             :  *
      13             :  * You should have received a copy of the GNU Lesser General Public License
      14             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      15             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      16             :  */
      17             : 
      18             : #include <test.h>
      19             : 
      20             : #include <lunchbox/clock.h>
      21             : #include <lunchbox/condition.h>
      22             : #include <lunchbox/rng.h>
      23             : 
      24             : #include <iostream>
      25             : 
      26           1 : int main( int, char** )
      27             : {
      28           1 :     lunchbox::Condition condition;
      29           2 :     lunchbox::Clock clock;
      30             :     {
      31           1 :         TEST( !condition.timedWait( 2345 ));
      32           1 :         const float time = clock.getTimef();
      33           1 :         TESTINFO( time > 2344.f, time );
      34             :     }
      35           2 :     lunchbox::RNG rng;
      36           1 :     unsigned nTests = 30;
      37          32 :     while( nTests-- )
      38             :     {
      39          30 :         const uint32_t timeout = rng.get<uint8_t>() + 2;
      40             : 
      41          30 :         clock.reset();
      42          30 :         TEST( !condition.timedWait( timeout ));
      43          30 :         const float time = clock.getTimef();
      44             : 
      45          30 :         TESTINFO( time > float( timeout - 1 ), time << " < " << timeout );
      46             :     }
      47             : 
      48           2 :     return EXIT_SUCCESS;
      49           3 : }

Generated by: LCOV version 1.11