PhoenixGenerator  2.0.0
Set of tools to generate code
main.cpp
Go to the documentation of this file.
1 
2 /***************************************
3  Auteur : Pierre Aubert
4  Mail : pierre.aubert@lapp.in2p3.fr
5  Licence : CeCILL-C
6 ****************************************/
7 
8 #include <iostream>
9 #include "phoenix_assert.h"
10 #include "phoenix_check.h"
11 
12 #include "convertToString.h"
13 
15 
20 template<typename T>
21 bool checkResultConvertToString(const std::string & testName, T value, const std::string & strReference){
22  std::string convertedValue(valueToString(value));
23  return phoenix_check(testName, convertedValue, strReference);
24 }
25 
28  phoenix_assert(checkResultConvertToString<int>("Test value int", 1, "1"));
29  phoenix_assert(checkResultConvertToString<unsigned int>("Test value unsigned int", 1, "1"));
30  phoenix_assert(checkResultConvertToString<long int>("Test value long int", 1, "1"));
31  phoenix_assert(checkResultConvertToString<long unsigned int>("Test value long unsigned int", 1, "1"));
32  phoenix_assert(checkResultConvertToString<double>("Test value double", 1.0, "1"));
33  phoenix_assert(checkResultConvertToString<double>("Test value double", 1.5, "1.5"));
34  phoenix_assert(checkResultConvertToString<float>("Test value float", 1.0f, "1"));
35  phoenix_assert(checkResultConvertToString<float>("Test value float", 1.5f, "1.5"));
36  phoenix_assert(checkResultConvertToString<std::string>("Test value string", "1.0f", "1.0f"));
37  phoenix_assert(stringToValue<int>("314") == 314);
38  phoenix_assert(stringToValue<std::string>("314") == "314");
39 
40  phoenix_assert(stringToValue<PString>("314 456") == PString("314 456"));
41  phoenix_assert(valueToString<PString>(PString("314 456")) == "314 456");
42 
43  phoenix_assert(stringToValue<PPath>("314 456") == PPath("314 456"));
44  phoenix_assert(valueToString<PPath>(PPath("314 456")) == "314 456");
45 
46  phoenix_assert(valueToString(true) == "true");
47  phoenix_assert(valueToString(false) == "false");
48  phoenix_assert(stringToValue<bool>("true") == true);
49  phoenix_assert(stringToValue<bool>("false") == false);
50 }
51 
52 
53 int main(int argc, char** argv){
55  return 0;
56 }
57 
58 
int main(int argc, char **argv)
Definition: main.cpp:19
bool checkResultConvertToString(const std::string &testName, T value, const std::string &strReference)
Check string expression.
Definition: main.cpp:21
void testConvertToString()
Test convert to string.
Definition: main.cpp:27
Path of a directory or a file.
Definition: PPath.h:17
Extends the std::string.
Definition: PString.h:16
PPath stringToValue< PPath >(const std::string &str)
Convert a string to value (specialisation for PPath)
PString stringToValue< PString >(const std::string &str)
Convert a string to value (specialisation for PString)
std::string valueToString< PString >(const PString &val)
Convert a value to string (specialisation for PString)
std::string valueToString< PPath >(const PPath &val)
Convert a value to string (specialisation for PPath)
bool stringToValue< bool >(const std::string &str)
Convert a string to value (specialisation for bool)
std::string valueToString(const T &val)
Convert a type into a string.
#define phoenix_assert(isOk)
bool phoenix_check(const std::string &testName, const std::string &val, const std::string &reference)
Check two string.