19#include <boost/test/unit_test.hpp>
21#include <oret/toplevelfixture.hpp>
27BOOST_FIXTURE_TEST_SUITE(OREDataTestSuite, ore::test::TopLevelFixture)
29BOOST_AUTO_TEST_SUITE(ExpiryTests)
33 BOOST_TEST_MESSAGE(
"Testing expiry date...");
35 Date inputDate(13, Jan, 2020);
39 BOOST_CHECK_EQUAL(expiry.
expiryDate(), inputDate);
42 string strExpiry = expiry.
toString();
45 QuantLib::ext::shared_ptr<Expiry> parsedExpiry;
46 BOOST_REQUIRE_NO_THROW(parsedExpiry =
parseExpiry(strExpiry));
49 QuantLib::ext::shared_ptr<ExpiryDate> castExpiry = QuantLib::ext::dynamic_pointer_cast<ExpiryDate>(parsedExpiry);
50 BOOST_CHECK(castExpiry);
53 BOOST_CHECK_EQUAL(castExpiry->expiryDate(), inputDate);
58 BOOST_TEST_MESSAGE(
"Testing expiry period...");
60 Period inputPeriod(3, Months);
67 string strExpiry = expiry.
toString();
70 QuantLib::ext::shared_ptr<Expiry> parsedExpiry;
71 BOOST_REQUIRE_NO_THROW(parsedExpiry =
parseExpiry(strExpiry));
74 QuantLib::ext::shared_ptr<ExpiryPeriod> castExpiry = QuantLib::ext::dynamic_pointer_cast<ExpiryPeriod>(parsedExpiry);
75 BOOST_CHECK(castExpiry);
78 BOOST_CHECK_EQUAL(castExpiry->expiryPeriod(), inputPeriod);
83 BOOST_TEST_MESSAGE(
"Testing future continuation expiry...");
85 Natural inputIndex = 2;
89 BOOST_CHECK_EQUAL(expiry.
expiryIndex(), inputIndex);
92 string strExpiry = expiry.
toString();
95 QuantLib::ext::shared_ptr<Expiry> parsedExpiry;
96 BOOST_REQUIRE_NO_THROW(parsedExpiry =
parseExpiry(strExpiry));
99 QuantLib::ext::shared_ptr<FutureContinuationExpiry> castExpiry =
100 QuantLib::ext::dynamic_pointer_cast<FutureContinuationExpiry>(parsedExpiry);
101 BOOST_CHECK(castExpiry);
104 BOOST_CHECK_EQUAL(castExpiry->expiryIndex(), inputIndex);
107BOOST_AUTO_TEST_SUITE_END()
109BOOST_AUTO_TEST_SUITE_END()
const QuantLib::Date & expiryDate() const
Return the expiry date.
std::string toString() const override
const QuantLib::Period & expiryPeriod() const
Return the expiry period.
std::string toString() const override
QuantLib::Natural expiryIndex() const
Return the future continuation expiry index.
std::string toString() const override
Classes for representing an expiry for use in market quotes.
QuantLib::ext::shared_ptr< Expiry > parseExpiry(const string &strExpiry)
Parse an Expiry from its string representation, strExpiry.
BOOST_AUTO_TEST_CASE(testExpiryDate)