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 "phoenix_check.h" | ||
11 | #include "openFileStream.h" | ||
12 | |||
13 | ///Check the openFileStream | ||
14 | 1 | void checkOpenFileStream(){ | |
15 |
1/1✓ Branch 0 (2→3) taken 1 times.
|
1 | std::ofstream fs; |
16 |
7/7✓ Branch 0 (5→6) taken 1 times.
✓ Branch 2 (8→9) taken 1 times.
✓ Branch 4 (11→12) taken 1 times.
✓ Branch 6 (12→13) taken 1 times.
✓ Branch 8 (13→14) taken 1 times.
✓ Branch 10 (14→15) taken 1 times.
✓ Branch 12 (15→16) taken 1 times.
|
5 | phoenix_assert(openFileStream(fs, PPath("fileNameOut.txt"))); |
17 |
2/2✓ Branch 0 (24→25) taken 1 times.
✓ Branch 2 (25→26) taken 1 times.
|
1 | fs << "some content" << std::endl; |
18 |
1/1✓ Branch 0 (26→27) taken 1 times.
|
1 | fs.close(); |
19 | |||
20 |
1/1✓ Branch 0 (27→28) taken 1 times.
|
1 | std::ifstream ifs; |
21 |
7/7✓ Branch 0 (30→31) taken 1 times.
✓ Branch 2 (33→34) taken 1 times.
✓ Branch 4 (36→37) taken 1 times.
✓ Branch 6 (37→38) taken 1 times.
✓ Branch 8 (38→39) taken 1 times.
✓ Branch 10 (39→40) taken 1 times.
✓ Branch 12 (40→41) taken 1 times.
|
5 | phoenix_assert(openFileStream(ifs, PPath("fileNameOut.txt"))); |
22 |
1/1✓ Branch 0 (49→50) taken 1 times.
|
1 | PString fileContent(""); |
23 |
1/1✓ Branch 0 (50→51) taken 1 times.
|
1 | ifs >> fileContent; |
24 |
1/1✓ Branch 0 (51→52) taken 1 times.
|
1 | ifs.close(); |
25 | |||
26 |
5/5✓ Branch 0 (54→55) taken 1 times.
✓ Branch 2 (57→58) taken 1 times.
✓ Branch 4 (60→61) taken 1 times.
✓ Branch 6 (61→62) taken 1 times.
✓ Branch 8 (62→63) taken 1 times.
|
6 | phoenix_assert(fileContent == "some"); //The input stream cut on blank characters |
27 | // std::cout << "checkOpenFileStream : fileContent = '" << fileContent << "'" << std::endl; | ||
28 | |||
29 |
7/7✓ Branch 0 (71→72) taken 1 times.
✓ Branch 2 (74→75) taken 1 times.
✓ Branch 4 (77→78) taken 1 times.
✓ Branch 6 (78→79) taken 1 times.
✓ Branch 8 (79→80) taken 1 times.
✓ Branch 10 (80→81) taken 1 times.
✓ Branch 12 (81→82) taken 1 times.
|
6 | phoenix_assert(!openFileStream(fs, PPath("outputDirWhichNotExist/test.txt"))); |
30 |
7/7✓ Branch 0 (92→93) taken 1 times.
✓ Branch 2 (95→96) taken 1 times.
✓ Branch 4 (98→99) taken 1 times.
✓ Branch 6 (99→100) taken 1 times.
✓ Branch 8 (100→101) taken 1 times.
✓ Branch 10 (101→102) taken 1 times.
✓ Branch 12 (102→103) taken 1 times.
|
6 | phoenix_assert(!openFileStream(ifs, PPath("unexistingFileNameOut.txt"))); |
31 |
7/7✓ Branch 0 (113→114) taken 1 times.
✓ Branch 2 (116→117) taken 1 times.
✓ Branch 4 (119→120) taken 1 times.
✓ Branch 6 (120→121) taken 1 times.
✓ Branch 8 (121→122) taken 1 times.
✓ Branch 10 (122→123) taken 1 times.
✓ Branch 12 (123→124) taken 1 times.
|
6 | phoenix_assert(!openFileStream(fs, PPath(""))); |
32 |
7/7✓ Branch 0 (134→135) taken 1 times.
✓ Branch 2 (137→138) taken 1 times.
✓ Branch 4 (140→141) taken 1 times.
✓ Branch 6 (141→142) taken 1 times.
✓ Branch 8 (142→143) taken 1 times.
✓ Branch 10 (143→144) taken 1 times.
✓ Branch 12 (144→145) taken 1 times.
|
5 | phoenix_assert(!openFileStream(ifs, PPath(""))); |
33 | 1 | } | |
34 | |||
35 | ///Check the openFileStream | ||
36 | /** @param fileName : name of the file to be used as a model | ||
37 | * @param nbFile : number of files to be opened | ||
38 | * @return true on success, false otherwise | ||
39 | */ | ||
40 | 20 | bool checkOpenVecFileStream(const PPath & fileName, size_t nbFile){ | |
41 | 20 | bool b(true); | |
42 | 20 | PVecOFStream vecOut; | |
43 |
1/1✓ Branch 0 (3→4) taken 20 times.
|
20 | b &= openFileStream(vecOut, fileName, nbFile); |
44 |
2/2✓ Branch 0 (9→5) taken 90 times.
✓ Branch 1 (9→10) taken 20 times.
|
110 | for(size_t i(0lu); i < nbFile; ++i){ |
45 |
2/2✓ Branch 0 (6→7) taken 90 times.
✓ Branch 2 (7→8) taken 90 times.
|
90 | vecOut[i] << i << std::endl; |
46 | } | ||
47 |
1/1✓ Branch 0 (10→11) taken 20 times.
|
20 | closeFileStream(vecOut); |
48 | 20 | PVecIFStream vecIn; | |
49 |
1/1✓ Branch 0 (12→13) taken 20 times.
|
20 | b &= openFileStream(vecIn, fileName, nbFile); |
50 |
2/2✓ Branch 0 (23→14) taken 90 times.
✓ Branch 1 (23→24) taken 20 times.
|
110 | for(size_t i(0lu); i < nbFile; ++i){ |
51 | 90 | size_t val(0lu); | |
52 |
1/1✓ Branch 0 (15→16) taken 90 times.
|
90 | vecIn[i] >> val; |
53 |
2/2✓ Branch 0 (18→19) taken 90 times.
✓ Branch 2 (19→20) taken 90 times.
|
180 | b &= phoenix_check("checkOpenVecFileStream : read element", val, i); |
54 | } | ||
55 |
1/1✓ Branch 0 (24→25) taken 20 times.
|
20 | closeFileStream(vecIn); |
56 | 20 | return b; | |
57 | 20 | } | |
58 | |||
59 | |||
60 | 1 | int main(int argc, char** argv){ | |
61 | 1 | checkOpenFileStream(); | |
62 |
2/2✓ Branch 0 (47→4) taken 10 times.
✓ Branch 1 (47→48) taken 1 times.
|
11 | for(size_t i(0lu); i < 10lu; ++i){ |
63 |
7/7✓ Branch 0 (6→7) taken 10 times.
✓ Branch 2 (9→10) taken 10 times.
✓ Branch 4 (12→13) taken 10 times.
✓ Branch 6 (13→14) taken 10 times.
✓ Branch 8 (14→15) taken 10 times.
✓ Branch 10 (15→16) taken 10 times.
✓ Branch 12 (16→17) taken 10 times.
|
60 | phoenix_assert(checkOpenVecFileStream(PPath("some_file_name.txt"), i)); |
64 |
7/7✓ Branch 0 (27→28) taken 10 times.
✓ Branch 2 (30→31) taken 10 times.
✓ Branch 4 (33→34) taken 10 times.
✓ Branch 6 (34→35) taken 10 times.
✓ Branch 8 (35→36) taken 10 times.
✓ Branch 10 (36→37) taken 10 times.
✓ Branch 12 (37→38) taken 10 times.
|
60 | phoenix_assert(checkOpenVecFileStream(PPath("some_file_without_extention"), i)); |
65 | } | ||
66 | 1 | return 0; | |
67 | } | ||
68 | |||
69 | |||
70 |