PhoenixPresentation  2.0.0
Set of cmake function to automate presentation generation
main.cpp File Reference
+ Include dependency graph for main.cpp:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 
template<typename T >
bool testMultiSimpleTableFile (const std::string &typeNameStr, size_t nbElementMin, size_t nbElementMax)
 Test the serialisation/deserialisation of table of data in message. More...
 
void testSimpleTableDataFile ()
 Test if data size is Ok. More...
 
template<typename T >
bool testSimpleTableFile (const std::string &typeNameStr, size_t nbElement)
 Test the serialisation/deserialisation of table of data in message. More...
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 68 of file main.cpp.

68  {
70  return 0;
71 }
void testSimpleTableDataFile()
Test if data size is Ok.
Definition: main.cpp:53

References testSimpleTableDataFile().

+ Here is the call graph for this function:

◆ testMultiSimpleTableFile()

template<typename T >
bool testMultiSimpleTableFile ( const std::string &  typeNameStr,
size_t  nbElementMin,
size_t  nbElementMax 
)

Test the serialisation/deserialisation of table of data in message.

Parameters
typeNameStr: name of the used type
nbElementMin: minimum number of elements in the table of data
nbElementMax: maximu number of elements in the table of data
Returns
true on success, false otherwise

Definition at line 44 of file main.cpp.

44  {
45  bool b(true);
46  for(size_t i(nbElementMin); i < nbElementMax && b; ++i){
47  b &= testSimpleTableFile<T>(typeNameStr, i);
48  }
49  return b;
50 }

◆ testSimpleTableDataFile()

void testSimpleTableDataFile ( )

Test if data size is Ok.

Definition at line 53 of file main.cpp.

53  {
54  data_stream_assert(testMultiSimpleTableFile<bool>("bool", 2lu, 100lu));
55  data_stream_assert(testMultiSimpleTableFile<char>("char", 2lu, 100lu));
56  data_stream_assert(testMultiSimpleTableFile<int8_t>("int8_t", 2lu, 100lu));
57  data_stream_assert(testMultiSimpleTableFile<short>("short", 2lu, 100lu));
58  data_stream_assert(testMultiSimpleTableFile<int>("int", 2lu, 100lu));
59  data_stream_assert(testMultiSimpleTableFile<long int>("long int", 2lu, 100lu));
60  data_stream_assert(testMultiSimpleTableFile<unsigned char>("unsigned char", 2lu, 100lu));
61  data_stream_assert(testMultiSimpleTableFile<unsigned short>("unsigned short", 2lu, 100lu));
62  data_stream_assert(testMultiSimpleTableFile<unsigned int>("unsigned int", 2lu, 100lu));
63  data_stream_assert(testMultiSimpleTableFile<long unsigned int>("long unsigned int", 2lu, 100lu));
64  data_stream_assert(testMultiSimpleTableFile<float>("float", 2lu, 100lu));
65  data_stream_assert(testMultiSimpleTableFile<double>("double", 2lu, 100lu));
66 }
#define data_stream_assert(isOk)

References data_stream_assert.

Referenced by main().

+ Here is the caller graph for this function:

◆ testSimpleTableFile()

template<typename T >
bool testSimpleTableFile ( const std::string &  typeNameStr,
size_t  nbElement 
)

Test the serialisation/deserialisation of table of data in message.

Parameters
typeNameStr: name of the used type
nbElement: number of elements in the table of data
Returns
true on success, false otherwise

Definition at line 18 of file main.cpp.

18  {
19  T * tabData = new T[nbElement];
20  for(size_t i(0lu); i < nbElement; ++i){
21  tabData[i] = 2lu*i + 1u;
22  }
23  std::string fileName("file.data");
24  bool b(true);
25  b &= data_save(fileName, tabData, nbElement); //Save the message
26  b &= !data_save("unexistingDirectory/unexistingFile.data", tabData, nbElement); //Save the message
27  T * tabLoadedData = new T[nbElement];
28  b &= data_load(fileName, tabLoadedData, nbElement); //Load the message
29 
30  std::stringstream str;
31  str << nbElement;
32  b &= checkValue(typeNameStr + "("+str.str()+")", tabLoadedData, tabData, nbElement);
33  b &= !data_load("unexistingFileName.data", tabLoadedData, nbElement); //Load the message
34  return b;
35 }
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 checkValue(const std::string &testName, const T &givenSize, const T &referenceSize)
Check given value compare to the reference value.

References checkValue(), data_load(), and data_save().

+ Here is the call graph for this function: