#include"observable.hpp"#include"utilities.hpp"#include#include#include#include#include#include#include#include#include#include#includeusingnamespace QuantLib;usingnamespace boost::unit_test_framework;namespace{classUpdateCounter:publicObserver{public:UpdateCounter()=default;voidupdate()override{++counter_;}Size counter()const{return counter_;}private:Size counter_ =0;};classRestoreUpdates{public:~RestoreUpdates(){ObservableSettings::instance().enableUpdates();}};}voidObservableTest::testObservableSettings(){BOOST_TEST_MESSAGE("Testing observable settings...");const ext::shared_ptr<SimpleQuote>quote(newSimpleQuote(100.0));UpdateCounter updateCounter;updateCounter.registerWith(quote);if(updateCounter.counter()!=0){BOOST_FAIL("update counter value is not zero");}quote->setValue(1.0);if(updateCounter.counter()!=1){BOOST_FAIL("update counter value is not one");}ObservableSettings::instance().disableUpdates(false);quote->setValue(2.0);if(updateCounter.counter()!=1){BOOST_FAIL("update counter value is not one");}ObservableSettings::instance().enableUpdates();if(updateCounter.counter()!=1){BOOST_FAIL("update counter value is not one");}ObservableSettings::instance().disableUpdates(true);quote->setValue(3.0);if(updateCounter.counter()!=1){BOOST_FAIL("update counter value is not one");}ObservableSettings::instance().enableUpdates();if(updateCounter.counter()!=2){BOOST_FAIL("update counter value is not two");}UpdateCounter updateCounter2;updateCounter2.registerWith(quote);ObservableSettings::instance().disableUpdates(true);for(Size i=0; i <10;++i){quote->setValue(Real(i));}if(updateCounter.counter()!=2){BOOST_FAIL("update counter value is not two"