00001
00010 #include "scalt0.hpp"
00011
00012 #include <iostream>
00013
00014 #include <boost/date_time/gregorian/gregorian.hpp>
00015
00016 #include <ql/utilities/tracing.hpp>
00017
00018 #include "scal0.hpp"
00019
00020 #include "eleve/src/typing3.hpp"
00021 #include "eleve/src/typing1.hpp"
00022
00023 BOOST_AUTO_TEST_SUITE (typing0)
00024
00025 using namespace eepgwde::detail;
00026
00027 BOOST_AUTO_TEST_CASE(tnull0)
00028 {
00029 BOOST_TEST_MESSAGE("eepgwde::detail::null0");
00030
00031 BOOST_TEST_MESSAGE( "null int: " << (null0<int>())() );
00032 BOOST_CHECK( (null0<int>())() == std::numeric_limits<int>::min() );
00033 BOOST_TEST_MESSAGE( "null double: " << (null0<double>())() );
00034 BOOST_TEST_MESSAGE( "null string: " << (null0<std::string>())() );
00035 BOOST_TEST_MESSAGE( "null date: " << (null0<posixdate>())() );
00036 BOOST_TEST_MESSAGE( "null usdate: " << (null0<usdate>())() );
00037 BOOST_CHECK((null0<posixdate>())() == (null0<usdate>())() );
00038 }
00039
00040 BOOST_AUTO_TEST_CASE(tnull02)
00041 {
00042 BOOST_TEST_MESSAGE("eepgwde::detail::null02");
00043
00044 using eepgwde::daemon::Q;
00045 using namespace eepgwde::detail;
00046 using boost::gregorian::date;
00047
00048 std::cerr << (null0<float>())() << std::endl;
00049 std::cerr << (null0<double>())() << std::endl;
00050 std::cerr << (null0<long double>())() << std::endl;
00051 std::cerr << (null0<long double>())() << std::endl;
00052
00053 std::cerr << (null0<short int>())() << std::endl;
00054 std::cerr << (null0<int>())() << std::endl;
00055 std::cerr << (null0<unsigned int>())() << std::endl;
00056 std::cerr << (null0<long>())() << std::endl;
00057 std::cerr << (null0<unsigned long>())() << std::endl;
00058
00059
00060 std::cerr << (null0<std::string>())() << std::endl;
00061
00062 std::cerr << (null0<usdate>())() << std::endl;
00063 std::cerr << (null0<eudate>())() << std::endl;
00064
00065 std::cerr << (null0<rate>())() << std::endl;
00066 std::cerr << (null0<bps>())() << std::endl;
00067 }
00068
00073 BOOST_AUTO_TEST_CASE(tnull01)
00074 {
00075 BOOST_TEST_MESSAGE("eepgwde::detail::null01");
00076
00077 Typing t0;
00078
00079 Typing::types0_t tt0 = t0.types0();
00080
00081 BOOST_TEST_MESSAGE( "types0: size: " << t0.types0().size() );
00082
00083 for(Typing::types0_t::iterator i=tt0.begin();
00084 i!=tt0.end(); ++i) {
00085 std::cerr << i->first << " " << i->second->null() << std::endl;
00086 }
00087
00088 }
00089
00090 BOOST_AUTO_TEST_CASE(tint1)
00091 {
00092 BOOST_TEST_MESSAGE("eepgwde::detail::int1");
00093
00094 using namespace eepgwde::detail;
00095
00096
00097
00098 BOOST_TEST_MESSAGE( "null0 boost::any typeid: "
00099 << typeid( (null0<boost::any>())() ).name() );
00100
00101 const boost::any null_ = (null0<boost::any>())();
00102 BOOST_CHECK( null_.type() == (null0<boost::any>())().type() );
00103
00104
00105
00106
00107 BOOST_TEST_MESSAGE( "null0 int: typeid "
00108 << typeid( (null0<int>())() ).name() );
00109
00110 null0<int> int0;
00111 boost::any aint0 = int0;
00112
00113 BOOST_TEST_MESSAGE( "null0 int: contains int: "
00114 << aint0.type().name() );
00115 BOOST_TEST_MESSAGE( "null0 int: contains int: "
00116 << static_cast<boost::any>( aint0 ).type().name() );
00117 }
00118
00119 BOOST_AUTO_TEST_CASE(tstr3)
00120 {
00121 BOOST_TEST_MESSAGE("eepgwde::detail::str3");
00122
00123 using namespace eepgwde::detail;
00124 using eepgwde::daemon::Q;
00125
00126 const boost::any null_ = (null0<std::string>())();
00127 const boost::any str_(std::string("this"));
00128
00129 BOOST_TEST_MESSAGE( "null null: type " << null_.type().name() );
00130 BOOST_TEST_MESSAGE( "null string: type " << str_.type().name() );
00131 BOOST_CHECK( str_.type() == null_.type() && str_.type().name() == null_.type().name() );
00132
00133 BOOST_TEST_MESSAGE( "string any_cast " << boost::any_cast<std::string>(str_) );
00134 }
00135
00136 BOOST_AUTO_TEST_CASE(tdate4)
00137 {
00138 BOOST_TEST_MESSAGE("eepgwde::detail::tdate4");
00139
00140 using namespace eepgwde::detail;
00141 using eepgwde::daemon::Q;
00142
00143 const boost::any null_ = (null0<posixdate>())();
00144 const boost::any str_(posixdate(boost::gregorian::date(2009,12,12)));
00145
00146 BOOST_TEST_MESSAGE( "null null: type " << null_.type().name() );
00147 BOOST_TEST_MESSAGE( "null string: type " << str_.type().name() );
00148 BOOST_CHECK( str_.type() == null_.type() && str_.type().name() == null_.type().name() );
00149
00150 BOOST_TEST_MESSAGE( "date any_cast " << boost::any_cast<posixdate>(str_) );
00151 }
00152
00153 BOOST_AUTO_TEST_CASE(tnull2)
00154 {
00155 BOOST_TEST_MESSAGE("eepgwde::detail::null3");
00156 }
00157
00158 BOOST_AUTO_TEST_SUITE_END()
00159
00160 BOOST_AUTO_TEST_SUITE (typing3)
00161
00162 using namespace eepgwde::detail;
00163
00164 struct Rate0 : public Numeric<double> {
00165 Rate0(const double & d) : Numeric<double>(d) {}
00166 Rate0(const Numeric<double> & d) : Numeric<double>(d.d_) {}
00167 };
00168
00169 struct Rate1 : public Numeric<double> {
00170 Rate1(const double & d) : Numeric<double>(d) {}
00171 Rate1(const Numeric<double> & d) : Numeric<double>(d.d_) {}
00172 };
00173
00174 struct Rate2 : public Numeric<int> {
00175 Rate2(const int & d) : Numeric<int>(d) {}
00176 Rate2(const Numeric<int> & d) : Numeric<int>(d.d_) {}
00177 };
00178
00179 struct Rate3 : public Numeric<char> {
00180 Rate3(const char & d) : Numeric<char>(d) {}
00181 Rate3(const Numeric<char> & d) : Numeric<char>(d.d_) {}
00182 };
00183
00184 BOOST_AUTO_TEST_CASE(n0)
00185 {
00186 BOOST_TEST_MESSAGE("eepgwde::boost::type_traits:n0");
00187
00188 Numeric<double> d(1.0);
00189
00190 double d0 = d;
00191 std::string d1 = d;
00192 boost::any o(d);
00193
00194 std::cerr << d << " " << d0 << " " << d1 << std::endl;
00195 std::cerr << o.type().name() << std::endl;
00196 }
00197
00198 BOOST_AUTO_TEST_CASE(n1)
00199 {
00200 BOOST_TEST_MESSAGE("eepgwde::boost::type_traits:n0");
00201
00202 {
00203 Rate0 d(1.0);
00204
00205 double d0 = d;
00206 std::string d1 = d;
00207 boost::any o(d);
00208
00209 std::cerr << d << " " << d0 << " " << d1 << std::endl;
00210 std::cerr << o.type().name() << std::endl;
00211 }
00212
00213 {
00214 Rate1 d(1.0);
00215
00216 double d0 = d;
00217 std::string d1 = d;
00218 boost::any o(d);
00219
00220 std::cerr << d << " " << d0 << " " << d1 << std::endl;
00221 std::cerr << o.type().name() << std::endl;
00222 }
00223
00224 {
00225 Rate2 d(1);
00226
00227 int d0 = d;
00228 std::string d1 = d;
00229 boost::any o(d);
00230
00231 std::cerr << d << " " << d0 << " " << d1 << std::endl;
00232 std::cerr << o.type().name() << std::endl;
00233 }
00234
00235 {
00236 Rate3 d(1);
00237
00238 char d0 = d;
00239 std::string d1 = d;
00240 boost::any o(d);
00241
00242 std::cerr << d << " " << d0 << " " << d1 << std::endl;
00243 std::cerr << o.type().name() << std::endl;
00244 }
00245 }
00246
00247 BOOST_AUTO_TEST_SUITE_END()