Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Functions
logquote.cpp File Reference
#include "toplevelfixture.hpp"
#include <boost/test/unit_test.hpp>
#include <ql/quotes/simplequote.hpp>
#include <qle/quotes/logquote.hpp>

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (testLogQuote)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE()

BOOST_AUTO_TEST_CASE ( testLogQuote  )

Definition at line 32 of file logquote.cpp.

32 {
33
34 BOOST_TEST_MESSAGE("Testing QuantExt::LogQuote...");
35 QuantLib::ext::shared_ptr<SimpleQuote> quote(new QuantLib::SimpleQuote(1.0));
36 Handle<Quote> qh(quote);
37 Handle<Quote> logQuote(QuantLib::ext::shared_ptr<Quote>(new LogQuote(qh)));
38
39 BOOST_CHECK_EQUAL(logQuote->value(), std::log(quote->value()));
40
41 quote->setValue(2.0);
42 BOOST_CHECK_EQUAL(logQuote->value(), std::log(quote->value()));
43
44 quote->setValue(3.0);
45 BOOST_CHECK_EQUAL(logQuote->value(), std::log(quote->value()));
46
47 quote->setValue(123.0);
48 BOOST_CHECK_EQUAL(logQuote->value(), std::log(quote->value()));
49
50 // LogQuote should throw when a negative value is set
51 BOOST_CHECK_THROW(quote->setValue(-1.0), std::exception);
52}
Class for storing logs of quotes for log-linear interpolation.
Definition: logquote.hpp:38