PhoenixPresentation  2.0.0
Set of cmake function to automate presentation generation
main_map.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 "phoenix_data_stream.h"
8 
10 
13 template<typename T, typename U>
14 void testSimpleMapValue(const std::string & testName, size_t nbValue){
15  std::string fileName("value_test_map.data");
16  std::map<T, U> vecRef;
17  for(size_t i(0lu); i < nbValue; ++i){vecRef[i] = (U)(2lu*i > nbValue/2lu);}
18  data_stream_assert(data_save(fileName, vecRef));
19  std::map<T, U> vecValue;
20  data_stream_assert(data_load(fileName, vecValue));
21  data_stream_assert(checkValue(testName, vecValue, vecRef));
22 }
23 
25 
28 template<typename T>
29 void testSetMapValue(const std::string & firstTypeName, size_t nbValue){
30  testSimpleMapValue<T, long unsigned int>("std::map<"+firstTypeName+", long unsigned int>", nbValue);
31  testSimpleMapValue<T, unsigned int>("std::map<"+firstTypeName+", unsigned int>", nbValue);
32  testSimpleMapValue<T, unsigned short>("std::map<"+firstTypeName+", unsigned short>", nbValue);
33  testSimpleMapValue<T, unsigned char>("std::map<"+firstTypeName+", unsigned char>", nbValue);
34  testSimpleMapValue<T, long int>("std::map<"+firstTypeName+", long int>", nbValue);
35  testSimpleMapValue<T, int>("std::map<"+firstTypeName+", int>", nbValue);
36  testSimpleMapValue<T, short>("std::map<"+firstTypeName+", short>", nbValue);
37  testSimpleMapValue<T, char>("std::map<"+firstTypeName+", char>", nbValue);
38  testSimpleMapValue<T, int8_t>("std::map<"+firstTypeName+", int8_t>", nbValue);
39  testSimpleMapValue<T, float>("std::map<"+firstTypeName+", float>", nbValue);
40  testSimpleMapValue<T, double>("std::map<"+firstTypeName+", double>", nbValue);
41  testSimpleMapValue<T, bool>("std::map<"+firstTypeName+", bool>", nbValue);
42 
43 }
44 
47  size_t nbValue(10lu);
48  testSetMapValue<long unsigned int>("long unsigned int", nbValue);
49  testSetMapValue<unsigned int>("unsigned int", nbValue);
50  testSetMapValue<unsigned short>("unsigned short", nbValue);
51  testSetMapValue<unsigned char>("unsigned char", nbValue);
52  testSetMapValue<long int>("long int", nbValue);
53  testSetMapValue<int>("int", nbValue);
54  testSetMapValue<short>("short", nbValue);
55  testSetMapValue<char>("char", nbValue);
56  testSetMapValue<int8_t>("int8_t", nbValue);
57  testSetMapValue<float>("float", nbValue);
58  testSetMapValue<double>("double", nbValue);
59  testSetMapValue<bool>("bool", nbValue);
60 }
61 
62 
63 int main(int argc, char** argv){
65  return 0;
66 }
67 
68 
int main(int argc, char **argv)
Definition: main_map.cpp:63
void testMapDataFile()
Test if data size is Ok.
Definition: main_map.cpp:46
void testSetMapValue(const std::string &firstTypeName, size_t nbValue)
Abstract check of values stored in a file.
Definition: main_map.cpp:29
void testSimpleMapValue(const std::string &testName, size_t nbValue)
Abstract check of values stored in a file.
Definition: main_map.cpp:14
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
#define data_stream_assert(isOk)
bool checkValue(const std::string &testName, const T &givenSize, const T &referenceSize)
Check given value compare to the reference value.