00001
00010 #include "scalt0.hpp"
00011
00012 #include <iostream>
00013
00014 #include <ql/utilities/tracing.hpp>
00015 #include <boost/date_time/gregorian/formatters.hpp>
00016
00017 #include "scal0.hpp"
00018
00019 namespace eepgwde { namespace detail { namespace i0 {
00020
00021 namespace ql = QuantLib;
00022
00024 template <typename U>
00025 typename enable_if<boost::is_same<ql::Date, U>, U>::type
00026 null1(dummy<0> = 2) {
00027 return QuantLib::Date(1, static_cast<ql::Month>(1), 1901);
00028 }
00029
00031 template <typename U>
00032 std::string
00033 ys(typename enable_if<boost::is_same<ql::Date, U>, U>::type,
00034 const boost::any &o, dummy<1> = 1)
00035 throw (std::domain_error &) {
00036 U r(boost::any_cast<U>(o));
00037 boost::gregorian::date bdt(r.year(), r.month(), r.dayOfMonth());
00038 return boost::gregorian::to_simple_string(bdt);
00039 }
00040
00042 template <typename U>
00043 U xs(typename enable_if<boost::is_same<ql::Date, U>, U>::type,
00044 const std::string & s, dummy<1> = 2)
00045 throw (std::domain_error &) {
00046 boost::gregorian::date dt = boost::gregorian::from_simple_string(s);
00047 U qdt(dt.day(), static_cast<ql::Month>(static_cast<int>(dt.month())), dt.year());
00048 return qdt;
00049 }
00050
00051 }}}
00052
00053 #include "eleve/src/typing3.hpp"
00054 #include "eleve/src/typing1.hpp"
00055
00056 namespace eepgwde { namespace detail {
00057
00058 namespace ql = QuantLib;
00059
00060
00061
00062 }}
00063
00064 BOOST_AUTO_TEST_SUITE (typing5)
00065
00066 namespace ql = QuantLib;
00067
00068 using namespace eepgwde::detail;
00069 using namespace boost;
00070
00071 namespace eepgwde { namespace detail {
00072 static null0<ql::Date> nullT;
00073 }}
00074
00075 BOOST_AUTO_TEST_CASE(tas0)
00076 {
00077 BOOST_TEST_MESSAGE("typing5::tas0");
00078 using namespace eepgwde::detail;
00079
00080 boost::any o = nullT;
00081 std::cerr << nullT() << std::endl;
00082 }
00083
00084 BOOST_AUTO_TEST_CASE(tas1)
00085 {
00086 BOOST_TEST_MESSAGE("typing5::tas1");
00087 using namespace eepgwde::detail;
00088
00089 {
00090 string s("2009-11-12");
00091 boost::any o(s);
00092
00093 ql::Date
00094 i0 = i0::xs<ql::Date>((null0<ql::Date>())(), s, i0::dummy<1>(2) );
00095
00096 BOOST_TEST_MESSAGE( s << " " << i0 );
00097 }
00098
00099 }
00100
00101 BOOST_AUTO_TEST_CASE(tas2)
00102 {
00103 BOOST_TEST_MESSAGE("typing5::tas2");
00104 using namespace eepgwde::detail;
00105
00106 {
00107 string s("2009-11-12");
00108 boost::any o(s);
00109
00110 ql::Date i0;
00111
00112 if (as<ql::Date>(&i0, o))
00113 BOOST_TEST_MESSAGE( s << " " << i0 );
00114 }
00115
00116 }
00117
00118 BOOST_AUTO_TEST_SUITE_END()
00119
00120 BOOST_AUTO_TEST_SUITE (typing6)
00121
00122 using namespace eepgwde::detail;
00123 using namespace boost;
00124
00126
00127 BOOST_AUTO_TEST_CASE(tas0)
00128 {
00129 BOOST_TEST_MESSAGE("typing6::tas0");
00130 using namespace eepgwde::detail;
00131
00132 boost::any o(std::string("this"));
00133
00134 boost::any o1( (null0<std::string>())() );
00135
00136 null0<std::string> nullT;
00137
00138 boost::any o2 = nullT;
00139
00140 BOOST_TEST_MESSAGE( o.type().name() << " " << o1.type().name() << " "
00141 << o2.type().name() << " "
00142 << static_cast<boost::any>(nullT).type().name() );
00143
00144 BOOST_CHECK( nullT == o );
00145
00146 BOOST_CHECK( null0<int>() != o );
00147
00148 }
00149
00151
00152 BOOST_AUTO_TEST_CASE(tas1)
00153 {
00154 BOOST_TEST_MESSAGE("typing6::tas1");
00155 using namespace eepgwde::detail;
00156 using eepgwde::detail::count;
00157
00158 std::list<boost::any> l;
00159
00160 l.push_back( boost::any(std::string("this") ) );
00161 l.push_back( boost::any(std::string("that") ) );
00162 l.push_back( boost::any( int(1) ) );
00163
00164 BOOST_TEST_MESSAGE( l.size() );
00165
00166 std::list<boost::any>::iterator end;
00167 BOOST_CHECK ( count<std::string>(&l) == 2 );
00168 }
00169
00171
00172 BOOST_AUTO_TEST_CASE(tas2)
00173 {
00174 BOOST_TEST_MESSAGE("typing6::tas2");
00175 using namespace eepgwde::detail;
00176
00177 std::auto_ptr<Renderer> r0(new null0<int>());
00178
00179 boost::any o(int(1));
00180
00181 BOOST_TEST_MESSAGE ( r0->name() << " " << r0->ys(o) );
00182 }
00183
00185
00186 BOOST_AUTO_TEST_CASE(tas3)
00187 {
00188 BOOST_TEST_MESSAGE("typing6::tas3");
00189 using namespace eepgwde::detail;
00190
00191 boost::any o(int(1));
00192
00193 double d;
00194 as(&d, o);
00195
00196 BOOST_TEST_MESSAGE ( any_cast<int>(o) << " " << d );
00197 }
00198
00199 BOOST_AUTO_TEST_SUITE_END()