19#include <boost/test/unit_test.hpp>
21#include <oret/toplevelfixture.hpp>
23#include <boost/make_shared.hpp>
27using namespace boost::unit_test_framework;
29BOOST_FIXTURE_TEST_SUITE(OREDataTestSuite, ore::test::TopLevelFixture)
31BOOST_AUTO_TEST_SUITE(LegDataTests)
35 BOOST_TEST_MESSAGE(
"Testing LegData Notionals...");
37 vector<double> notionals = {100, 200, 300};
38 vector<string> dates = {
"",
"2015-01-01",
"2016-01-01"};
40 ScheduleRules sr(
"2014-06-01",
"2016-12-01",
"6M",
"TARGET",
"F",
"F",
"Forward");
42 BOOST_CHECK_EQUAL(s.size(), 6UL);
47 BOOST_CHECK_EQUAL(notionalsOut.size(), 5UL);
48 BOOST_CHECK_EQUAL(notionalsOut[0], 100);
49 BOOST_CHECK_EQUAL(notionalsOut[1], 100);
50 BOOST_CHECK_EQUAL(notionalsOut[2], 200);
51 BOOST_CHECK_EQUAL(notionalsOut[3], 200);
52 BOOST_CHECK_EQUAL(notionalsOut[4], 300);
55 notionals = vector<double>(1, 123);
57 BOOST_CHECK_EQUAL(notionalsOut.size(), 1UL);
58 BOOST_CHECK_EQUAL(notionalsOut[0], 123);
61 notionals = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
63 BOOST_CHECK_EQUAL(notionalsOut.size(), 10UL);
64 for (Size i = 0; i < notionalsOut.size(); i++) {
65 BOOST_CHECK_EQUAL(notionalsOut[i], (
double)i);
71 BOOST_TEST_MESSAGE(
"Testing LegData Cashflows...");
73 vector<double> amounts = {1000000, 2000000, 3000000};
74 vector<string> dates = {
"2015-01-01",
"2016-01-01",
"2017-01-01"};
76 LegData legData(QuantLib::ext::make_shared<CashflowData>(amounts, dates),
true,
"EUR");
80 BOOST_CHECK_EQUAL(leg.size(), 3);
82 BOOST_CHECK_EQUAL(leg[0]->amount(), 1000000);
83 BOOST_CHECK_EQUAL(leg[1]->amount(), 2000000);
84 BOOST_CHECK_EQUAL(leg[2]->amount(), 3000000);
86 BOOST_CHECK_EQUAL(leg[0]->date(),
parseDate(
"2015-01-01"));
87 BOOST_CHECK_EQUAL(leg[1]->date(),
parseDate(
"2016-01-01"));
88 BOOST_CHECK_EQUAL(leg[2]->date(),
parseDate(
"2017-01-01"));
91BOOST_AUTO_TEST_SUITE_END()
93BOOST_AUTO_TEST_SUITE_END()
Serializable object holding leg data.
Serializable object holding schedule Rules data.
Date parseDate(const string &s)
Convert std::string to QuantLib::Date.
leg data model and serialization
Leg makeSimpleLeg(const LegData &data)
vector< T > buildScheduledVector(const vector< T > &values, const vector< string > &dates, const Schedule &schedule, const bool checkAllValuesAppearInResult=false)
Schedule makeSchedule(const ScheduleDates &data)
BOOST_AUTO_TEST_CASE(testLegDataNotionals)