PhoenixMock  1.8.7
Tools to split/merge/print mock used in Phoenix
main.cpp
Go to the documentation of this file.
1 /***************************************
2  Auteur : Pierre Aubert
3  Mail : pierre.aubert@lapp.in2p3.fr
4  Licence : CeCILL-C
5 ****************************************/
6 
7 #include "data_stream_assert.h"
8 #include "Shadok.h"
9 
12  Shadok s;
13  s.setAge(3);
14  s.setName("Shadoko");
15 
16  size_t shadokSize(data_size(s));
17  data_stream_assert(shadokSize == 19lu);
18 }
19 
22  Shadok s;
23  s.setAge(3);
24  s.setName("Shadoko");
25 
26  std::vector<char> messageIn(data_size(s));
27  char* iter = (char*)messageIn.data();
28  data_message_save(iter, s);
29 
31  Shadok out;
32  char* iterOut = (char*)messageIn.data();
33  data_message_load(iterOut, out);
34 
35  data_stream_assert(s.getAge() == out.getAge());
36  data_stream_assert(s.getName() == out.getName());
37 }
38 
41  Shadok s;
42  s.setAge(3);
43  s.setName("Shadoko");
44 
45  std::string fileName("shadok.data");
46  data_save(fileName, s);
47 
49  Shadok out;
50  data_load(fileName, out);
51 
52  data_stream_assert(s.getAge() == out.getAge());
53  data_stream_assert(s.getName() == out.getName());
54 }
55 
57 
61 bool checkEqualityConst(const Shadok & s1, const Shadok & s2){
62  return s1.getName() == s2.getName() && s1.getAge() == s2.getAge();
63 }
64 
66 void testShadok(){
67  Shadok s;
68  Shadok p(s);
69  Shadok q;
70  q = s;
71  data_stream_assert(s.getAge() == q.getAge());
73 }
74 
75 int main(int argc, char** argv){
79  testShadok();
80  return 0;
81 }
82 
data_stream_assert
#define data_stream_assert(isOk)
Definition: data_stream_assert.h:17
Shadok.h
Shadok::getAge
int getAge() const
Get the age of the Shadok.
Definition: Shadok.cpp:49
data_stream_assert.h
checkEqualityConst
bool checkEqualityConst(const Shadok &s1, const Shadok &s2)
Check the shadok equality as constant.
Definition: main.cpp:61
data_size
size_t data_size(T &data)
Get size of data.
Definition: data_size.h:17
Shadok::setAge
void setAge(int age)
Set the age of the Shadok.
Definition: Shadok.cpp:39
Shadok::getName
const std::string & getName() const
Get the name of the Shadok.
Definition: Shadok.cpp:59
testShadok
void testShadok()
Some basic Shadok test.
Definition: main.cpp:66
data_save
bool data_save(FILE *iter, const T &data)
Save data in a message.
Definition: data_file.h:18
data_message_save
bool data_message_save(Stream &iter, T &data)
Save data in a message.
Definition: data_message.h:18
testShadokMessage
void testShadokMessage()
Test the Shadok message.
Definition: main.cpp:21
data_load
bool data_load(FILE *iter, T &data)
Load data from a message.
Definition: data_file.h:39
Shadok
test class for the data_stream automatic api
Definition: Shadok.h:13
testShadokFile
void testShadokFile()
Test the Shadok message.
Definition: main.cpp:40
Shadok::setName
void setName(const std::string &name)
Set the name of the Shadok.
Definition: Shadok.cpp:44
data_message_load
bool data_message_load(char *&iter, T &data)
Load data from a message.
Definition: data_message.h:60
main
int main(int argc, char **argv)
Definition: main.cpp:85
testShadokSize
void testShadokSize()
Test the Shadok size.
Definition: main.cpp:11