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 "phoenix_check.h" |
||
11 |
#include "openFileStream.h" |
||
12 |
|||
13 |
///Check the openFileStream |
||
14 |
1 |
void checkOpenFileStream(){ |
|
15 |
✓ | 2 |
std::ofstream fs; |
16 |
✓✓✓✓ ✓✓ |
1 |
phoenix_assert(openFileStream(fs, "fileNameOut.txt")); |
17 |
✓✓ | 1 |
fs << "some content" << std::endl; |
18 |
✓ | 1 |
fs.close(); |
19 |
|||
20 |
✓ | 2 |
std::ifstream ifs; |
21 |
✓✓✓✓ ✓✓ |
1 |
phoenix_assert(openFileStream(ifs, "fileNameOut.txt")); |
22 |
✓ | 1 |
std::string fileContent(""); |
23 |
✓ | 1 |
ifs >> fileContent; |
24 |
✓ | 1 |
ifs.close(); |
25 |
|||
26 |
✓✓✓✓ |
1 |
phoenix_assert(fileContent == "some"); //The input stream cut on blank characters |
27 |
// std::cout << "checkOpenFileStream : fileContent = '" << fileContent << "'" << std::endl; |
||
28 |
|||
29 |
✓✓✓✓ ✓✓ |
1 |
phoenix_assert(!openFileStream(fs, "outputDirWhichNotExist/test.txt")); |
30 |
✓✓✓✓ ✓✓ |
1 |
phoenix_assert(!openFileStream(ifs, "unexistingFileNameOut.txt")); |
31 |
✓✓✓✓ ✓✓ |
1 |
phoenix_assert(!openFileStream(fs, "")); |
32 |
✓✓✓✓ ✓✓ |
1 |
phoenix_assert(!openFileStream(ifs, "")); |
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 std::string & fileName, size_t nbFile){ |
|
41 |
20 |
bool b(true); |
|
42 |
40 |
PVecOFStream vecOut; |
|
43 |
✓ | 20 |
b &= openFileStream(vecOut, fileName, nbFile); |
44 |
✓✓ | 110 |
for(size_t i(0lu); i < nbFile; ++i){ |
45 |
✓✓ | 90 |
vecOut[i] << i << std::endl; |
46 |
} |
||
47 |
✓ | 20 |
closeFileStream(vecOut); |
48 |
20 |
PVecIFStream vecIn; |
|
49 |
✓ | 20 |
b &= openFileStream(vecIn, fileName, nbFile); |
50 |
✓✓ | 110 |
for(size_t i(0lu); i < nbFile; ++i){ |
51 |
90 |
size_t val(0lu); |
|
52 |
✓ | 90 |
vecIn[i] >> val; |
53 |
✓✓ | 90 |
b &= phoenix_check("checkOpenVecFileStream : read element", val, i); |
54 |
} |
||
55 |
✓ | 20 |
closeFileStream(vecIn); |
56 |
40 |
return b; |
|
57 |
} |
||
58 |
|||
59 |
|||
60 |
1 |
int main(int argc, char** argv){ |
|
61 |
1 |
checkOpenFileStream(); |
|
62 |
✓✓ | 11 |
for(size_t i(0lu); i < 10lu; ++i){ |
63 |
✓✓✓✓ ✓✓ |
10 |
phoenix_assert(checkOpenVecFileStream("some_file_name.txt", i)); |
64 |
✓✓✓✓ ✓✓ |
10 |
phoenix_assert(checkOpenVecFileStream("some_file_without_extention", i)); |
65 |
} |
||
66 |
1 |
return 0; |
|
67 |
} |
||
68 |
|||
69 |
Generated by: GCOVR (Version 4.2) |