| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | |||
| 2 | /*************************************** | ||
| 3 | Auteur : Pierre Aubert | ||
| 4 | Mail : pierre.aubert@lapp.in2p3.fr | ||
| 5 | Licence : CeCILL-C | ||
| 6 | ****************************************/ | ||
| 7 | |||
| 8 | #include "PTimer.h" | ||
| 9 | #include "data_stream_assert.h" | ||
| 10 | |||
| 11 | ✗ | void testPTimerMoveConstructor(){ | |
| 12 | ✗ | PTimer a(1000000lu); | |
| 13 | ✗ | PTimer b(std::move(a)); | |
| 14 | ✗ | data_stream_assert(b.getEllapsedTime() == 1000000lu); | |
| 15 | ✗ | } | |
| 16 | |||
| 17 | ✗ | void testPTimerMoveAssignment(){ | |
| 18 | ✗ | PTimer c(500lu); | |
| 19 | ✗ | PTimer d(999lu); | |
| 20 | ✗ | d = std::move(c); | |
| 21 | ✗ | data_stream_assert(d.getEllapsedTime() == 500lu); | |
| 22 | ✗ | } | |
| 23 | |||
| 24 | /// @brief test if setTimer works | ||
| 25 | /// @return true on success, false on failure | ||
| 26 | 1 | bool testPtimer(){ | |
| 27 |
1/1✓ Branch 0 (2→3) taken 1 times.
|
1 | PTimer timer(1000l); |
| 28 | 1 | time_t currentTime = 0l; | |
| 29 |
1/1✓ Branch 0 (3→4) taken 1 times.
|
1 | timer.setStartTime(currentTime); |
| 30 |
1/1✓ Branch 0 (4→5) taken 1 times.
|
1 | bool bRet = !timer.isTime(currentTime); |
| 31 |
1/1✓ Branch 0 (5→6) taken 1 times.
|
1 | bRet&=timer.isTime(1000l); |
| 32 | 1 | return bRet; | |
| 33 | 1 | } | |
| 34 | |||
| 35 | 1 | bool testCopyPtimer(){ | |
| 36 |
1/1✓ Branch 0 (2→3) taken 1 times.
|
1 | PTimer timer(1000l); |
| 37 |
1/1✓ Branch 0 (3→4) taken 1 times.
|
1 | PTimer timer2(timer); |
| 38 | 1 | time_t currentTime = 0l; | |
| 39 |
1/1✓ Branch 0 (4→5) taken 1 times.
|
1 | timer.setEllapsedTime(currentTime); |
| 40 |
1/1✓ Branch 0 (5→6) taken 1 times.
|
1 | bool bRet = timer.getEllapsedTime() == currentTime; |
| 41 |
1/1✓ Branch 0 (6→7) taken 1 times.
|
1 | PTimer timer3; |
| 42 |
1/1✓ Branch 0 (7→8) taken 1 times.
|
1 | timer3 = timer; |
| 43 |
1/1✓ Branch 0 (8→9) taken 1 times.
|
1 | bRet&=timer3.getEllapsedTime() == currentTime; |
| 44 | 1 | return bRet; | |
| 45 | 1 | } | |
| 46 | |||
| 47 | 1 | int main(int argc, char** argv){ | |
| 48 | 1 | bool b = testPtimer(); | |
| 49 | 1 | b&=testCopyPtimer(); | |
| 50 | 1 | return b-1; | |
| 51 | } | ||
| 52 | |||
| 53 | |||
| 54 |