Directory: | ./ |
---|---|
File: | tmp_project/PhoenixString/TESTS/TEST_PSTREAM/main.cpp |
Date: | 2024-07-27 10:53:27 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 45 | 45 | 100.0% |
Branches: | 82 | 82 | 100.0% |
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 |
1/1✓ Branch 1 taken 1 times.
|
1 | PStream strOut; |
15 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(strOut.open("testInt.bin", "w")); |
16 |
1/1✓ Branch 1 taken 1 times.
|
1 | strOut << 42; |
17 |
1/1✓ Branch 1 taken 1 times.
|
1 | strOut.close(); |
18 | |||
19 |
1/1✓ Branch 1 taken 1 times.
|
1 | PStream strIn; |
20 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(strIn.open("testInt.bin", "r")); |
21 | 1 | int val(0); | |
22 |
1/1✓ Branch 1 taken 1 times.
|
1 | strIn >> val; |
23 | |||
24 |
3/3✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
|
1 | std::cout << "testPStream : val = " << val << std::endl; |
25 |
4/4✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
|
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 |
1/1✓ Branch 1 taken 1 times.
|
1 | PStream strOut; |
34 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(strOut.open("testTabInt.bin", "w")); |
35 |
1/1✓ Branch 1 taken 1 times.
|
1 | strOut.write(tabInt, 10lu); |
36 |
1/1✓ Branch 1 taken 1 times.
|
1 | strOut.close(); |
37 | |||
38 |
1/1✓ Branch 1 taken 1 times.
|
1 | PStream strIn; |
39 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(strIn.open("testTabInt.bin", "r")); |
40 |
1/1✓ Branch 1 taken 1 times.
|
1 | strIn.read(tabIntRead, 10lu); |
41 | |||
42 |
3/3✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
|
1 | std::cout << "testPStreamTable : tabIntRead[9] = " << tabIntRead[9] << std::endl; |
43 |
2/2✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1 times.
|
11 | for(size_t i(0); i < 10lu; ++i){ |
44 |
4/4✓ Branch 2 taken 10 times.
✓ Branch 6 taken 10 times.
✓ Branch 10 taken 10 times.
✓ Branch 13 taken 10 times.
|
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 |
1/1✓ Branch 1 taken 1 times.
|
1 | PStream strOut; |
54 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(strOut.open("testMatInt.bin", "w")); |
55 |
1/1✓ Branch 1 taken 1 times.
|
1 | strOut.write(tabInt, 2lu, 5lu, 0lu); |
56 |
1/1✓ Branch 1 taken 1 times.
|
1 | strOut.close(); |
57 | |||
58 |
1/1✓ Branch 1 taken 1 times.
|
1 | PStream strIn; |
59 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(strIn.open("testMatInt.bin", "r")); |
60 |
1/1✓ Branch 1 taken 1 times.
|
1 | strIn.read(tabIntRead, 2lu, 5lu, 0lu); |
61 | |||
62 |
3/3✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
|
1 | std::cout << "testPStreamMatrix : tabIntRead[9] = " << tabIntRead[9] << std::endl; |
63 |
2/2✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1 times.
|
11 | for(size_t i(0); i < 10lu; ++i){ |
64 |
4/4✓ Branch 2 taken 10 times.
✓ Branch 6 taken 10 times.
✓ Branch 10 taken 10 times.
✓ Branch 13 taken 10 times.
|
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 | |||
76 |