PhoenixMock  1.8.7
Tools to split/merge/print mock used in Phoenix
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 "PStream.h"
11 
13 void testPStream(){
14  PStream strOut;
15  phoenix_assert(strOut.open("testInt.bin", "w"));
16  strOut << 42;
17  strOut.close();
18 
19  PStream strIn;
20  phoenix_assert(strIn.open("testInt.bin", "r"));
21  int val(0);
22  strIn >> val;
23 
24  std::cout << "testPStream : val = " << val << std::endl;
25  phoenix_assert(val == 42);
26 }
27 
30  int tabInt [] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
31  int tabIntRead [] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
32 
33  PStream strOut;
34  phoenix_assert(strOut.open("testTabInt.bin", "w"));
35  strOut.write(tabInt, 10lu);
36  strOut.close();
37 
38  PStream strIn;
39  phoenix_assert(strIn.open("testTabInt.bin", "r"));
40  strIn.read(tabIntRead, 10lu);
41 
42  std::cout << "testPStreamTable : tabIntRead[9] = " << tabIntRead[9] << std::endl;
43  for(size_t i(0); i < 10lu; ++i){
44  phoenix_assert(tabInt[i] == tabIntRead[i]);
45  }
46 }
47 
50  int tabInt [] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
51  int tabIntRead [] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
52 
53  PStream strOut;
54  phoenix_assert(strOut.open("testMatInt.bin", "w"));
55  strOut.write(tabInt, 2lu, 5lu, 0lu);
56  strOut.close();
57 
58  PStream strIn;
59  phoenix_assert(strIn.open("testMatInt.bin", "r"));
60  strIn.read(tabIntRead, 2lu, 5lu, 0lu);
61 
62  std::cout << "testPStreamMatrix : tabIntRead[9] = " << tabIntRead[9] << std::endl;
63  for(size_t i(0); i < 10lu; ++i){
64  phoenix_assert(tabInt[i] == tabIntRead[i]);
65  }
66 }
67 
68 int main(int argc, char** argv){
69  testPStream();
72  return 0;
73 }
74 
75 
PStream::close
void close()
Close the stream.
Definition: PStream.cpp:32
PStream.h
PStream::write
bool write(const T &value)
Write a value into the stream.
Definition: PStream_impl.h:37
testPStreamMatrix
void testPStreamMatrix()
Test the PStream.
Definition: main.cpp:49
PStream::read
bool read(T &value)
Read a value from the stream.
Definition: PStream_impl.h:73
testPStream
void testPStream()
Test the PStream.
Definition: main.cpp:13
testPStreamTable
void testPStreamTable()
Test the PStream.
Definition: main.cpp:29
PStream
Deal with binary stream.
Definition: PStream.h:14
PStream::open
bool open(const std::string &fileName, const std::string &mode="r")
Open the current stream.
Definition: PStream.cpp:25
phoenix_assert
#define phoenix_assert(isOk)
Definition: phoenix_assert.h:19
phoenix_assert.h
main
int main(int argc, char **argv)
Definition: main.cpp:85