PhoenixPresentation  2.0.0
Set of cmake function to automate presentation generation
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  DataStreamMsg messageIn(data_size(s));
27  DataStreamIter iter = (DataStreamIter)messageIn.data();
29 
31  Shadok out;
32  DataStreamIter iterOut = (DataStreamIter)messageIn.data();
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 
int main(int argc, char **argv)
Definition: main.cpp:228
bool checkEqualityConst(const Shadok &s1, const Shadok &s2)
Check the shadok equality as constant.
Definition: main.cpp:61
void testShadok()
Some basic Shadok test.
Definition: main.cpp:66
void testShadokMessage()
Test the Shadok message.
Definition: main.cpp:21
void testShadokFile()
Test the Shadok message.
Definition: main.cpp:40
void testShadokSize()
Test the Shadok size.
Definition: main.cpp:11
test class for the data_stream automatic api
Definition: Shadok.h:13
void setAge(int age)
Set the age of the Shadok.
Definition: Shadok.cpp:39
const std::string & getName() const
Get the name of the Shadok.
Definition: Shadok.cpp:59
int getAge() const
Get the age of the Shadok.
Definition: Shadok.cpp:49
void setName(const std::string &name)
Set the name of the Shadok.
Definition: Shadok.cpp:44
bool data_load(FILE *iter, T &data)
Load data from a message.
Definition: data_file.h:39
bool data_save(FILE *iter, const T &data)
Save data in a message.
Definition: data_file.h:18
bool data_message_save(DataStreamIter &iter, T &data)
Save data in a message.
Definition: data_message.h:18
bool data_message_load(DataStreamIter &iter, T &data)
Load data from a message.
Definition: data_message.h:60
size_t data_size(T &data)
Get size of data.
Definition: data_size.h:17
#define data_stream_assert(isOk)
std::vector< DataStreamType > DataStreamMsg
DataStreamType * DataStreamIter