19#include <boost/make_shared.hpp>
20#include <boost/test/unit_test.hpp>
23#include <oret/toplevelfixture.hpp>
26using namespace boost::unit_test_framework;
30BOOST_FIXTURE_TEST_SUITE(OREDataTestSuite, ore::test::TopLevelFixture)
32BOOST_AUTO_TEST_SUITE(PortfolioTests)
35 QuantLib::ext::shared_ptr<Portfolio> portfolio = QuantLib::ext::make_shared<Portfolio>();
36 QuantLib::ext::shared_ptr<FxForward> trade1 = QuantLib::ext::make_shared<FxForward>();
37 QuantLib::ext::shared_ptr<FxForward> trade2 = QuantLib::ext::make_shared<FxForward>();
40 BOOST_CHECK_EQUAL(portfolio->has(trade1->id()),
false);
41 BOOST_CHECK_EQUAL(portfolio->size(), 0);
42 portfolio->add(trade1);
43 BOOST_CHECK_EQUAL(portfolio->has(trade1->id()),
true);
44 BOOST_CHECK_EQUAL(portfolio->size(), 1);
45 portfolio->add(trade2);
46 BOOST_CHECK_EQUAL(portfolio->has(trade2->id()),
true);
47 BOOST_CHECK_EQUAL(portfolio->size(), 2);
51 QuantLib::ext::shared_ptr<Portfolio> portfolio = QuantLib::ext::make_shared<Portfolio>();
52 QuantLib::ext::shared_ptr<FxForward> trade1 = QuantLib::ext::make_shared<FxForward>();
53 QuantLib::ext::shared_ptr<FxForward> trade2 = QuantLib::ext::make_shared<FxForward>();
54 portfolio->add(trade1);
55 BOOST_CHECK_THROW(portfolio->add(trade2), exception);
59 QuantLib::ext::shared_ptr<Portfolio> portfolio = QuantLib::ext::make_shared<Portfolio>();
60 QuantLib::ext::shared_ptr<FxForward> trade = QuantLib::ext::make_shared<FxForward>();
61 portfolio->add(trade);
62 BOOST_CHECK_EQUAL(portfolio->size(), 1);
64 BOOST_CHECK_EQUAL(portfolio->size(), 0);
68 QuantLib::ext::shared_ptr<Portfolio> portfolio = QuantLib::ext::make_shared<Portfolio>();
69 QuantLib::ext::shared_ptr<FxForward> trade1 = QuantLib::ext::make_shared<FxForward>();
70 QuantLib::ext::shared_ptr<FxForward> trade2 = QuantLib::ext::make_shared<FxForward>();
73 BOOST_CHECK_EQUAL(portfolio->size(), 0);
74 portfolio->add(trade1);
75 BOOST_CHECK_EQUAL(portfolio->size(), 1);
76 portfolio->add(trade2);
77 BOOST_CHECK_EQUAL(portfolio->size(), 2);
81 QuantLib::ext::shared_ptr<Portfolio> portfolio = QuantLib::ext::make_shared<Portfolio>();
82 QuantLib::ext::shared_ptr<FxForward> trade = QuantLib::ext::make_shared<FxForward>();
83 BOOST_CHECK_EQUAL(portfolio->has(trade->id()),
false);
84 portfolio->add(trade);
85 BOOST_CHECK_EQUAL(portfolio->has(trade->id()),
true);
86 portfolio->remove(trade->id());
87 BOOST_CHECK_EQUAL(portfolio->has(trade->id()),
false);
91 QuantLib::ext::shared_ptr<Portfolio> portfolio = QuantLib::ext::make_shared<Portfolio>();
92 QuantLib::ext::shared_ptr<FxForward> trade1 = QuantLib::ext::make_shared<FxForward>();
93 QuantLib::ext::shared_ptr<FxForward> trade2 = QuantLib::ext::make_shared<FxForward>();
94 std::map<std::string, QuantLib::ext::shared_ptr<Trade>> trade_list;
97 BOOST_CHECK(portfolio->trades() == trade_list);
98 portfolio->add(trade1);
99 trade_list[
"1"] = trade1;
100 BOOST_CHECK(portfolio->trades() == trade_list);
101 portfolio->add(trade2);
102 trade_list[
"2"] = trade2;
103 BOOST_CHECK(portfolio->trades() == trade_list);
107 QuantLib::ext::shared_ptr<Portfolio> portfolio = QuantLib::ext::make_shared<Portfolio>();
108 QuantLib::ext::shared_ptr<FxForward> trade1 = QuantLib::ext::make_shared<FxForward>();
109 QuantLib::ext::shared_ptr<FxForward> trade2 = QuantLib::ext::make_shared<FxForward>();
112 std::set<std::string> trade_ids;
113 BOOST_CHECK(portfolio->ids() == trade_ids);
114 portfolio->add(trade1);
115 trade_ids.insert(
"1");
116 BOOST_CHECK(portfolio->ids() == trade_ids);
117 portfolio->add(trade2);
118 trade_ids.insert(
"2");
119 BOOST_CHECK(portfolio->ids() == trade_ids);
122BOOST_AUTO_TEST_SUITE_END()
124BOOST_AUTO_TEST_SUITE_END()
FX Forward data model and serialization.
BOOST_AUTO_TEST_CASE(testAddTrades)