GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
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 <iostream> |
||
9 |
#include "phoenix_assert.h" |
||
10 |
#include "PStream.h" |
||
11 |
|||
12 |
///Test the PStream |
||
13 |
1 |
void testPStream(){ |
|
14 |
✓ | 2 |
PStream strOut; |
15 |
✓✓✓✓ ✓✓✓ |
1 |
phoenix_assert(strOut.open("testInt.bin", "w")); |
16 |
✓ | 1 |
strOut << 42; |
17 |
✓ | 1 |
strOut.close(); |
18 |
|||
19 |
✓ | 1 |
PStream strIn; |
20 |
✓✓✓✓ ✓✓✓ |
1 |
phoenix_assert(strIn.open("testInt.bin", "r")); |
21 |
1 |
int val(0); |
|
22 |
✓ | 1 |
strIn >> val; |
23 |
|||
24 |
✓✓✓ | 1 |
std::cout << "testPStream : val = " << val << std::endl; |
25 |
✓✓✓✓ |
1 |
phoenix_assert(val == 42); |
26 |
1 |
} |
|
27 |
|||
28 |
///Test the PStream |
||
29 |
1 |
void testPStreamTable(){ |
|
30 |
1 |
int tabInt [] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; |
|
31 |
1 |
int tabIntRead [] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
|
32 |
|||
33 |
✓ | 2 |
PStream strOut; |
34 |
✓✓✓✓ ✓✓✓ |
1 |
phoenix_assert(strOut.open("testTabInt.bin", "w")); |
35 |
✓ | 1 |
strOut.write(tabInt, 10lu); |
36 |
✓ | 1 |
strOut.close(); |
37 |
|||
38 |
✓ | 2 |
PStream strIn; |
39 |
✓✓✓✓ ✓✓✓ |
1 |
phoenix_assert(strIn.open("testTabInt.bin", "r")); |
40 |
✓ | 1 |
strIn.read(tabIntRead, 10lu); |
41 |
|||
42 |
✓✓✓ | 1 |
std::cout << "testPStreamTable : tabIntRead[9] = " << tabIntRead[9] << std::endl; |
43 |
✓✓ | 11 |
for(size_t i(0); i < 10lu; ++i){ |
44 |
✓✓✓✓ |
10 |
phoenix_assert(tabInt[i] == tabIntRead[i]); |
45 |
} |
||
46 |
1 |
} |
|
47 |
|||
48 |
///Test the PStream |
||
49 |
1 |
void testPStreamMatrix(){ |
|
50 |
1 |
int tabInt [] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; |
|
51 |
1 |
int tabIntRead [] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
|
52 |
|||
53 |
✓ | 2 |
PStream strOut; |
54 |
✓✓✓✓ ✓✓✓ |
1 |
phoenix_assert(strOut.open("testMatInt.bin", "w")); |
55 |
✓ | 1 |
strOut.write(tabInt, 2lu, 5lu, 0lu); |
56 |
✓ | 1 |
strOut.close(); |
57 |
|||
58 |
✓ | 2 |
PStream strIn; |
59 |
✓✓✓✓ ✓✓✓ |
1 |
phoenix_assert(strIn.open("testMatInt.bin", "r")); |
60 |
✓ | 1 |
strIn.read(tabIntRead, 2lu, 5lu, 0lu); |
61 |
|||
62 |
✓✓✓ | 1 |
std::cout << "testPStreamMatrix : tabIntRead[9] = " << tabIntRead[9] << std::endl; |
63 |
✓✓ | 11 |
for(size_t i(0); i < 10lu; ++i){ |
64 |
✓✓✓✓ |
10 |
phoenix_assert(tabInt[i] == tabIntRead[i]); |
65 |
} |
||
66 |
1 |
} |
|
67 |
|||
68 |
1 |
int main(int argc, char** argv){ |
|
69 |
1 |
testPStream(); |
|
70 |
1 |
testPStreamTable(); |
|
71 |
1 |
testPStreamMatrix(); |
|
72 |
1 |
return 0; |
|
73 |
} |
||
74 |
|||
75 |
Generated by: GCOVR (Version 4.2) |