PhoenixMock  1.8.7
Tools to split/merge/print mock used in Phoenix
main.cpp File Reference
#include <iostream>
#include "phoenix_assert.h"
#include "PStream.h"
+ Include dependency graph for main.cpp:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 
void testPStream ()
 Test the PStream. More...
 
void testPStreamMatrix ()
 Test the PStream. More...
 
void testPStreamTable ()
 Test the PStream. More...
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 68 of file main.cpp.

68  {
69  testPStream();
72  return 0;
73 }

References testPStream(), testPStreamMatrix(), and testPStreamTable().

+ Here is the call graph for this function:

◆ testPStream()

void testPStream ( )

Test the PStream.

Definition at line 13 of file main.cpp.

13  {
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 }

References PStream::close(), PStream::open(), and phoenix_assert.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testPStreamMatrix()

void testPStreamMatrix ( )

Test the PStream.

Definition at line 49 of file main.cpp.

49  {
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 }

References PStream::close(), PStream::open(), phoenix_assert, PStream::read(), and PStream::write().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testPStreamTable()

void testPStreamTable ( )

Test the PStream.

Definition at line 29 of file main.cpp.

29  {
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 }

References PStream::close(), PStream::open(), phoenix_assert, PStream::read(), and PStream::write().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:
PStream::close
void close()
Close the stream.
Definition: PStream.cpp:32
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