PhoenixPresentation  2.0.0
Set of cmake function to automate presentation generation
main.cpp
Go to the documentation of this file.
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 
15  std::ofstream fs;
16  phoenix_assert(openFileStream(fs, PPath("fileNameOut.txt")));
17  fs << "some content" << std::endl;
18  fs.close();
19 
20  std::ifstream ifs;
21  phoenix_assert(openFileStream(ifs, PPath("fileNameOut.txt")));
22  PString fileContent("");
23  ifs >> fileContent;
24  ifs.close();
25 
26  phoenix_assert(fileContent == "some"); //The input stream cut on blank characters
27 // std::cout << "checkOpenFileStream : fileContent = '" << fileContent << "'" << std::endl;
28 
29  phoenix_assert(!openFileStream(fs, PPath("outputDirWhichNotExist/test.txt")));
30  phoenix_assert(!openFileStream(ifs, PPath("unexistingFileNameOut.txt")));
33 }
34 
36 
40 bool checkOpenVecFileStream(const PPath & fileName, size_t nbFile){
41  bool b(true);
42  PVecOFStream vecOut;
43  b &= openFileStream(vecOut, fileName, nbFile);
44  for(size_t i(0lu); i < nbFile; ++i){
45  vecOut[i] << i << std::endl;
46  }
47  closeFileStream(vecOut);
48  PVecIFStream vecIn;
49  b &= openFileStream(vecIn, fileName, nbFile);
50  for(size_t i(0lu); i < nbFile; ++i){
51  size_t val(0lu);
52  vecIn[i] >> val;
53  b &= phoenix_check("checkOpenVecFileStream : read element", val, i);
54  }
55  closeFileStream(vecIn);
56  return b;
57 }
58 
59 
60 int main(int argc, char** argv){
62  for(size_t i(0lu); i < 10lu; ++i){
63  phoenix_assert(checkOpenVecFileStream(PPath("some_file_name.txt"), i));
64  phoenix_assert(checkOpenVecFileStream(PPath("some_file_without_extention"), i));
65  }
66  return 0;
67 }
68 
69 
int main(int argc, char **argv)
Definition: main.cpp:228
void checkOpenFileStream()
Check the openFileStream.
Definition: main.cpp:14
bool checkOpenVecFileStream(const PPath &fileName, size_t nbFile)
Check the openFileStream.
Definition: main.cpp:40
Path of a directory or a file.
Definition: PPath.h:17
Extends the std::string.
Definition: PString.h:16
bool openFileStream(std::ofstream &fs, const PPath &fileName)
Open a ofstream and says if there is a problem.
void closeFileStream(PVecOFStream &fs)
Close a vector of ofstream.
std::vector< std::ifstream > PVecIFStream
std::vector< std::ofstream > PVecOFStream
#define phoenix_assert(isOk)
bool phoenix_check(const std::string &testName, const std::string &val, const std::string &reference)
Check two string.