Skip to content

Commit e389e68

Browse files
committed
Merge branch 'github-192' into 'master'
Github 192 See merge request qs/ore-github!42
2 parents 1efe568 + 3da32ec commit e389e68

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

OREData/ored/utilities/parsers.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,10 @@ pair<string, string> parseBoostAny(const boost::any& anyType, Size precision) {
951951
resultType = "array";
952952
QuantLib::Array r = boost::any_cast<QuantLib::Array>(anyType);
953953
oss << std::fixed << std::setprecision(precision) << r;
954+
} else if (anyType.type() == typeid(QuantLib::Currency)) {
955+
resultType = "currency";
956+
QuantLib::Currency r = boost::any_cast<QuantLib::Currency>(anyType);
957+
oss << r;
954958
} else {
955959
ALOG("Unsupported Boost::Any type");
956960
resultType = "unsupported_type";

OREData/test/parser.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <ored/utilities/parsers.hpp>
2424
#include <ored/utilities/strike.hpp>
2525
#include <oret/toplevelfixture.hpp>
26+
#include <ql/currencies/america.hpp>
2627
#include <ql/math/comparison.hpp>
2728
#include <ql/time/calendars/austria.hpp>
2829
#include <ql/time/calendars/chile.hpp>
@@ -1103,6 +1104,17 @@ BOOST_AUTO_TEST_CASE(testParseBoostAny) {
11031104
BOOST_CHECK_EQUAL(result.second, "[ 3; 3; 3; 3; 3 ]");
11041105
}
11051106

1107+
BOOST_AUTO_TEST_CASE(testParseBoostAnyWithCurrency) {
1108+
1109+
BOOST_TEST_MESSAGE("Testing parsing of Boost::Any...");
1110+
1111+
Currency usd = USDCurrency();
1112+
std::pair<std::string, std::string> result;
1113+
BOOST_REQUIRE_NO_THROW(result = ore::data::parseBoostAny(usd));
1114+
BOOST_CHECK_EQUAL(result.first, "currency");
1115+
BOOST_CHECK_EQUAL(result.second, "USD");
1116+
}
1117+
11061118
BOOST_AUTO_TEST_SUITE_END()
11071119

11081120
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)