Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Functions
aggregationscenariodata.cpp File Reference
#include <boost/test/unit_test.hpp>
#include <orea/scenario/aggregationscenariodata.hpp>
#include <oret/toplevelfixture.hpp>
#include <test/oreatoplevelfixture.hpp>

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (testInMemoryAggregationScenarioData)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE()

BOOST_AUTO_TEST_CASE ( testInMemoryAggregationScenarioData  )

Definition at line 31 of file aggregationscenariodata.cpp.

31 {
33
34 // write data
35 BOOST_CHECK_THROW(data.set(3, 0, 0.0, AggregationScenarioDataType::Generic, "blabla"), std::exception);
36 BOOST_CHECK_THROW(data.set(0, 5, 0.0, AggregationScenarioDataType::Generic, "blabla"), std::exception);
37
38 for (Size i = 0; i < 3; ++i) {
39 for (Size j = 0; j < 5; ++j) {
40 data.set(i, j, 0.0001 * i + 0.01 * j, AggregationScenarioDataType::IndexFixing, "OIS_EUR");
41 data.set(i, j, 0.1 + 0.0001 * i + 0.01 * j, AggregationScenarioDataType::IndexFixing, "OIS_USD");
42 data.set(i, j, 0.2 + 0.0001 * i + 0.01 * j, AggregationScenarioDataType::IndexFixing, "OIS_GBP");
43 data.set(i, j, i + 0.1 * j, AggregationScenarioDataType::FXSpot, "EURUSD");
44 data.set(i, j, 2.0 + i + 0.1 * j, AggregationScenarioDataType::FXSpot, "EURGBP");
45 }
46 }
47
48 // read data
49 BOOST_CHECK_THROW(data.get(3, 0, AggregationScenarioDataType::Generic, "blabla"), std::exception);
50 BOOST_CHECK_THROW(data.get(0, 5, AggregationScenarioDataType::Generic, "blabla"), std::exception);
51
52 Real tol = 1.0E-12;
53
54 for (Size i = 0; i < 3; ++i) {
55 for (Size j = 0; j < 5; ++j) {
56 BOOST_CHECK_CLOSE(data.get(i, j, AggregationScenarioDataType::IndexFixing, "OIS_EUR"),
57 0.0001 * i + 0.01 * j, tol);
58 BOOST_CHECK_CLOSE(data.get(i, j, AggregationScenarioDataType::IndexFixing, "OIS_USD"),
59 0.1 + 0.0001 * i + 0.01 * j, tol);
60 BOOST_CHECK_CLOSE(data.get(i, j, AggregationScenarioDataType::IndexFixing, "OIS_GBP"),
61 0.2 + 0.0001 * i + 0.01 * j, tol);
62 BOOST_CHECK_CLOSE(data.get(i, j, AggregationScenarioDataType::FXSpot, "EURUSD"), i + 0.1 * j, tol);
63 BOOST_CHECK_CLOSE(data.get(i, j, AggregationScenarioDataType::FXSpot, "EURGBP"), 2.0 + i + 0.1 * j, tol);
64 }
65 }
66}
A concrete in memory implementation of AggregationScenarioData.
data