From b0160d07ff3d2b736f6301057ecbeaf5d46ff606 Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Thu, 14 Dec 2023 18:10:22 +0100 Subject: [PATCH] Use test-suite namespaces to avoid ambiguities. BOOST_AUTO_TEST_SUITE defines a namespace, so utilities in test files don't need to be in a namespace (anonymous or otherwise) to avoid ambiguities, even in unity builds. --- test-suite/americanoption.cpp | 10 +-- test-suite/amortizingbond.cpp | 4 +- test-suite/andreasenhugevolatilityinterpl.cpp | 30 ++----- test-suite/array.cpp | 12 ++- test-suite/asianoptions.cpp | 10 +-- test-suite/assetswap.cpp | 30 ++----- test-suite/autocovariances.cpp | 6 +- test-suite/barrieroption.cpp | 18 ++-- test-suite/basismodels.cpp | 8 +- test-suite/basisswapratehelpers.cpp | 20 ++--- test-suite/basketoption.cpp | 8 +- test-suite/batesmodel.cpp | 16 ++-- test-suite/bermudanswaption.cpp | 16 ++-- test-suite/binaryoption.cpp | 16 ++-- test-suite/blackdeltacalculator.cpp | 18 ++-- test-suite/blackformula.cpp | 6 +- test-suite/bondforward.cpp | 18 ++-- test-suite/bonds.cpp | 34 ++----- test-suite/brownianbridge.cpp | 10 +-- test-suite/businessdayconventions.cpp | 15 ++-- test-suite/calendars.cpp | 6 +- test-suite/callablebonds.cpp | 8 +- test-suite/capfloor.cpp | 32 ++----- test-suite/capflooredcoupon.cpp | 14 ++- test-suite/cashflows.cpp | 6 +- test-suite/catbonds.cpp | 26 ++---- test-suite/cdo.cpp | 16 ++-- test-suite/cdsoption.cpp | 4 +- test-suite/chooseroption.cpp | 10 +-- test-suite/cliquetoption.cpp | 8 +- test-suite/cms.cpp | 18 ++-- test-suite/cms_normal.cpp | 18 ++-- test-suite/cmsspread.cpp | 8 +- test-suite/commodityunitofmeasure.cpp | 4 +- test-suite/compiledboostversion.cpp | 4 +- test-suite/compoundoption.cpp | 16 ++-- test-suite/convertiblebonds.cpp | 16 ++-- test-suite/covariance.cpp | 16 ++-- test-suite/creditdefaultswap.cpp | 6 +- test-suite/creditriskplus.cpp | 4 +- test-suite/crosscurrencyratehelpers.cpp | 18 ++-- test-suite/currency.cpp | 6 +- test-suite/curvestates.cpp | 34 ++----- test-suite/dates.cpp | 6 +- test-suite/daycounters.cpp | 28 +++--- test-suite/defaultprobabilitycurves.cpp | 6 +- test-suite/digitalcoupon.cpp | 28 ++---- test-suite/digitaloption.cpp | 10 +-- test-suite/distributions.cpp | 20 ++--- test-suite/dividendoption.cpp | 10 +-- test-suite/doublebarrieroption.cpp | 16 ++-- test-suite/doublebinaryoption.cpp | 10 +-- test-suite/equitycashflow.cpp | 28 ++---- test-suite/equityindex.cpp | 36 ++------ test-suite/equitytotalreturnswap.cpp | 22 ++--- test-suite/europeanoption.cpp | 56 ++---------- test-suite/everestoption.cpp | 4 +- test-suite/exchangerate.cpp | 6 +- test-suite/extendedtrees.cpp | 32 ++----- test-suite/extensibleoptions.cpp | 4 +- test-suite/fastfouriertransform.cpp | 6 +- test-suite/fdcev.cpp | 9 +- test-suite/fdcir.cpp | 4 +- test-suite/fdheston.cpp | 16 ++-- test-suite/fdmlinearop.cpp | 14 ++- test-suite/fdsabr.cpp | 10 +-- test-suite/fittedbonddiscountcurve.cpp | 6 +- test-suite/forwardoption.cpp | 10 +-- test-suite/forwardrateagreement.cpp | 6 +- test-suite/functions.cpp | 6 +- test-suite/garch.cpp | 16 ++-- test-suite/gaussianquadratures.cpp | 30 ++----- test-suite/gjrgarchmodel.cpp | 6 +- test-suite/gsr.cpp | 6 +- test-suite/hestonmodel.cpp | 8 +- test-suite/hestonslvmodel.cpp | 8 +- test-suite/himalayaoption.cpp | 6 +- test-suite/hybridhestonhullwhiteprocess.cpp | 16 ++-- test-suite/indexes.cpp | 6 +- test-suite/inflation.cpp | 18 ++-- test-suite/inflationcapfloor.cpp | 18 ++-- test-suite/inflationcapflooredcoupon.cpp | 16 ++-- test-suite/inflationcpibond.cpp | 16 ++-- test-suite/inflationcpicapfloor.cpp | 16 ++-- test-suite/inflationcpiswap.cpp | 20 ++--- test-suite/inflationvolatility.cpp | 16 ++-- test-suite/instruments.cpp | 6 +- test-suite/integrals.cpp | 87 ++++++------------ test-suite/interestrates.cpp | 10 +-- test-suite/interpolations.cpp | 9 +- test-suite/jumpdiffusion.cpp | 10 +-- test-suite/lazyobject.cpp | 22 ++--- test-suite/libormarketmodel.cpp | 20 ++--- test-suite/libormarketmodelprocess.cpp | 16 ++-- test-suite/linearleastsquaresregression.cpp | 10 +-- test-suite/lookbackoptions.cpp | 10 +-- test-suite/lowdiscrepancysequences.cpp | 4 +- test-suite/margrabeoption.cpp | 10 +-- test-suite/marketmodel_cms.cpp | 14 ++- test-suite/marketmodel_smm.cpp | 14 ++- .../marketmodel_smmcapletalphacalibration.cpp | 14 ++- .../marketmodel_smmcapletcalibration.cpp | 14 ++- .../marketmodel_smmcaplethomocalibration.cpp | 16 ++-- test-suite/markovfunctional.cpp | 10 +-- test-suite/matrices.cpp | 30 ++----- test-suite/mclongstaffschwartzengine.cpp | 10 +-- test-suite/mersennetwister.cpp | 6 +- test-suite/money.cpp | 4 +- test-suite/noarbsabr.cpp | 8 +- test-suite/normalclvmodel.cpp | 8 +- test-suite/nthorderderivativeop.cpp | 6 +- test-suite/nthtodefault.cpp | 14 ++- test-suite/numericaldifferentiation.cpp | 10 +-- test-suite/observable.cpp | 10 +-- test-suite/ode.cpp | 10 +-- test-suite/operators.cpp | 6 +- test-suite/optimizers.cpp | 10 +-- test-suite/optionletstripper.cpp | 26 ++---- test-suite/overnightindexedcoupon.cpp | 30 ++----- test-suite/overnightindexedswap.cpp | 34 +++---- test-suite/pagodaoption.cpp | 4 +- test-suite/partialtimebarrieroption.cpp | 12 ++- test-suite/pathgenerator.cpp | 10 +-- test-suite/period.cpp | 6 +- test-suite/piecewiseyieldcurve.cpp | 48 ++-------- .../piecewisezerospreadedtermstructure.cpp | 32 ++----- test-suite/prices.cpp | 4 +- test-suite/quantlibbenchmark.cpp | 89 ++++++++++--------- test-suite/quantooption.cpp | 8 +- test-suite/quotes.cpp | 16 ++-- test-suite/rangeaccrual.cpp | 19 ++-- test-suite/riskneutraldensitycalculator.cpp | 4 +- test-suite/riskstats.cpp | 6 +- test-suite/rngtraits.cpp | 6 +- test-suite/rounding.cpp | 22 ++--- test-suite/sampledcurve.cpp | 14 ++- test-suite/schedule.cpp | 10 +-- test-suite/settings.cpp | 6 +- test-suite/shortratemodels.cpp | 18 ++-- test-suite/sofrfutures.cpp | 10 +-- test-suite/solvers.cpp | 10 +-- test-suite/spreadoption.cpp | 8 +- test-suite/squarerootclvmodel.cpp | 15 ++-- test-suite/stats.cpp | 10 +-- test-suite/subperiodcoupons.cpp | 18 ++-- test-suite/svivolatility.cpp | 4 +- test-suite/swap.cpp | 26 ++---- test-suite/swapforwardmappings.cpp | 10 +-- test-suite/swaption.cpp | 30 ++----- test-suite/swaptionvolatilitycube.cpp | 26 ++---- test-suite/swaptionvolatilitymatrix.cpp | 16 ++-- test-suite/swingoption.cpp | 17 +--- test-suite/termstructures.cpp | 32 ++----- test-suite/timegrid.cpp | 6 +- test-suite/timeseries.cpp | 6 +- test-suite/tqreigendecomposition.cpp | 6 +- test-suite/tracing.cpp | 10 +-- test-suite/transformedgrid.cpp | 10 +-- test-suite/twoassetbarrieroption.cpp | 8 +- test-suite/twoassetcorrelationoption.cpp | 4 +- test-suite/ultimateforwardtermstructure.cpp | 24 ++--- test-suite/variancegamma.cpp | 8 +- test-suite/varianceoption.cpp | 4 +- test-suite/varianceswaps.cpp | 10 +-- test-suite/volatilitymodels.cpp | 6 +- test-suite/vpp.cpp | 26 ++---- test-suite/xoshiro256starstar.cpp | 15 ++-- test-suite/zabr.cpp | 4 +- test-suite/zerocouponswap.cpp | 24 ++--- 169 files changed, 863 insertions(+), 1626 deletions(-) diff --git a/test-suite/americanoption.cpp b/test-suite/americanoption.cpp index 29cafb0ba42..2e65e532fdd 100644 --- a/test-suite/americanoption.cpp +++ b/test-suite/americanoption.cpp @@ -48,6 +48,10 @@ using namespace QuantLib; using namespace boost::unit_test_framework; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(AmericanOptionTests) + #undef REPORT_FAILURE #define REPORT_FAILURE(greekName, payoff, exercise, s, q, r, today, \ v, expected, calculated, error, tolerance) \ @@ -83,10 +87,6 @@ namespace { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(AmericanOptionTest) - BOOST_AUTO_TEST_CASE(testBaroneAdesiWhaleyValues) { BOOST_TEST_MESSAGE("Testing Barone-Adesi and Whaley approximation " @@ -2243,4 +2243,4 @@ BOOST_AUTO_TEST_CASE(testSingleBjerksundStenslandGreeks) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/amortizingbond.cpp b/test-suite/amortizingbond.cpp index c5ad555cd26..2e858c547ee 100644 --- a/test-suite/amortizingbond.cpp +++ b/test-suite/amortizingbond.cpp @@ -31,9 +31,9 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) -BOOST_AUTO_TEST_SUITE(AmortizingBondTest) +BOOST_AUTO_TEST_SUITE(AmortizingBondTests) BOOST_AUTO_TEST_CASE(testAmortizingFixedRateBond) { BOOST_TEST_MESSAGE("Testing amortizing fixed rate bond..."); diff --git a/test-suite/andreasenhugevolatilityinterpl.cpp b/test-suite/andreasenhugevolatilityinterpl.cpp index 329d21a1c15..523c7b142c9 100644 --- a/test-suite/andreasenhugevolatilityinterpl.cpp +++ b/test-suite/andreasenhugevolatilityinterpl.cpp @@ -45,7 +45,11 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -namespace andreasen_huge_volatility_interpl_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(AndreasenHugeVolatilityInterplTests) + +namespace { struct CalibrationData { const Handle spot; @@ -387,17 +391,11 @@ namespace andreasen_huge_volatility_interpl_test { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(AndreasenHugeVolatilityInterplTest) - BOOST_AUTO_TEST_CASE(testAndreasenHugePut, *precondition(if_speed(Fast))) { BOOST_TEST_MESSAGE( "Testing Andreasen-Huge example with Put calibration..."); - using namespace andreasen_huge_volatility_interpl_test; - const CalibrationData data = AndreasenHugeExampleData(); const CalibrationResults expected = { @@ -415,8 +413,6 @@ BOOST_AUTO_TEST_CASE(testAndreasenHugeCall) { BOOST_TEST_MESSAGE( "Testing Andreasen-Huge example with Call calibration..."); - using namespace andreasen_huge_volatility_interpl_test; - const CalibrationData data = AndreasenHugeExampleData(); const CalibrationResults expected = { @@ -435,8 +431,6 @@ BOOST_AUTO_TEST_CASE(testAndreasenHugeCallPut, *precondition(if_speed(Fast))) { "Testing Andreasen-Huge example with instantaneous " "Call and Put calibration..."); - using namespace andreasen_huge_volatility_interpl_test; - const CalibrationData data = AndreasenHugeExampleData(); const CalibrationResults expected = { @@ -453,8 +447,6 @@ BOOST_AUTO_TEST_CASE(testLinearInterpolation, *precondition(if_speed(Fast))) { BOOST_TEST_MESSAGE( "Testing Andreasen-Huge example with linear interpolation..."); - using namespace andreasen_huge_volatility_interpl_test; - const CalibrationData data = AndreasenHugeExampleData(); const CalibrationResults expected = { @@ -471,8 +463,6 @@ BOOST_AUTO_TEST_CASE(testPiecewiseConstantInterpolation, *precondition(if_speed( BOOST_TEST_MESSAGE( "Testing Andreasen-Huge example with piecewise constant interpolation..."); - using namespace andreasen_huge_volatility_interpl_test; - const CalibrationData data = AndreasenHugeExampleData(); const CalibrationResults expected = { @@ -491,8 +481,6 @@ BOOST_AUTO_TEST_CASE(testTimeDependentInterestRates, *precondition(if_speed(Fast "Testing Andreasen-Huge volatility interpolation with " "time dependent interest rates and dividend yield..."); - using namespace andreasen_huge_volatility_interpl_test; - const CalibrationData data = AndreasenHugeExampleData(); const DayCounter dc = data.rTS->dayCounter(); @@ -635,8 +623,6 @@ BOOST_AUTO_TEST_CASE(testArbitrageFree) { "Testing Andreasen-Huge volatility interpolation gives " "arbitrage free prices..."); - using namespace andreasen_huge_volatility_interpl_test; - CalibrationData data[] = { BorovkovaExampleData(), arbitrageData() };; for (auto& i : data) { @@ -829,8 +815,6 @@ BOOST_AUTO_TEST_CASE(testPeterAndFabiensExample) { // http://chasethedevil.github.io/post/andreasen-huge-extrapolation/ - using namespace andreasen_huge_volatility_interpl_test; - const std::pair > sd = sabrData(); const CalibrationData& data = sd.first; const std::vector& parameter = sd.second; @@ -876,8 +860,6 @@ BOOST_AUTO_TEST_CASE(testDifferentOptimizers) { "Testing different optimizer for Andreasen-Huge " "volatility interpolation..."); - using namespace andreasen_huge_volatility_interpl_test; - const CalibrationData& data = sabrData().first; const ext::shared_ptr optimizationMethods[] = { @@ -981,8 +963,6 @@ BOOST_AUTO_TEST_CASE(testFlatVolCalibration) { BOOST_TEST_MESSAGE( "Testing Andreasen-Huge example with flat volatility surface..."); - using namespace andreasen_huge_volatility_interpl_test; - const Date ref(1, November, 2019); const DayCounter dc = Actual365Fixed(); Settings::instance().evaluationDate() = ref; diff --git a/test-suite/array.cpp b/test-suite/array.cpp index 673a58b6790..493459b26ff 100644 --- a/test-suite/array.cpp +++ b/test-suite/array.cpp @@ -25,23 +25,21 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -namespace array_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(ArrayTests) + +namespace { class FSquared { public: Real operator()(Real x) const { return x*x; } }; } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(ArrayTest) - BOOST_AUTO_TEST_CASE(testConstruction) { BOOST_TEST_MESSAGE("Testing array construction..."); - using namespace array_test; - // empty array Array a1; if (!a1.empty()) diff --git a/test-suite/asianoptions.cpp b/test-suite/asianoptions.cpp index bcaac8fc131..69b974be902 100644 --- a/test-suite/asianoptions.cpp +++ b/test-suite/asianoptions.cpp @@ -50,6 +50,10 @@ using namespace QuantLib; using namespace boost::unit_test_framework; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(AsianOptionTests) + #undef REPORT_FAILURE #define REPORT_FAILURE(greekName, averageType, \ runningAccumulator, pastFixings, \ @@ -142,10 +146,6 @@ namespace { }; } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(AsianOptionTest) - BOOST_AUTO_TEST_CASE(testAnalyticContinuousGeometricAveragePrice) { BOOST_TEST_MESSAGE( @@ -2241,7 +2241,7 @@ BOOST_AUTO_TEST_CASE(testAnalyticDiscreteGeometricAveragePriceHeston) { ext::shared_ptr engine(new AnalyticDiscreteGeometricAveragePriceAsianHestonEngine(hestonProcess)); - AsianOptionTest::testDiscreteGeometricAveragePriceHeston(engine, tol); + AsianOptionTests::testDiscreteGeometricAveragePriceHeston(engine, tol); } BOOST_AUTO_TEST_CASE(testDiscreteGeometricAveragePriceHestonPastFixings) { diff --git a/test-suite/assetswap.cpp b/test-suite/assetswap.cpp index a4c0a9dcb9d..3e4ad35a243 100644 --- a/test-suite/assetswap.cpp +++ b/test-suite/assetswap.cpp @@ -57,7 +57,11 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -namespace asset_swap_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(AssetSwapTests) + +namespace { struct CommonVars { // common data @@ -113,16 +117,10 @@ namespace asset_swap_test { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) // fails with QL_USE_INDEXED_COUPON - -BOOST_AUTO_TEST_SUITE(AssetSwapTest) - BOOST_AUTO_TEST_CASE(testConsistency) { BOOST_TEST_MESSAGE( "Testing consistency between fair price and fair spread..."); - using namespace asset_swap_test; - CommonVars vars; Calendar bondCalendar = TARGET(); @@ -509,8 +507,6 @@ BOOST_AUTO_TEST_CASE(testImpliedValue) { BOOST_TEST_MESSAGE("Testing implied bond value against asset-swap fair" " price with null spread..."); - using namespace asset_swap_test; - bool usingAtParCoupons = IborCoupon::Settings::instance().usingAtParCoupons(); CommonVars vars; @@ -877,8 +873,6 @@ BOOST_AUTO_TEST_CASE(testMarketASWSpread) { BOOST_TEST_MESSAGE("Testing relationship between market asset swap" " and par asset swap..."); - using namespace asset_swap_test; - bool usingAtParCoupons = IborCoupon::Settings::instance().usingAtParCoupons(); CommonVars vars; @@ -1317,8 +1311,6 @@ BOOST_AUTO_TEST_CASE(testZSpread) { BOOST_TEST_MESSAGE("Testing clean and dirty price with null Z-spread " "against theoretical prices..."); - using namespace asset_swap_test; - CommonVars vars; Calendar bondCalendar = TARGET(); @@ -1639,8 +1631,6 @@ BOOST_AUTO_TEST_CASE(testGenericBondImplied) { BOOST_TEST_MESSAGE("Testing implied generic-bond value against" " asset-swap fair price with null spread..."); - using namespace asset_swap_test; - bool usingAtParCoupons = IborCoupon::Settings::instance().usingAtParCoupons(); CommonVars vars; @@ -2029,8 +2019,6 @@ BOOST_AUTO_TEST_CASE(testMASWWithGenericBond) { BOOST_TEST_MESSAGE("Testing market asset swap against par asset swap " "with generic bond..."); - using namespace asset_swap_test; - bool usingAtParCoupons = IborCoupon::Settings::instance().usingAtParCoupons(); CommonVars vars; @@ -2504,8 +2492,6 @@ BOOST_AUTO_TEST_CASE(testZSpreadWithGenericBond) { BOOST_TEST_MESSAGE("Testing clean and dirty price with null Z-spread " "against theoretical prices..."); - using namespace asset_swap_test; - CommonVars vars; Calendar bondCalendar = TARGET(); @@ -2870,8 +2856,6 @@ BOOST_AUTO_TEST_CASE(testSpecializedBondVsGenericBond) { BOOST_TEST_MESSAGE("Testing clean and dirty prices for specialized bond" " against equivalent generic bond..."); - using namespace asset_swap_test; - CommonVars vars; Calendar bondCalendar = TARGET(); @@ -3431,8 +3415,6 @@ BOOST_AUTO_TEST_CASE(testSpecializedBondVsGenericBondUsingAsw) { BOOST_TEST_MESSAGE("Testing asset-swap prices and spreads for specialized" " bond against equivalent generic bond..."); - using namespace asset_swap_test; - CommonVars vars; Calendar bondCalendar = TARGET(); @@ -4257,4 +4239,4 @@ BOOST_AUTO_TEST_CASE(testSpecializedBondVsGenericBondUsingAsw) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/autocovariances.cpp b/test-suite/autocovariances.cpp index e7e5d63e76b..9303bf5a35b 100644 --- a/test-suite/autocovariances.cpp +++ b/test-suite/autocovariances.cpp @@ -24,9 +24,9 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) -BOOST_AUTO_TEST_SUITE(AutocovariancesTest) +BOOST_AUTO_TEST_SUITE(AutocovariancesTests) BOOST_AUTO_TEST_CASE(testConvolutions) { BOOST_TEST_MESSAGE("Testing convolutions..."); @@ -89,4 +89,4 @@ BOOST_AUTO_TEST_CASE(testAutoCorrelations) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/barrieroption.cpp b/test-suite/barrieroption.cpp index 0ba1535dfa3..65697fe673e 100644 --- a/test-suite/barrieroption.cpp +++ b/test-suite/barrieroption.cpp @@ -51,6 +51,10 @@ using namespace QuantLib; using namespace boost::unit_test_framework; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(BarrierOptionTests) + #undef REPORT_FAILURE #define REPORT_FAILURE(greekName, barrierType, barrier, rebate, payoff, \ exercise, s, q, r, today, v, expected, calculated, \ @@ -100,7 +104,7 @@ using namespace boost::unit_test_framework; << " tolerance: " << tolerance); -namespace barrier_option_test { +namespace { std::string barrierTypeToString(Barrier::Type type) { switch(type){ @@ -173,10 +177,6 @@ namespace barrier_option_test { BOOST_FAIL("exception expected"); \ } \ -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(BarrierOptionTest) - BOOST_AUTO_TEST_CASE(testParity) { BOOST_TEST_MESSAGE("Testing that knock-in plus knock-out barrier options " @@ -255,8 +255,6 @@ BOOST_AUTO_TEST_CASE(testHaugValues) { BOOST_TEST_MESSAGE("Testing barrier options against Haug's values..."); - using namespace barrier_option_test; - Exercise::Type european = Exercise::European; Exercise::Type american = Exercise::American; NewBarrierOptionData values[] = { @@ -522,8 +520,6 @@ BOOST_AUTO_TEST_CASE(testBabsiriValues) { BOOST_TEST_MESSAGE("Testing barrier options against Babsiri's values..."); - using namespace barrier_option_test; - /* Data from "Simulating Path-Dependent Options: A New Approach" @@ -623,8 +619,6 @@ BOOST_AUTO_TEST_CASE(testBeagleholeValues) { BOOST_TEST_MESSAGE("Testing barrier options against Beaglehole's values..."); - using namespace barrier_option_test; - /* Data from "Going to Extreme: Correcting Simulation Bias in Exotic @@ -1462,8 +1456,6 @@ BOOST_AUTO_TEST_CASE(testPerturbative) { BOOST_AUTO_TEST_CASE(testVannaVolgaSimpleBarrierValues) { BOOST_TEST_MESSAGE("Testing barrier FX options against Vanna/Volga values..."); - using namespace barrier_option_test; - BarrierFxOptionData values[] = { //barrierType,barrier,rebate,type,strike,s,q,r,t,vol25Put,volAtm,vol25Call,vol, result, tol diff --git a/test-suite/basismodels.cpp b/test-suite/basismodels.cpp index 76525cc461c..3808c0a0abb 100644 --- a/test-suite/basismodels.cpp +++ b/test-suite/basismodels.cpp @@ -39,6 +39,10 @@ using namespace QuantLib; using namespace boost::unit_test_framework; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(BasisModelsTests) + namespace { // auxiliary data @@ -224,10 +228,6 @@ namespace { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(BasisModelsTest) - BOOST_AUTO_TEST_CASE(testSwaptioncfsContCompSpread) { BOOST_TEST_MESSAGE( "Testing deterministic tenor basis model with continuous compounded spreads..."); diff --git a/test-suite/basisswapratehelpers.cpp b/test-suite/basisswapratehelpers.cpp index a135cbd0a13..0158e8a7c08 100644 --- a/test-suite/basisswapratehelpers.cpp +++ b/test-suite/basisswapratehelpers.cpp @@ -32,7 +32,11 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -namespace basisswapratehelpers_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(BasisSwapRateHelpersTests) + +namespace { struct BasisSwapQuote { Integer n; @@ -210,32 +214,28 @@ namespace basisswapratehelpers_test { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(BasisSwapRateHelpersTest) - BOOST_AUTO_TEST_CASE(testIborIborBaseCurveBootstrap) { BOOST_TEST_MESSAGE("Testing IBOR-IBOR basis-swap rate helpers (base curve bootstrap)..."); - basisswapratehelpers_test::testIborIborBootstrap(true); + testIborIborBootstrap(true); } BOOST_AUTO_TEST_CASE(testIborIborOtherCurveBootstrap) { BOOST_TEST_MESSAGE("Testing IBOR-IBOR basis-swap rate helpers (other curve bootstrap)..."); - basisswapratehelpers_test::testIborIborBootstrap(false); + testIborIborBootstrap(false); } -BOOST_AUTO_TEST_CASE(testOvernightIborBootstrap) { +BOOST_AUTO_TEST_CASE(testOvernightIborBootstrapWithoutDiscountCurve) { BOOST_TEST_MESSAGE("Testing overnight-IBOR basis-swap rate helpers..."); - basisswapratehelpers_test::testOvernightIborBootstrap(false); + testOvernightIborBootstrap(false); } BOOST_AUTO_TEST_CASE(testOvernightIborBootstrapWithDiscountCurve) { BOOST_TEST_MESSAGE("Testing overnight-IBOR basis-swap rate helpers with external discount curve..."); - basisswapratehelpers_test::testOvernightIborBootstrap(true); + testOvernightIborBootstrap(true); } BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/basketoption.cpp b/test-suite/basketoption.cpp index a7c4c4ccd81..bc23923d047 100644 --- a/test-suite/basketoption.cpp +++ b/test-suite/basketoption.cpp @@ -41,6 +41,10 @@ using namespace QuantLib; using namespace boost::unit_test_framework; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(BasketOptionTests) + #undef REPORT_FAILURE_2 #define REPORT_FAILURE_2(greekName, basketType, payoff, exercise, \ s1, s2, q1, q2, r, today, v1, v2, rho, \ @@ -210,10 +214,6 @@ namespace { }; } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(BasketOptionTest) - BOOST_AUTO_TEST_CASE(testEuroTwoValues) { BOOST_TEST_MESSAGE("Testing two-asset European basket options..."); diff --git a/test-suite/batesmodel.cpp b/test-suite/batesmodel.cpp index 37fca3cfb15..32a718250b6 100644 --- a/test-suite/batesmodel.cpp +++ b/test-suite/batesmodel.cpp @@ -42,7 +42,11 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -namespace bates_model_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(BatesModelTests) + +namespace { Real getCalibrationError( std::vector > & options) { @@ -80,10 +84,6 @@ namespace bates_model_test { }; } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(BatesModelTest) - BOOST_AUTO_TEST_CASE(testAnalyticVsBlack) { BOOST_TEST_MESSAGE("Testing analytic Bates engine against Black formula..."); @@ -295,8 +295,6 @@ BOOST_AUTO_TEST_CASE(testAnalyticVsMCPricing) { BOOST_TEST_MESSAGE("Testing analytic Bates engine against Monte-Carlo " "engine..."); - using namespace bates_model_test; - Date settlementDate(30, March, 2007); Settings::instance().evaluationDate() = settlementDate; @@ -374,8 +372,6 @@ BOOST_AUTO_TEST_CASE(testDAXCalibration) { BOOST_TEST_MESSAGE( "Testing Bates model calibration using DAX volatility data..."); - using namespace bates_model_test; - Date settlementDate(5, July, 2002); Settings::instance().evaluationDate() = settlementDate; @@ -517,4 +513,4 @@ BOOST_AUTO_TEST_CASE(testDAXCalibration) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/bermudanswaption.cpp b/test-suite/bermudanswaption.cpp index 3aacba01342..5300b971298 100644 --- a/test-suite/bermudanswaption.cpp +++ b/test-suite/bermudanswaption.cpp @@ -41,7 +41,11 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -namespace bermudan_swaption_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(BermudanSwaptionTests) + +namespace { struct CommonVars { // global data @@ -107,17 +111,11 @@ namespace bermudan_swaption_test { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(BermudanSwaptionTest) - BOOST_AUTO_TEST_CASE(testCachedValues) { BOOST_TEST_MESSAGE( "Testing Bermudan swaption with HW model against cached values..."); - using namespace bermudan_swaption_test; - bool usingAtParCoupons = IborCoupon::Settings::instance().usingAtParCoupons(); CommonVars vars; @@ -243,8 +241,6 @@ BOOST_AUTO_TEST_CASE(testCachedG2Values, *precondition(if_speed(Fast))) { BOOST_TEST_MESSAGE( "Testing Bermudan swaption with G2 model against cached values..."); - using namespace bermudan_swaption_test; - bool usingAtParCoupons = IborCoupon::Settings::instance().usingAtParCoupons(); CommonVars vars; @@ -379,4 +375,4 @@ BOOST_AUTO_TEST_CASE(testTreeEngineTimeSnapping) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/binaryoption.cpp b/test-suite/binaryoption.cpp index 9124d0ac2b6..3acdab84274 100644 --- a/test-suite/binaryoption.cpp +++ b/test-suite/binaryoption.cpp @@ -36,6 +36,10 @@ using namespace QuantLib; using namespace boost::unit_test_framework; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(BinaryOptionTests) + #undef REPORT_FAILURE #define REPORT_FAILURE(greekName, payoff, exercise, barrierType, barrier, s, q,\ r, today, v, expected, calculated, error, tolerance) \ @@ -55,7 +59,7 @@ using namespace boost::unit_test_framework; << " error: " << error << "\n" \ << " tolerance: " << tolerance << "\n"); -namespace binary_option_test { +namespace { std::string barrierTypeToString(Barrier::Type type) { switch(type){ @@ -88,16 +92,10 @@ namespace binary_option_test { }; } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(BinaryOptionTest) - BOOST_AUTO_TEST_CASE(testCashOrNothingHaugValues) { BOOST_TEST_MESSAGE("Testing cash-or-nothing barrier options against Haug's values..."); - using namespace binary_option_test; - BinaryOptionData values[] = { /* The data below are from "Option pricing formulas 2nd Ed.", E.G. Haug, McGraw-Hill 2007 pag. 180 - cases 13,14,17,18,21,22,25,26 @@ -195,8 +193,6 @@ BOOST_AUTO_TEST_CASE(testAssetOrNothingHaugValues) { BOOST_TEST_MESSAGE("Testing asset-or-nothing barrier options against Haug's values..."); - using namespace binary_option_test; - BinaryOptionData values[] = { /* The data below are from "Option pricing formulas 2nd Ed.", E.G. Haug, McGraw-Hill 2007 pag. 180 - cases 15,16,19,20,23,24,27,28 @@ -274,4 +270,4 @@ BOOST_AUTO_TEST_CASE(testAssetOrNothingHaugValues) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/blackdeltacalculator.cpp b/test-suite/blackdeltacalculator.cpp index 4ff813f3906..886f732e98e 100644 --- a/test-suite/blackdeltacalculator.cpp +++ b/test-suite/blackdeltacalculator.cpp @@ -34,7 +34,11 @@ using namespace boost::unit_test_framework; using std::sqrt; -namespace black_delta_calculator_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(BlackDeltaCalculatorTests) + +namespace { struct DeltaData { Option::Type ot; @@ -61,16 +65,10 @@ namespace black_delta_calculator_test { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(BlackDeltaCalculatorTest) - BOOST_AUTO_TEST_CASE(testDeltaValues){ BOOST_TEST_MESSAGE("Testing delta calculator values..."); - using namespace black_delta_calculator_test; - DeltaData values[] = { // Values taken from parallel implementation in R {Option::Call, DeltaVolQuote::Spot, 1.421, 0.997306, 0.992266, 0.1180654, 1.608080, 0.15}, @@ -154,8 +152,6 @@ BOOST_AUTO_TEST_CASE(testDeltaPriceConsistency) { BOOST_TEST_MESSAGE("Testing premium-adjusted delta price consistency..."); - using namespace black_delta_calculator_test; - // This function tests for price consistencies with the standard // Black Scholes calculator, since premium adjusted deltas can be calculated // from spot deltas by adding/subtracting the premium. @@ -319,8 +315,6 @@ BOOST_AUTO_TEST_CASE(testPutCallParity){ BOOST_TEST_MESSAGE("Testing put-call parity for deltas..."); - using namespace black_delta_calculator_test; - // Test for put call parity between put and call deltas. /* The data below are from @@ -524,8 +518,6 @@ BOOST_AUTO_TEST_CASE(testAtmCalcs){ BOOST_TEST_MESSAGE("Testing delta-neutral ATM quotations..."); - using namespace black_delta_calculator_test; - DeltaData values[] = { {Option::Call, DeltaVolQuote::Spot, 1.421, 0.997306, 0.992266, 0.1180654, 1.608080, 0.15}, {Option::Call, DeltaVolQuote::PaSpot, 1.421, 0.997306, 0.992266, 0.1180654, 1.600545, 0.15}, diff --git a/test-suite/blackformula.cpp b/test-suite/blackformula.cpp index 067158b7764..99360123205 100644 --- a/test-suite/blackformula.cpp +++ b/test-suite/blackformula.cpp @@ -29,9 +29,9 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) -BOOST_AUTO_TEST_SUITE(BlackFormulaTest) +BOOST_AUTO_TEST_SUITE(BlackFormulaTests) BOOST_AUTO_TEST_CASE(testBachelierImpliedVol){ @@ -437,4 +437,4 @@ BOOST_AUTO_TEST_CASE(testBachelierBlackFormulaForwardDerivativeWithZeroVolatilit BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/bondforward.cpp b/test-suite/bondforward.cpp index 06c84a1cbf2..9f248b5df89 100644 --- a/test-suite/bondforward.cpp +++ b/test-suite/bondforward.cpp @@ -27,7 +27,11 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -namespace bond_forward_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(BondForwardTests) + +namespace { struct CommonVars { // common data @@ -64,15 +68,9 @@ namespace bond_forward_test { } } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(BondForwardTest) - BOOST_AUTO_TEST_CASE(testFuturesPriceReplication) { BOOST_TEST_MESSAGE("Testing futures price replication..."); - using namespace bond_forward_test; - CommonVars vars; Real tolerance = 1.0e-2; @@ -101,8 +99,6 @@ BOOST_AUTO_TEST_CASE(testFuturesPriceReplication) { BOOST_AUTO_TEST_CASE(testCleanForwardPriceReplication) { BOOST_TEST_MESSAGE("Testing clean forward price replication..."); - using namespace bond_forward_test; - CommonVars vars; Real tolerance = 1.0e-2; @@ -131,8 +127,6 @@ BOOST_AUTO_TEST_CASE(testThatForwardValueIsEqualToSpotValueIfNoIncome) { BOOST_TEST_MESSAGE( "Testing that forward value is equal to spot value if no income..."); - using namespace bond_forward_test; - CommonVars vars; Real tolerance = 1.0e-2; @@ -159,4 +153,4 @@ BOOST_AUTO_TEST_CASE(testThatForwardValueIsEqualToSpotValueIfNoIncome) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/bonds.cpp b/test-suite/bonds.cpp index afbd748ad39..14384d3b900 100644 --- a/test-suite/bonds.cpp +++ b/test-suite/bonds.cpp @@ -54,6 +54,10 @@ using namespace QuantLib; using namespace boost::unit_test_framework; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(BondsTests) + #define ASSERT_CLOSE(name, settlement, calculated, expected, tolerance) \ if (std::fabs(calculated-expected) > tolerance) { \ BOOST_ERROR("Failed to reproduce " << name << " at " << settlement \ @@ -61,7 +65,7 @@ using namespace boost::unit_test_framework; << "\n expected: " << std::setprecision(8) << expected); \ } -namespace bonds_test { +namespace { struct CommonVars { // common data @@ -91,16 +95,10 @@ namespace bonds_test { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(BondsTest) - BOOST_AUTO_TEST_CASE(testYield) { BOOST_TEST_MESSAGE("Testing consistency of bond price/yield calculation..."); - using namespace bonds_test; - CommonVars vars; Real tolerance = 1.0e-7; @@ -199,8 +197,6 @@ BOOST_AUTO_TEST_CASE(testAtmRate) { BOOST_TEST_MESSAGE("Testing consistency of bond price/ATM rate calculation..."); - using namespace bonds_test; - CommonVars vars; Real tolerance = 1.0e-7; @@ -259,8 +255,6 @@ BOOST_AUTO_TEST_CASE(testZspread) { BOOST_TEST_MESSAGE("Testing consistency of bond price/z-spread calculation..."); - using namespace bonds_test; - CommonVars vars; Real tolerance = 1.0e-7; @@ -338,8 +332,6 @@ BOOST_AUTO_TEST_CASE(testTheoretical) { BOOST_TEST_MESSAGE("Testing theoretical bond price/yield calculation..."); - using namespace bonds_test; - CommonVars vars; Real tolerance = 1.0e-7; @@ -419,8 +411,6 @@ BOOST_AUTO_TEST_CASE(testCached) { BOOST_TEST_MESSAGE( "Testing bond price/yield calculation against cached values..."); - using namespace bonds_test; - CommonVars vars; // with implicit settlement calculation: @@ -690,8 +680,6 @@ BOOST_AUTO_TEST_CASE(testCachedZero) { BOOST_TEST_MESSAGE("Testing zero-coupon bond prices against cached values..."); - using namespace bonds_test; - CommonVars vars; Date today(22,November,2004); @@ -772,8 +760,6 @@ BOOST_AUTO_TEST_CASE(testCachedFixed) { BOOST_TEST_MESSAGE("Testing fixed-coupon bond prices against cached values..."); - using namespace bonds_test; - CommonVars vars; Date today(22,November,2004); @@ -871,8 +857,6 @@ BOOST_AUTO_TEST_CASE(testCachedFloating) { BOOST_TEST_MESSAGE("Testing floating-rate bond prices against cached values..."); - using namespace bonds_test; - bool usingAtParCoupons = IborCoupon::Settings::instance().usingAtParCoupons(); CommonVars vars; @@ -1013,8 +997,6 @@ BOOST_AUTO_TEST_CASE(testBrazilianCached) { BOOST_TEST_MESSAGE( "Testing Brazilian public bond prices against Andima cached values..."); - using namespace bonds_test; - CommonVars vars; Natural settlementDays = 1; @@ -1439,8 +1421,6 @@ BOOST_AUTO_TEST_CASE(testFixedBondWithGivenDates) { BOOST_TEST_MESSAGE("Testing fixed-coupon bond built on schedule with given dates..."); - using namespace bonds_test; - CommonVars vars; Date today(22,November,2004); @@ -1561,8 +1541,6 @@ BOOST_AUTO_TEST_CASE(testRiskyBondWithGivenDates) { BOOST_TEST_MESSAGE("Testing risky bond engine..."); - using namespace bonds_test; - CommonVars vars; Date today(22, November, 2005); @@ -1707,4 +1685,4 @@ BOOST_AUTO_TEST_CASE(testThirty360BondWithSettlementOn31st){ BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/brownianbridge.cpp b/test-suite/brownianbridge.cpp index bd53c766a81..ea291230bec 100644 --- a/test-suite/brownianbridge.cpp +++ b/test-suite/brownianbridge.cpp @@ -32,6 +32,10 @@ using namespace QuantLib; using namespace boost::unit_test_framework; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(BrownianBridgeTests) + namespace { template @@ -58,10 +62,6 @@ namespace { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(BrownianBridgeTest) - BOOST_AUTO_TEST_CASE(testVariates) { BOOST_TEST_MESSAGE("Testing Brownian-bridge variates..."); @@ -248,4 +248,4 @@ BOOST_AUTO_TEST_CASE(testPathGeneration) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/businessdayconventions.cpp b/test-suite/businessdayconventions.cpp index 6790fe31087..11888917695 100644 --- a/test-suite/businessdayconventions.cpp +++ b/test-suite/businessdayconventions.cpp @@ -26,7 +26,12 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -namespace business_day_conventions_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(BusinessDayConventionTests) + +namespace { + struct SingleCase { SingleCase(Calendar calendar, const BusinessDayConvention& convention, @@ -46,16 +51,10 @@ namespace business_day_conventions_test { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(BusinessDayConventionTest) - BOOST_AUTO_TEST_CASE(testConventions) { BOOST_TEST_MESSAGE("Testing business day conventions..."); - using namespace business_day_conventions_test; - SingleCase testCases[] = { // Following SingleCase(SouthAfrica(), Following, Date(3,February,2015), Period(1,Months), false, Date(3,March,2015)), @@ -128,4 +127,4 @@ BOOST_AUTO_TEST_CASE(testConventions) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/calendars.cpp b/test-suite/calendars.cpp index 1bcf51daf85..e10f36b241e 100644 --- a/test-suite/calendars.cpp +++ b/test-suite/calendars.cpp @@ -49,9 +49,9 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) -BOOST_AUTO_TEST_SUITE(CalendarTest) +BOOST_AUTO_TEST_SUITE(CalendarTests) BOOST_AUTO_TEST_CASE(testModifiedCalendars) { @@ -3601,4 +3601,4 @@ BOOST_AUTO_TEST_CASE(testDayLists) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/callablebonds.cpp b/test-suite/callablebonds.cpp index b9945e36406..83fccf665e9 100644 --- a/test-suite/callablebonds.cpp +++ b/test-suite/callablebonds.cpp @@ -40,6 +40,10 @@ using namespace QuantLib; using namespace boost::unit_test_framework; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(CallableBondTests) + namespace { struct Globals { @@ -94,10 +98,6 @@ namespace { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(CallableBondTest) - BOOST_AUTO_TEST_CASE(testInterplay) { BOOST_TEST_MESSAGE("Testing interplay of callability and puttability for callable bonds..."); diff --git a/test-suite/capfloor.cpp b/test-suite/capfloor.cpp index 4fae635e902..19d41d335f7 100644 --- a/test-suite/capfloor.cpp +++ b/test-suite/capfloor.cpp @@ -44,7 +44,11 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -namespace capfloor_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(CapFloorTests) + +namespace { struct CommonVars { // common data @@ -145,16 +149,10 @@ namespace capfloor_test { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(CapFloorTest) - BOOST_AUTO_TEST_CASE(testVega) { BOOST_TEST_MESSAGE("Testing cap/floor vega..."); - using namespace capfloor_test; - CommonVars vars; Integer lengths[] = { 1, 2, 3, 4, 5, 6, 7, 10, 15, 20, 30 }; @@ -204,8 +202,6 @@ BOOST_AUTO_TEST_CASE(testStrikeDependency) { BOOST_TEST_MESSAGE("Testing cap/floor dependency on strike..."); - using namespace capfloor_test; - CommonVars vars; Integer lengths[] = { 1, 2, 3, 5, 7, 10, 15, 20 }; @@ -259,8 +255,6 @@ BOOST_AUTO_TEST_CASE(testConsistency) { BOOST_TEST_MESSAGE("Testing consistency between cap, floor and collar..."); - using namespace capfloor_test; - CommonVars vars; Integer lengths[] = { 1, 2, 3, 5, 7, 10, 15, 20 }; @@ -366,8 +360,6 @@ BOOST_AUTO_TEST_CASE(testParity) { BOOST_TEST_MESSAGE("Testing cap/floor parity..."); - using namespace capfloor_test; - CommonVars vars; Integer lengths[] = { 1, 2, 3, 5, 7, 10, 15, 20 }; @@ -411,8 +403,6 @@ BOOST_AUTO_TEST_CASE(testATMRate) { BOOST_TEST_MESSAGE("Testing cap/floor ATM rate..."); - using namespace capfloor_test; - CommonVars vars; Integer lengths[] = { 1, 2, 3, 5, 7, 10, 15, 20 }; @@ -469,8 +459,6 @@ BOOST_AUTO_TEST_CASE(testImpliedVolatility) { BOOST_TEST_MESSAGE("Testing implied term volatility for cap and floor..."); - using namespace capfloor_test; - CommonVars vars; Size maxEvaluations = 100; @@ -554,8 +542,6 @@ BOOST_AUTO_TEST_CASE(testCachedValue) { BOOST_TEST_MESSAGE("Testing Black cap/floor price against cached values..."); - using namespace capfloor_test; - CommonVars vars; Date cachedToday(14,March,2002), @@ -600,8 +586,6 @@ BOOST_AUTO_TEST_CASE(testCachedValueFromOptionLets) { BOOST_TEST_MESSAGE("Testing Black cap/floor price as a sum of optionlets prices against cached values..."); - using namespace capfloor_test; - CommonVars vars; Date cachedToday(14,March,2002), @@ -669,8 +653,6 @@ BOOST_AUTO_TEST_CASE(testOptionLetsDelta) { BOOST_TEST_MESSAGE("Testing Black caplet/floorlet delta coefficients against finite difference values..."); - using namespace capfloor_test; - CommonVars vars; Date cachedToday(14,March,2002), @@ -792,8 +774,6 @@ BOOST_AUTO_TEST_CASE(testBachelierOptionLetsDelta) { BOOST_TEST_MESSAGE("Testing Bachelier caplet/floorlet delta coefficients against finite difference values..."); - using namespace capfloor_test; - CommonVars vars; Date cachedToday(14,March,2002), @@ -916,4 +896,4 @@ BOOST_AUTO_TEST_CASE(testBachelierOptionLetsDelta) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/capflooredcoupon.cpp b/test-suite/capflooredcoupon.cpp index a95a502913e..e155f36b631 100644 --- a/test-suite/capflooredcoupon.cpp +++ b/test-suite/capflooredcoupon.cpp @@ -40,7 +40,11 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -namespace capfloored_coupon_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(CapFlooredCouponTests) + +namespace { struct CommonVars { // global data @@ -185,16 +189,10 @@ namespace capfloored_coupon_test { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(CapFlooredCouponTest) - BOOST_AUTO_TEST_CASE(testLargeRates) { BOOST_TEST_MESSAGE("Testing degenerate collared coupon..."); - using namespace capfloored_coupon_test; - CommonVars vars; /* A vanilla floating leg and a capped floating leg with strike @@ -239,8 +237,6 @@ BOOST_AUTO_TEST_CASE(testDecomposition) { BOOST_TEST_MESSAGE("Testing collared coupon against its decomposition..."); - using namespace capfloored_coupon_test; - CommonVars vars; Real tolerance = 1e-12; diff --git a/test-suite/cashflows.cpp b/test-suite/cashflows.cpp index f303d5da669..52cc4b9d7cc 100644 --- a/test-suite/cashflows.cpp +++ b/test-suite/cashflows.cpp @@ -42,9 +42,9 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) -BOOST_AUTO_TEST_SUITE(CashFlowTest) +BOOST_AUTO_TEST_SUITE(CashFlowTests) BOOST_AUTO_TEST_CASE(testSettings) { @@ -539,4 +539,4 @@ BOOST_AUTO_TEST_CASE(testFixedIborCouponWithoutForecastCurve) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/catbonds.cpp b/test-suite/catbonds.cpp index 67a9b03b3a7..8b5a8b39b5b 100644 --- a/test-suite/catbonds.cpp +++ b/test-suite/catbonds.cpp @@ -48,7 +48,11 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -namespace catbonds_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(CatBondTests) + +namespace { std::pair data[] = {std::pair(Date(1, February, 2012), 100), std::pair(Date(1, July, 2013), 150), std::pair(Date(5, January, 2014), 50)}; ext::shared_ptr > > sampleEvents(new std::vector >(data, data+3)); @@ -71,15 +75,9 @@ namespace catbonds_test { }; } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(CatBondTest) - BOOST_AUTO_TEST_CASE(testEventSetForWholeYears) { BOOST_TEST_MESSAGE("Testing that catastrophe events are split correctly for periods of whole years..."); - using namespace catbonds_test; - EventSet catRisk(sampleEvents, eventsStart, eventsEnd); ext::shared_ptr simulation = catRisk.newSimulation(Date(1, January, 2015), Date(31, December, 2015)); @@ -111,8 +109,6 @@ BOOST_AUTO_TEST_CASE(testEventSetForWholeYears) { BOOST_AUTO_TEST_CASE(testEventSetForIrregularPeriods) { BOOST_TEST_MESSAGE("Testing that catastrophe events are split correctly for irregular periods..."); - using namespace catbonds_test; - EventSet catRisk(sampleEvents, eventsStart, eventsEnd); ext::shared_ptr simulation = catRisk.newSimulation(Date(2, January, 2015), Date(5, January, 2016)); @@ -136,8 +132,6 @@ BOOST_AUTO_TEST_CASE(testEventSetForIrregularPeriods) { BOOST_AUTO_TEST_CASE(testEventSetForNoEvents) { BOOST_TEST_MESSAGE("Testing that catastrophe events are split correctly when there are no simulated events..."); - using namespace catbonds_test; - ext::shared_ptr > > emptyEvents(new std::vector >()); EventSet catRisk(emptyEvents, eventsStart, eventsEnd); ext::shared_ptr simulation = catRisk.newSimulation(Date(2, January, 2015), Date(5, January, 2016)); @@ -207,8 +201,6 @@ BOOST_AUTO_TEST_CASE(testBetaRisk) { BOOST_AUTO_TEST_CASE(testRiskFreeAgainstFloatingRateBond) { BOOST_TEST_MESSAGE("Testing floating-rate cat bond against risk-free floating-rate bond..."); - using namespace catbonds_test; - bool usingAtParCoupons = IborCoupon::Settings::instance().usingAtParCoupons(); CommonVars vars; @@ -375,8 +367,6 @@ BOOST_AUTO_TEST_CASE(testRiskFreeAgainstFloatingRateBond) { BOOST_AUTO_TEST_CASE(testCatBondInDoomScenario) { BOOST_TEST_MESSAGE("Testing floating-rate cat bond in a doom scenario (certain default)..."); - using namespace catbonds_test; - CommonVars vars; Date today(22,November,2004); @@ -439,8 +429,6 @@ BOOST_AUTO_TEST_CASE(testCatBondInDoomScenario) { BOOST_AUTO_TEST_CASE(testCatBondWithDoomOnceInTenYears) { BOOST_TEST_MESSAGE("Testing floating-rate cat bond in a doom once in 10 years scenario..."); - using namespace catbonds_test; - CommonVars vars; Date today(22,November,2004); @@ -522,8 +510,6 @@ BOOST_AUTO_TEST_CASE(testCatBondWithDoomOnceInTenYears) { BOOST_AUTO_TEST_CASE(testCatBondWithDoomOnceInTenYearsProportional) { BOOST_TEST_MESSAGE("Testing floating-rate cat bond in a doom once in 10 years scenario with proportional notional reduction..."); - using namespace catbonds_test; - CommonVars vars; Date today(22,November,2004); @@ -603,8 +589,6 @@ BOOST_AUTO_TEST_CASE(testCatBondWithDoomOnceInTenYearsProportional) { BOOST_AUTO_TEST_CASE(testCatBondWithGeneratedEventsProportional) { BOOST_TEST_MESSAGE("Testing floating-rate cat bond in a generated scenario with proportional notional reduction..."); - using namespace catbonds_test; - CommonVars vars; Date today(22,November,2004); diff --git a/test-suite/cdo.cpp b/test-suite/cdo.cpp index eccdd9b24da..ae3ea564579 100644 --- a/test-suite/cdo.cpp +++ b/test-suite/cdo.cpp @@ -42,9 +42,13 @@ using namespace QuantLib; using namespace boost::unit_test_framework; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(CdoTests, *precondition(if_speed(Slow))) + #ifndef QL_PATCH_SOLARIS -namespace cdo_test { +namespace { Real hwAttachment[] = { 0.00, 0.03, 0.06, 0.10 }; Real hwDetachment[] = { 0.03, 0.06, 0.10, 1.00 }; @@ -90,14 +94,6 @@ namespace cdo_test { } -#endif - -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(CdoTest, *precondition(if_speed(Slow))) - -#ifndef QL_PATCH_SOLARIS - struct dataSetOne { static const int dataset{0}; }; struct dataSetTwo { static const int dataset{1}; }; struct dataSetThree { static const int dataset{2}; }; @@ -114,8 +110,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(testHW, T, dataSets) { " for data set " << dataSet << "..."); - using namespace cdo_test; - Size poolSize = 100; Real lambda = 0.01; diff --git a/test-suite/cdsoption.cpp b/test-suite/cdsoption.cpp index 28c4755ecd6..08faee24399 100644 --- a/test-suite/cdsoption.cpp +++ b/test-suite/cdsoption.cpp @@ -34,9 +34,9 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) -BOOST_AUTO_TEST_SUITE(CdsOptionTest) +BOOST_AUTO_TEST_SUITE(CdsOptionTests) BOOST_AUTO_TEST_CASE(testCached) { diff --git a/test-suite/chooseroption.cpp b/test-suite/chooseroption.cpp index ff513066121..bd9e5eb9df0 100644 --- a/test-suite/chooseroption.cpp +++ b/test-suite/chooseroption.cpp @@ -30,6 +30,10 @@ using namespace QuantLib; using namespace boost::unit_test_framework; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(ChooserOptionTests) + #undef REPORT_FAILURE #define REPORT_FAILURE(greekName, choosingDate, \ exercise, s, q, r, today, v, \ @@ -49,10 +53,6 @@ using namespace boost::unit_test_framework; << "\n" \ << " tolerance: " << tolerance); -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(ChooserOptionTest) - BOOST_AUTO_TEST_CASE(testAnalyticSimpleChooserEngine){ BOOST_TEST_MESSAGE("Testing analytic simple chooser option..."); @@ -160,4 +160,4 @@ BOOST_AUTO_TEST_CASE(testAnalyticComplexChooserEngine){ BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/cliquetoption.cpp b/test-suite/cliquetoption.cpp index fa7b0317931..9efd882b9d4 100644 --- a/test-suite/cliquetoption.cpp +++ b/test-suite/cliquetoption.cpp @@ -34,6 +34,10 @@ using namespace QuantLib; using namespace boost::unit_test_framework; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(CliquetOptionTests) + #undef REPORT_FAILURE #define REPORT_FAILURE(greekName, payoff, exercise, s, q, r, today, v, \ expected, calculated, error, tolerance) \ @@ -50,10 +54,6 @@ using namespace boost::unit_test_framework; << " error: " << error << "\n" \ << " tolerance: " << tolerance); -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(CliquetOptionTest) - BOOST_AUTO_TEST_CASE(testValues) { BOOST_TEST_MESSAGE("Testing Cliquet option values..."); diff --git a/test-suite/cms.cpp b/test-suite/cms.cpp index cdc47a5aa6a..271d8a093df 100644 --- a/test-suite/cms.cpp +++ b/test-suite/cms.cpp @@ -43,7 +43,11 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -namespace cms_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(CmsTests) + +namespace { struct CommonVars { // global data @@ -243,16 +247,10 @@ namespace cms_test { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(CmsTest) - BOOST_AUTO_TEST_CASE(testFairRate) { BOOST_TEST_MESSAGE("Testing Hagan-pricer flat-vol equivalence for coupons (lognormal case)..."); - using namespace cms_test; - CommonVars vars; ext::shared_ptr swapIndex(new SwapIndex("EuriborSwapIsdaFixA", @@ -317,8 +315,6 @@ BOOST_AUTO_TEST_CASE(testCmsSwap) { BOOST_TEST_MESSAGE("Testing Hagan-pricer flat-vol equivalence for swaps (lognormal case)..."); - using namespace cms_test; - CommonVars vars; ext::shared_ptr swapIndex(new SwapIndex("EuriborSwapIsdaFixA", @@ -380,8 +376,6 @@ BOOST_AUTO_TEST_CASE(testParity) { BOOST_TEST_MESSAGE("Testing put-call parity for capped-floored CMS coupons (lognormal case)..."); - using namespace cms_test; - CommonVars vars; std::vector > swaptionVols = { @@ -470,4 +464,4 @@ BOOST_AUTO_TEST_CASE(testParity) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/cms_normal.cpp b/test-suite/cms_normal.cpp index 9d15f03c8cf..b2cd7bfab1d 100644 --- a/test-suite/cms_normal.cpp +++ b/test-suite/cms_normal.cpp @@ -44,7 +44,11 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -namespace cms_normal_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(CmsNormalTests) + +namespace { struct CommonVars { // global data @@ -270,16 +274,10 @@ namespace cms_normal_test { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(CmsNormalTest) - BOOST_AUTO_TEST_CASE(testFairRate) { BOOST_TEST_MESSAGE("Testing Hagan-pricer flat-vol equivalence for coupons (normal case)..."); - using namespace cms_normal_test; - CommonVars vars; ext::shared_ptr swapIndex(new SwapIndex("CMS10Y", @@ -343,8 +341,6 @@ BOOST_AUTO_TEST_CASE(testCmsSwap) { BOOST_TEST_MESSAGE("Testing Hagan-pricer flat-vol equivalence for swaps (normal case)..."); - using namespace cms_normal_test; - CommonVars vars; ext::shared_ptr swapIndex(new SwapIndex("CMS10Y", @@ -405,8 +401,6 @@ BOOST_AUTO_TEST_CASE(testParity) { BOOST_TEST_MESSAGE("Testing put-call parity for capped-floored CMS coupons (normal case)..."); - using namespace cms_normal_test; - CommonVars vars; std::vector > swaptionVols = { @@ -505,4 +499,4 @@ BOOST_AUTO_TEST_CASE(testParity) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/cmsspread.cpp b/test-suite/cmsspread.cpp index 762d8d6330c..c8024dc2943 100644 --- a/test-suite/cmsspread.cpp +++ b/test-suite/cmsspread.cpp @@ -43,6 +43,10 @@ using namespace QuantLib; using namespace boost::unit_test_framework; using namespace boost::accumulators; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(CmsSpreadTests) + namespace { struct TestData { TestData() { @@ -91,10 +95,6 @@ struct TestData { }; } // namespace -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(CmsSpreadTest) - BOOST_AUTO_TEST_CASE(testFixings) { BOOST_TEST_MESSAGE("Testing fixings of cms spread indices..."); diff --git a/test-suite/commodityunitofmeasure.cpp b/test-suite/commodityunitofmeasure.cpp index 69fbe3de8a2..55ba1a99584 100644 --- a/test-suite/commodityunitofmeasure.cpp +++ b/test-suite/commodityunitofmeasure.cpp @@ -25,9 +25,9 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) -BOOST_AUTO_TEST_SUITE(CommodityUnitOfMeasureTest) +BOOST_AUTO_TEST_SUITE(CommodityUnitOfMeasureTests) BOOST_AUTO_TEST_CASE(testDirect) { diff --git a/test-suite/compiledboostversion.cpp b/test-suite/compiledboostversion.cpp index ef6322ffca0..6e7a9a7c7b0 100644 --- a/test-suite/compiledboostversion.cpp +++ b/test-suite/compiledboostversion.cpp @@ -27,9 +27,9 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) -BOOST_AUTO_TEST_SUITE(CompiledBoostVersionTest) +BOOST_AUTO_TEST_SUITE(CompiledBoostVersionTests) BOOST_AUTO_TEST_CASE(test) { diff --git a/test-suite/compoundoption.cpp b/test-suite/compoundoption.cpp index de7df293787..d2c260b34a0 100644 --- a/test-suite/compoundoption.cpp +++ b/test-suite/compoundoption.cpp @@ -34,6 +34,10 @@ using namespace QuantLib; using namespace boost::unit_test_framework; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(CompoundOptionTests) + #undef REPORT_FAILURE #define REPORT_FAILURE(greekName, payoffM, payoffD, exerciseM, \ exerciseD, s, q, r, today, \ @@ -55,7 +59,7 @@ using namespace boost::unit_test_framework; "\nerror: " << error << \ "\ntolerance: " << tolerance); -namespace compound_option_test { +namespace { struct CompoundOptionData { Option::Type typeMother; @@ -78,16 +82,10 @@ namespace compound_option_test { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(CompoundOptionTest) - BOOST_AUTO_TEST_CASE(testPutCallParity){ BOOST_TEST_MESSAGE("Testing compound-option put-call parity..."); - using namespace compound_option_test; - // Test Put Call Parity for compound options. // Formula taken from: "Foreign Exchange Risk", Wystup, Risk 2002 // Page 81, Equation 9.5 @@ -202,8 +200,6 @@ BOOST_AUTO_TEST_CASE(testValues){ BOOST_TEST_MESSAGE("Testing compound-option values and greeks..."); - using namespace compound_option_test; - CompoundOptionData values[] = { // type Mother, typeDaughter, strike Mother, strike Daughter, spot, q, r, t Mother, t Daughter, vol, value, tol, delta, gamma, vega, theta // Tolerance is taken to be pretty high with 1.0e-3, since the price/theta is very sensitive with respect to @@ -350,4 +346,4 @@ BOOST_AUTO_TEST_CASE(testValues){ BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/convertiblebonds.cpp b/test-suite/convertiblebonds.cpp index d85d4552154..d6c24d43ab9 100644 --- a/test-suite/convertiblebonds.cpp +++ b/test-suite/convertiblebonds.cpp @@ -45,7 +45,11 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -namespace convertible_bonds_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(ConvertibleBondTests) + +namespace { struct CommonVars { // global data @@ -102,10 +106,6 @@ namespace convertible_bonds_test { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(ConvertibleBondTest) - BOOST_AUTO_TEST_CASE(testBond) { /* when deeply out-of-the-money, the value of the convertible bond @@ -114,8 +114,6 @@ BOOST_AUTO_TEST_CASE(testBond) { BOOST_TEST_MESSAGE( "Testing out-of-the-money convertible bonds against vanilla bonds..."); - using namespace convertible_bonds_test; - CommonVars vars; vars.conversionRatio = 1.0e-16; @@ -303,8 +301,6 @@ BOOST_AUTO_TEST_CASE(testOption) { BOOST_TEST_MESSAGE( "Testing zero-coupon convertible bonds against vanilla option..."); - using namespace convertible_bonds_test; - CommonVars vars; ext::shared_ptr euExercise = @@ -449,4 +445,4 @@ BOOST_AUTO_TEST_CASE(testRegression) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/covariance.cpp b/test-suite/covariance.cpp index bf1f9428ad3..049ca5feaba 100644 --- a/test-suite/covariance.cpp +++ b/test-suite/covariance.cpp @@ -27,7 +27,11 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -namespace covariance_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(CovarianceTests) + +namespace { Real norm(const Matrix& m) { Real sum = 0.0; @@ -39,16 +43,10 @@ namespace covariance_test { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(CovarianceTest) - BOOST_AUTO_TEST_CASE(testRankReduction) { BOOST_TEST_MESSAGE("Testing matrix rank reduction salvaging algorithms..."); - using namespace covariance_test; - Real expected, calculated; Size n = 3; @@ -106,8 +104,6 @@ BOOST_AUTO_TEST_CASE(testSalvagingMatrix) { BOOST_TEST_MESSAGE("Testing positive semi-definiteness salvaging " "algorithms..."); - using namespace covariance_test; - Real expected, calculated; Size n = 3; @@ -271,4 +267,4 @@ BOOST_AUTO_TEST_CASE(testCovariance) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/creditdefaultswap.cpp b/test-suite/creditdefaultswap.cpp index 86c9b167400..6a18183199f 100644 --- a/test-suite/creditdefaultswap.cpp +++ b/test-suite/creditdefaultswap.cpp @@ -49,9 +49,9 @@ using namespace QuantLib; using namespace boost::unit_test_framework; using std::map; -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) -BOOST_AUTO_TEST_SUITE(CreditDefaultSwapTest) +BOOST_AUTO_TEST_SUITE(CreditDefaultSwapTests) BOOST_AUTO_TEST_CASE(testCachedValue) { @@ -957,4 +957,4 @@ BOOST_AUTO_TEST_CASE(testIsdaCalculatorReconcileSingleWithIssueDateInThePast) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/creditriskplus.cpp b/test-suite/creditriskplus.cpp index 90340bb0afa..dacfa803ab6 100644 --- a/test-suite/creditriskplus.cpp +++ b/test-suite/creditriskplus.cpp @@ -25,9 +25,9 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) -BOOST_AUTO_TEST_SUITE(CreditRiskPlusTest) +BOOST_AUTO_TEST_SUITE(CreditRiskPlusTests) BOOST_AUTO_TEST_CASE(testReferenceValues) { diff --git a/test-suite/crosscurrencyratehelpers.cpp b/test-suite/crosscurrencyratehelpers.cpp index f5f89d24119..ba1ba228bf5 100644 --- a/test-suite/crosscurrencyratehelpers.cpp +++ b/test-suite/crosscurrencyratehelpers.cpp @@ -33,7 +33,11 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -namespace crosscurrencyratehelpers_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(CrossCurrencyRateHelpersTests) + +namespace { struct XccyTestDatum { Integer n; @@ -219,8 +223,6 @@ namespace crosscurrencyratehelpers_test { void testConstantNotionalCrossCurrencySwapsNPV(bool isFxBaseCurrencyCollateralCurrency, bool isBasisOnFxBaseCurrencyLeg) { - using namespace crosscurrencyratehelpers_test; - CommonVars vars; Handle collateralHandle = @@ -275,8 +277,6 @@ void testResettingCrossCurrencySwaps(bool isFxBaseCurrencyCollateralCurrency, bool isBasisOnFxBaseCurrencyLeg, bool isFxBaseCurrencyLegResettable) { - using namespace crosscurrencyratehelpers_test; - CommonVars vars; Handle collateralHandle = @@ -323,10 +323,6 @@ void testResettingCrossCurrencySwaps(bool isFxBaseCurrencyCollateralCurrency, } } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(CrossCurrencyRateHelpersTest) - BOOST_AUTO_TEST_CASE(testConstNotionalBasisSwapsWithCollateralInQuoteAndBasisInBaseCcy) { BOOST_TEST_MESSAGE("Testing constant notional basis swaps with collateral in quote ccy and " "basis in base ccy..."); @@ -420,8 +416,6 @@ BOOST_AUTO_TEST_CASE(testExceptionWhenInstrumentTenorShorterThanIndexFrequency) BOOST_TEST_MESSAGE( "Testing exception when instrument tenor is shorter than index frequency..."); - using namespace crosscurrencyratehelpers_test; - CommonVars vars; std::vector data{{1, Months, 10.0}}; @@ -435,4 +429,4 @@ BOOST_AUTO_TEST_CASE(testExceptionWhenInstrumentTenorShorterThanIndexFrequency) BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/currency.cpp b/test-suite/currency.cpp index 0ce9543115d..29ad7be5466 100644 --- a/test-suite/currency.cpp +++ b/test-suite/currency.cpp @@ -23,9 +23,9 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) -BOOST_AUTO_TEST_SUITE(CurrencyTest) +BOOST_AUTO_TEST_SUITE(CurrencyTests) BOOST_AUTO_TEST_CASE(testBespokeConstructor) { BOOST_TEST_MESSAGE("Testing bespoke currency constructor..."); @@ -57,4 +57,4 @@ BOOST_AUTO_TEST_CASE(testBespokeConstructor) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/curvestates.cpp b/test-suite/curvestates.cpp index f76702a4af5..7b7a4c6f403 100644 --- a/test-suite/curvestates.cpp +++ b/test-suite/curvestates.cpp @@ -37,7 +37,11 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -namespace curve_states_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(CurveStatesTests) + +namespace { struct CommonVars { // global data @@ -112,36 +116,10 @@ namespace curve_states_test { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(CurveStatesTest) - -// Comment/uncomment the desired test case. - -//BOOST_AUTO_TEST_CASE(testLMMCurveState) { -// -// BOOST_TEST_MESSAGE("Testing Libor-market-model curve state..."); -// -// using namespace curve_states_test; -// -// CommonVars vars; -//} - -//BOOST_AUTO_TEST_CASE(testCoterminalSwapCurveState) { -// -// BOOST_TEST_MESSAGE("Testing coterminal-swap-market-model curve state..."); -// -// using namespace curve_states_test; -// -// CommonVars vars; -//} - BOOST_AUTO_TEST_CASE(testCMSwapCurveState) { BOOST_TEST_MESSAGE("Testing constant-maturity-swap-market-model curve state..."); - using namespace curve_states_test; - CommonVars vars; Size nbRates = vars.todaysForwards.size(); @@ -201,4 +179,4 @@ BOOST_AUTO_TEST_CASE(testCMSwapCurveState) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/dates.cpp b/test-suite/dates.cpp index 2f0eea0b043..a3b1ee3eae1 100644 --- a/test-suite/dates.cpp +++ b/test-suite/dates.cpp @@ -38,9 +38,9 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) -BOOST_AUTO_TEST_SUITE(DateTest) +BOOST_AUTO_TEST_SUITE(DateTests) BOOST_AUTO_TEST_CASE(ecbDates) { BOOST_TEST_MESSAGE("Testing ECB dates..."); @@ -474,4 +474,4 @@ BOOST_AUTO_TEST_CASE(canHash) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/daycounters.cpp b/test-suite/daycounters.cpp index 9da957a29db..dfc39d65fd9 100644 --- a/test-suite/daycounters.cpp +++ b/test-suite/daycounters.cpp @@ -48,7 +48,11 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -namespace day_counters_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(DayCounterTests) + +namespace { struct SingleCase { SingleCase(ActualActual::Convention convention, @@ -111,16 +115,10 @@ namespace day_counters_test { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(DayCounterTest) - BOOST_AUTO_TEST_CASE(testActualActual) { BOOST_TEST_MESSAGE("Testing actual/actual day counters..."); - using namespace day_counters_test; - SingleCase testCases[] = { // first example SingleCase(ActualActual::ISDA, @@ -345,8 +343,6 @@ BOOST_AUTO_TEST_CASE(testActualActualWithSemiannualSchedule) { BOOST_TEST_MESSAGE("Testing actual/actual with schedule " "for undefined semiannual reference periods..."); - using namespace day_counters_test; - Calendar calendar = UnitedStates(UnitedStates::GovernmentBond); Date fromDate = Date(10, January, 2017); Date firstCoupon = Date(31, August, 2017); @@ -462,8 +458,6 @@ BOOST_AUTO_TEST_CASE(testActualActualWithAnnualSchedule){ BOOST_TEST_MESSAGE("Testing actual/actual with schedule " "for undefined annual reference periods..."); - using namespace day_counters_test; - // Now do an annual schedule Calendar calendar = UnitedStates(UnitedStates::GovernmentBond); Schedule schedule = MakeSchedule() @@ -503,8 +497,6 @@ BOOST_AUTO_TEST_CASE(testActualActualWithSchedule) { BOOST_TEST_MESSAGE("Testing actual/actual day counter with schedule..."); - using namespace day_counters_test; - // long first coupon Date issueDateExpected = Date(17, January, 2017); Date firstCouponDateExpected = Date(31, August, 2017); @@ -803,7 +795,7 @@ BOOST_AUTO_TEST_CASE(testThirty360_BondBasis) { DayCounter dayCounter = Thirty360(Thirty360::BondBasis); - day_counters_test::Thirty360Case data[] = { + Thirty360Case data[] = { // Example 1: End dates do not involve the last day of February {Date(20, August, 2006), Date(20, February, 2007), 180}, {Date(20, February, 2007), Date(20, August, 2007), 180}, @@ -857,7 +849,7 @@ BOOST_AUTO_TEST_CASE(testThirty360_EurobondBasis) { DayCounter dayCounter = Thirty360(Thirty360::EurobondBasis); - day_counters_test::Thirty360Case data[] = { + Thirty360Case data[] = { // Example 1: End dates do not involve the last day of February {Date(20, August, 2006), Date(20, February, 2007), 180}, {Date(20, February, 2007), Date(20, August, 2007), 180}, @@ -915,7 +907,7 @@ BOOST_AUTO_TEST_CASE(testThirty360_ISDA) { // See https://www.isda.org/2008/12/22/30-360-day-count-conventions/ - day_counters_test::Thirty360Case data1[] = { + Thirty360Case data1[] = { // Example 1: End dates do not involve the last day of February {Date(20, August, 2006), Date(20, February, 2007), 180}, {Date(20, February, 2007), Date(20, August, 2007), 180}, @@ -938,7 +930,7 @@ BOOST_AUTO_TEST_CASE(testThirty360_ISDA) { } } - day_counters_test::Thirty360Case data2[] = { + Thirty360Case data2[] = { // Example 2: End dates include some end-February dates {Date(28, February, 2006), Date(31, August, 2006), 180}, {Date(31, August, 2006), Date(28, February, 2007), 180}, @@ -967,7 +959,7 @@ BOOST_AUTO_TEST_CASE(testThirty360_ISDA) { } } - day_counters_test::Thirty360Case data3[] = { + Thirty360Case data3[] = { // Example 3: Miscellaneous calculations {Date(31, January, 2006), Date(28, February, 2006), 30}, {Date(30, January, 2006), Date(28, February, 2006), 30}, diff --git a/test-suite/defaultprobabilitycurves.cpp b/test-suite/defaultprobabilitycurves.cpp index f1c7a20bd0a..99d9e20daf0 100644 --- a/test-suite/defaultprobabilitycurves.cpp +++ b/test-suite/defaultprobabilitycurves.cpp @@ -48,9 +48,9 @@ using std::map; using std::vector; using std::string; -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) -BOOST_AUTO_TEST_SUITE(DefaultProbabilityCurveTest) +BOOST_AUTO_TEST_SUITE(DefaultProbabilityCurveTests) BOOST_AUTO_TEST_CASE(testDefaultProbability) { @@ -532,4 +532,4 @@ BOOST_AUTO_TEST_CASE(testIterativeBootstrapRetries) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/digitalcoupon.cpp b/test-suite/digitalcoupon.cpp index 5675fda4487..007b04f0f99 100644 --- a/test-suite/digitalcoupon.cpp +++ b/test-suite/digitalcoupon.cpp @@ -36,7 +36,11 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -namespace digital_coupon_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(DigitalCouponTests) + +namespace { struct CommonVars { // global data @@ -66,16 +70,10 @@ namespace digital_coupon_test { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) // might fail with QL_USE_INDEXED_COUPON - -BOOST_AUTO_TEST_SUITE(DigitalCouponTest) - BOOST_AUTO_TEST_CASE(testAssetOrNothing) { BOOST_TEST_MESSAGE("Testing European asset-or-nothing digital coupon..."); - using namespace digital_coupon_test; - /* Call Payoff = (aL+b)Heaviside(aL+b-X) = a Max[L-X'] + (b+aX')Heaviside(L-X') Value Call = aF N(d1') + bN(d2') Put Payoff = (aL+b)Heaviside(X-aL-b) = -a Max[X-L'] + (b+aX')Heaviside(X'-L) @@ -262,8 +260,6 @@ BOOST_AUTO_TEST_CASE(testAssetOrNothingDeepInTheMoney) { BOOST_TEST_MESSAGE("Testing European deep in-the-money asset-or-nothing " "digital coupon..."); - using namespace digital_coupon_test; - CommonVars vars; Real gearing = 1.0; @@ -371,8 +367,6 @@ BOOST_AUTO_TEST_CASE(testAssetOrNothingDeepOutTheMoney) { BOOST_TEST_MESSAGE("Testing European deep out-the-money asset-or-nothing " "digital coupon..."); - using namespace digital_coupon_test; - CommonVars vars; Real gearing = 1.0; @@ -485,8 +479,6 @@ BOOST_AUTO_TEST_CASE(testCashOrNothing) { d2' = ln(F/X')/stdDev - 0.5*stdDev; */ - using namespace digital_coupon_test; - CommonVars vars; Volatility vols[] = { 0.05, 0.15, 0.30 }; @@ -631,8 +623,6 @@ BOOST_AUTO_TEST_CASE(testCashOrNothingDeepInTheMoney) { BOOST_TEST_MESSAGE("Testing European deep in-the-money cash-or-nothing " "digital coupon..."); - using namespace digital_coupon_test; - CommonVars vars; Real gearing = 1.0; @@ -738,8 +728,6 @@ BOOST_AUTO_TEST_CASE(testCashOrNothingDeepOutTheMoney) { BOOST_TEST_MESSAGE("Testing European deep out-the-money cash-or-nothing " "digital coupon..."); - using namespace digital_coupon_test; - CommonVars vars; Real gearing = 1.0; @@ -845,8 +833,6 @@ BOOST_AUTO_TEST_CASE(testCallPutParity) { BOOST_TEST_MESSAGE("Testing call/put parity for European digital coupon..."); - using namespace digital_coupon_test; - CommonVars vars; Volatility vols[] = { 0.05, 0.15, 0.30 }; @@ -940,8 +926,6 @@ BOOST_AUTO_TEST_CASE(testReplicationType) { BOOST_TEST_MESSAGE("Testing replication type for European digital coupon..."); - using namespace digital_coupon_test; - CommonVars vars; Volatility vols[] = { 0.05, 0.15, 0.30 }; @@ -1115,4 +1099,4 @@ BOOST_AUTO_TEST_CASE(testReplicationType) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/digitaloption.cpp b/test-suite/digitaloption.cpp index 5016e9f0a22..5053d57000a 100644 --- a/test-suite/digitaloption.cpp +++ b/test-suite/digitaloption.cpp @@ -36,6 +36,10 @@ using namespace QuantLib; using namespace boost::unit_test_framework; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(DigitalOptionTests) + #undef REPORT_FAILURE #define REPORT_FAILURE(greekName, payoff, exercise, s, q, r, today, \ v, expected, calculated, error, tolerance, knockin) \ @@ -72,10 +76,6 @@ namespace { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(DigitalOptionTest) - BOOST_AUTO_TEST_CASE(testCashOrNothingEuropeanValues) { BOOST_TEST_MESSAGE("Testing European cash-or-nothing digital option..."); @@ -732,4 +732,4 @@ BOOST_AUTO_TEST_CASE(testMCCashAtHit) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/distributions.cpp b/test-suite/distributions.cpp index 4cef523aec3..4819f232547 100644 --- a/test-suite/distributions.cpp +++ b/test-suite/distributions.cpp @@ -36,7 +36,11 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -namespace distributions_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(DistributionTests) + +namespace { Real average = 1.0, sigma = 2.0; @@ -219,16 +223,10 @@ namespace distributions_test { }; } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(DistributionTest) - BOOST_AUTO_TEST_CASE(testNormal) { BOOST_TEST_MESSAGE("Testing normal distributions..."); - using namespace distributions_test; - InverseCumulativeNormal invCumStandardNormal; Real check = invCumStandardNormal(0.5); if (check != 0.0e0) { @@ -317,8 +315,6 @@ BOOST_AUTO_TEST_CASE(testBivariate) { BOOST_TEST_MESSAGE("Testing bivariate cumulative normal distribution..."); - using namespace distributions_test; - checkBivariateAtZero( "Drezner 1978", 1.0e-6); checkBivariate("Drezner 1978"); @@ -446,8 +442,6 @@ BOOST_AUTO_TEST_CASE(testBivariateCumulativeStudent) { BOOST_TEST_MESSAGE( "Testing bivariate cumulative Student t distribution..."); - using namespace distributions_test; - Real xs[14] = { 0.00, 0.50, 1.00, 1.50, 2.00, 2.50, 3.00, 4.00, 5.00, 6.00, 7.00, 8.00, 9.00, 10.00 }; Natural ns[20] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 60, 90, 120, 150, 300, 600 }; // Part of table 1 from the reference paper @@ -643,8 +637,6 @@ BOOST_AUTO_TEST_CASE(testInvCDFviaStochasticCollocation) { BOOST_TEST_MESSAGE( "Testing inverse CDF based on stochastic collocation..."); - using namespace distributions_test; - const Real k = 3.0; const Real lambda = 1.0; @@ -741,4 +733,4 @@ BOOST_AUTO_TEST_CASE(testSankaranApproximation) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/dividendoption.cpp b/test-suite/dividendoption.cpp index 33e4366eaf0..80b544205c1 100644 --- a/test-suite/dividendoption.cpp +++ b/test-suite/dividendoption.cpp @@ -37,6 +37,10 @@ using namespace QuantLib; using namespace boost::unit_test_framework; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(DividendOptionTests) + #undef REPORT_FAILURE #define REPORT_FAILURE(greekName, payoff, exercise, s, q, r, today, \ v, expected, calculated, error, tolerance) \ @@ -57,10 +61,6 @@ using namespace boost::unit_test_framework; // tests -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(DividendOptionTest) - BOOST_AUTO_TEST_CASE(testEuropeanValues) { BOOST_TEST_MESSAGE( @@ -1321,4 +1321,4 @@ BOOST_AUTO_TEST_CASE(testEscrowedDividendModel) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/doublebarrieroption.cpp b/test-suite/doublebarrieroption.cpp index 71ca0e540fb..63ec4ac8148 100644 --- a/test-suite/doublebarrieroption.cpp +++ b/test-suite/doublebarrieroption.cpp @@ -47,6 +47,10 @@ using namespace QuantLib; using namespace boost::unit_test_framework; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(DoubleBarrierOptionTests) + #undef REPORT_FAILURE #define REPORT_FAILURE(greekName, barrierType, barrierlo, barrierhi, \ payoff, exercise, s, q, r, today, v, expected, \ @@ -105,7 +109,7 @@ using namespace boost::unit_test_framework; << "Analytical: " << analytical << "\n" \ << "Monte Carlo: " << monteCarlo << "\n"); -namespace double_barrier_option_test { +namespace { struct NewBarrierOptionData { DoubleBarrier::Type barrierType; @@ -144,16 +148,10 @@ namespace double_barrier_option_test { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(DoubleBarrierOptionTest) - BOOST_AUTO_TEST_CASE(testEuropeanHaugValues) { BOOST_TEST_MESSAGE("Testing double barrier european options against Haug's values..."); - using namespace double_barrier_option_test; - Exercise::Type european = Exercise::European; NewBarrierOptionData values[] = { /* The data below are from @@ -391,8 +389,6 @@ BOOST_AUTO_TEST_CASE(testVannaVolgaDoubleBarrierValues) { BOOST_TEST_MESSAGE( "Testing double-barrier FX options against Vanna/Volga values..."); - using namespace double_barrier_option_test; - DoubleBarrierFxOptionData values[] = { // BarrierType, barr.1, barr.2, rebate, type, strike, s, q, r, t, vol25Put, volAtm,vol25Call, vol, result, tol @@ -532,8 +528,6 @@ BOOST_AUTO_TEST_CASE(testVannaVolgaDoubleBarrierValues) { BOOST_AUTO_TEST_CASE(testMonteCarloDoubleBarrierWithAnalytical, *precondition(if_speed(Fast))) { BOOST_TEST_MESSAGE("Testing MC double-barrier options against analytical values..."); - using namespace double_barrier_option_test; - Real tolerance = 0.01; //percentage difference between analytical and monte carlo values to be tolerated // set up dates diff --git a/test-suite/doublebinaryoption.cpp b/test-suite/doublebinaryoption.cpp index 03b9a5a9771..a7fefe634d0 100644 --- a/test-suite/doublebinaryoption.cpp +++ b/test-suite/doublebinaryoption.cpp @@ -33,6 +33,10 @@ Copyright (C) 2015 Thema Consulting SA using namespace QuantLib; using namespace boost::unit_test_framework; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(DoubleBinaryOptionTests) + #undef REPORT_FAILURE #define REPORT_FAILURE(greekName, payoff, exercise, barrierType, barrier_lo, \ barrier_hi, s, q, r, today, v, expected, calculated, \ @@ -71,10 +75,6 @@ namespace { }; } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(DoubleBinaryOptionTest) - BOOST_AUTO_TEST_CASE(testHaugValues) { BOOST_TEST_MESSAGE("Testing cash-or-nothing double barrier options against Haug's values..."); @@ -328,4 +328,4 @@ BOOST_AUTO_TEST_CASE(testPdeDoubleBarrierWithAnalytical) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/equitycashflow.cpp b/test-suite/equitycashflow.cpp index bcf085734dc..38b353ee6b0 100644 --- a/test-suite/equitycashflow.cpp +++ b/test-suite/equitycashflow.cpp @@ -26,7 +26,11 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -namespace equitycashflow_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(EquityCashFlowTests) + +namespace { struct CommonVars { @@ -165,15 +169,9 @@ namespace equitycashflow_test { } } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(EquityCashFlowTest) - BOOST_AUTO_TEST_CASE(testSimpleEquityCashFlow) { BOOST_TEST_MESSAGE("Testing simple equity cash flow..."); - using namespace equitycashflow_test; - const Real tolerance = 1.0e-6; CommonVars vars; @@ -198,8 +196,6 @@ BOOST_AUTO_TEST_CASE(testSimpleEquityCashFlow) { BOOST_AUTO_TEST_CASE(testQuantoCorrection) { BOOST_TEST_MESSAGE("Testing quanto correction..."); - using namespace equitycashflow_test; - checkQuantoCorrection(true); checkQuantoCorrection(false); @@ -211,8 +207,6 @@ BOOST_AUTO_TEST_CASE(testQuantoCorrection) { BOOST_AUTO_TEST_CASE(testErrorWhenBaseDateAfterFixingDate) { BOOST_TEST_MESSAGE("Testing error when base date after fixing date..."); - using namespace equitycashflow_test; - CommonVars vars; Date end(5, January, 2023); @@ -226,8 +220,6 @@ BOOST_AUTO_TEST_CASE(testErrorWhenBaseDateAfterFixingDate) { BOOST_AUTO_TEST_CASE(testErrorWhenQuantoCurveHandleIsEmpty) { BOOST_TEST_MESSAGE("Testing error when quanto currency curve handle is empty..."); - using namespace equitycashflow_test; - CommonVars vars; auto cf = vars.createEquityQuantoCashFlow(); @@ -240,8 +232,6 @@ BOOST_AUTO_TEST_CASE(testErrorWhenQuantoCurveHandleIsEmpty) { BOOST_AUTO_TEST_CASE(testErrorWhenEquityVolHandleIsEmpty) { BOOST_TEST_MESSAGE("Testing error when equity vol handle is empty..."); - using namespace equitycashflow_test; - CommonVars vars; auto cf = vars.createEquityQuantoCashFlow(); @@ -254,8 +244,6 @@ BOOST_AUTO_TEST_CASE(testErrorWhenEquityVolHandleIsEmpty) { BOOST_AUTO_TEST_CASE(testErrorWhenFXVolHandleIsEmpty) { BOOST_TEST_MESSAGE("Testing error when FX vol handle is empty..."); - using namespace equitycashflow_test; - CommonVars vars; auto cf = vars.createEquityQuantoCashFlow(); @@ -268,8 +256,6 @@ BOOST_AUTO_TEST_CASE(testErrorWhenFXVolHandleIsEmpty) { BOOST_AUTO_TEST_CASE(testErrorWhenCorrelationHandleIsEmpty) { BOOST_TEST_MESSAGE("Testing error when correlation handle is empty..."); - using namespace equitycashflow_test; - CommonVars vars; auto cf = vars.createEquityQuantoCashFlow(); @@ -282,8 +268,6 @@ BOOST_AUTO_TEST_CASE(testErrorWhenCorrelationHandleIsEmpty) { BOOST_AUTO_TEST_CASE(testErrorWhenInconsistentMarketDataReferenceDate) { BOOST_TEST_MESSAGE("Testing error when market data reference dates are inconsistent..."); - using namespace equitycashflow_test; - CommonVars vars; auto cf = vars.createEquityQuantoCashFlow(); @@ -297,4 +281,4 @@ BOOST_AUTO_TEST_CASE(testErrorWhenInconsistentMarketDataReferenceDate) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/equityindex.cpp b/test-suite/equityindex.cpp index d80ed895f3e..c9103d88954 100644 --- a/test-suite/equityindex.cpp +++ b/test-suite/equityindex.cpp @@ -26,7 +26,11 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -namespace equityindex_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(EquityIndexTests) + +namespace { struct CommonVars { @@ -65,15 +69,9 @@ namespace equityindex_test { }; } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(EquityIndexTest) - BOOST_AUTO_TEST_CASE(testTodaysFixing) { BOOST_TEST_MESSAGE("Testing today's fixing..."); - using namespace equityindex_test; - CommonVars vars; const Real tolerance = 1.0e-8; @@ -97,8 +95,6 @@ BOOST_AUTO_TEST_CASE(testTodaysFixing) { BOOST_AUTO_TEST_CASE(testTodaysFixingWithSpotAsProxy) { BOOST_TEST_MESSAGE("Testing today's fixing with spot as proxy..."); - using namespace equityindex_test; - CommonVars vars(false); const Real tolerance = 1.0e-8; @@ -114,8 +110,6 @@ BOOST_AUTO_TEST_CASE(testTodaysFixingWithSpotAsProxy) { BOOST_AUTO_TEST_CASE(testFixingForecast) { BOOST_TEST_MESSAGE("Testing fixing forecast..."); - using namespace equityindex_test; - CommonVars vars; const Real tolerance = 1.0e-8; @@ -135,8 +129,6 @@ BOOST_AUTO_TEST_CASE(testFixingForecast) { BOOST_AUTO_TEST_CASE(testFixingForecastWithoutDividend) { BOOST_TEST_MESSAGE("Testing fixing forecast without dividend..."); - using namespace equityindex_test; - CommonVars vars; const Real tolerance = 1.0e-8; @@ -158,8 +150,6 @@ BOOST_AUTO_TEST_CASE(testFixingForecastWithoutDividend) { BOOST_AUTO_TEST_CASE(testFixingForecastWithoutSpot) { BOOST_TEST_MESSAGE("Testing fixing forecast without spot handle..."); - using namespace equityindex_test; - CommonVars vars; const Real tolerance = 1.0e-8; @@ -182,8 +172,6 @@ BOOST_AUTO_TEST_CASE(testFixingForecastWithoutSpot) { BOOST_AUTO_TEST_CASE(testFixingForecastWithoutSpotAndHistoricalFixing) { BOOST_TEST_MESSAGE("Testing fixing forecast without spot handle and historical fixing..."); - using namespace equityindex_test; - CommonVars vars(false); Date forecastedDate(20, May, 2030); @@ -200,8 +188,6 @@ BOOST_AUTO_TEST_CASE(testFixingForecastWithoutSpotAndHistoricalFixing) { BOOST_AUTO_TEST_CASE(testSpotChange) { BOOST_TEST_MESSAGE("Testing spot change..."); - using namespace equityindex_test; - CommonVars vars; const Real tolerance = 1.0e-8; @@ -224,8 +210,6 @@ BOOST_AUTO_TEST_CASE(testSpotChange) { BOOST_AUTO_TEST_CASE(testErrorWhenInvalidFixingDate) { BOOST_TEST_MESSAGE("Testing error when invalid fixing date is used..."); - using namespace equityindex_test; - CommonVars vars; BOOST_CHECK_EXCEPTION( @@ -236,8 +220,6 @@ BOOST_AUTO_TEST_CASE(testErrorWhenInvalidFixingDate) { BOOST_AUTO_TEST_CASE(testErrorWhenFixingMissing) { BOOST_TEST_MESSAGE("Testing error when required fixing is missing..."); - using namespace equityindex_test; - CommonVars vars; BOOST_CHECK_EXCEPTION( @@ -248,8 +230,6 @@ BOOST_AUTO_TEST_CASE(testErrorWhenFixingMissing) { BOOST_AUTO_TEST_CASE(testErrorWhenInterestHandleMissing) { BOOST_TEST_MESSAGE("Testing error when interest handle is missing..."); - using namespace equityindex_test; - CommonVars vars; Date forecastedDate(20, May, 2030); @@ -266,8 +246,6 @@ BOOST_AUTO_TEST_CASE(testErrorWhenInterestHandleMissing) { BOOST_AUTO_TEST_CASE(testFixingObservability) { BOOST_TEST_MESSAGE("Testing observability of index fixings..."); - using namespace equityindex_test; - CommonVars vars; ext::shared_ptr i1 = @@ -288,8 +266,6 @@ BOOST_AUTO_TEST_CASE(testFixingObservability) { BOOST_AUTO_TEST_CASE(testNoErrorIfTodayIsNotBusinessDay) { BOOST_TEST_MESSAGE("Testing that no error is thrown if today is not a business day..."); - using namespace equityindex_test; - CommonVars vars; Date today(28, January, 2023); @@ -305,4 +281,4 @@ BOOST_AUTO_TEST_CASE(testNoErrorIfTodayIsNotBusinessDay) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/equitytotalreturnswap.cpp b/test-suite/equitytotalreturnswap.cpp index e96136e9bc3..c28115dd7d5 100644 --- a/test-suite/equitytotalreturnswap.cpp +++ b/test-suite/equitytotalreturnswap.cpp @@ -31,7 +31,11 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -namespace equitytotalreturnswap_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(EquityTotalReturnSwapTests) + +namespace { struct CommonVars { @@ -210,15 +214,9 @@ namespace equitytotalreturnswap_test { } } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(EquityTotalReturnSwapTest) - BOOST_AUTO_TEST_CASE(testFairMargin) { BOOST_TEST_MESSAGE("Testing fair margin..."); - using namespace equitytotalreturnswap_test; - // Check TRS vs Libor-type index checkFairMarginCalculation(Swap::Receiver, Date(5, January, 2023), Date(5, April, 2023), false); checkFairMarginCalculation(Swap::Payer, Date(5, January, 2023), Date(5, April, 2023), false, @@ -239,8 +237,6 @@ BOOST_AUTO_TEST_CASE(testFairMargin) { BOOST_AUTO_TEST_CASE(testErrorWhenNegativeNominal) { BOOST_TEST_MESSAGE("Testing error when negative nominal..."); - using namespace equitytotalreturnswap_test; - CommonVars vars; BOOST_CHECK_EXCEPTION( @@ -253,8 +249,6 @@ BOOST_AUTO_TEST_CASE(testErrorWhenNegativeNominal) { BOOST_AUTO_TEST_CASE(testErrorWhenNoPaymentCalendar) { BOOST_TEST_MESSAGE("Testing error when payment calendar is missing..."); - using namespace equitytotalreturnswap_test; - CommonVars vars; auto sch = Schedule(Date(5, January, 2023), Date(5, April, 2023), 3 * Months, Calendar(), @@ -268,8 +262,6 @@ BOOST_AUTO_TEST_CASE(testErrorWhenNoPaymentCalendar) { BOOST_AUTO_TEST_CASE(testEquityLegNPV) { BOOST_TEST_MESSAGE("Testing equity leg NPV replication..."); - using namespace equitytotalreturnswap_test; - CommonVars vars; const Real tolerance = 1.0e-8; @@ -294,8 +286,6 @@ BOOST_AUTO_TEST_CASE(testEquityLegNPV) { BOOST_AUTO_TEST_CASE(testTRSNPV) { BOOST_TEST_MESSAGE("Testing TRS NPV..."); - using namespace equitytotalreturnswap_test; - CommonVars vars; // Check TRS vs Libor-type index @@ -314,4 +304,4 @@ BOOST_AUTO_TEST_CASE(testTRSNPV) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/europeanoption.cpp b/test-suite/europeanoption.cpp index c3a9f565b51..e7ed46a41e9 100644 --- a/test-suite/europeanoption.cpp +++ b/test-suite/europeanoption.cpp @@ -45,6 +45,10 @@ using namespace QuantLib; using namespace boost::unit_test_framework; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(EuropeanOptionTests) + #undef REPORT_FAILURE #define REPORT_FAILURE(greekName, payoff, exercise, s, q, r, today, \ v, expected, calculated, error, tolerance) \ @@ -63,7 +67,7 @@ using namespace boost::unit_test_framework; << " error: " << error << "\n" \ << " tolerance: " << tolerance); -namespace european_option_test { +namespace { // utilities @@ -187,20 +191,12 @@ namespace european_option_test { return option; } -} - -// different engines - -namespace { - - void testEngineConsistency(european_option_test::EngineType engine, + void testEngineConsistency(EngineType engine, Size binomialSteps, Size samples, std::map tolerance, bool testGreeks = false) { - using namespace european_option_test; - std::map calculated, expected; // test options @@ -284,16 +280,10 @@ namespace { } } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(EuropeanOptionTest) - BOOST_AUTO_TEST_CASE(testValues) { BOOST_TEST_MESSAGE("Testing European option values..."); - using namespace european_option_test; - /* The data below are from "Option pricing formulas", E.G. Haug, McGraw-Hill 1998 */ @@ -406,8 +396,6 @@ BOOST_AUTO_TEST_CASE(testGreekValues) { BOOST_TEST_MESSAGE("Testing European option greek values..."); - using namespace european_option_test; - /* The data below are from "Option pricing formulas", E.G. Haug, McGraw-Hill 1998 pag 11-16 @@ -695,8 +683,6 @@ BOOST_AUTO_TEST_CASE(testGreeks) { BOOST_TEST_MESSAGE("Testing analytic European option greeks..."); - using namespace european_option_test; - std::map calculated, expected, tolerance; tolerance["delta"] = 1.0e-5; tolerance["gamma"] = 1.0e-5; @@ -846,8 +832,6 @@ BOOST_AUTO_TEST_CASE(testImpliedVol) { BOOST_TEST_MESSAGE("Testing European option implied volatility..."); - using namespace european_option_test; - Size maxEvaluations = 100; Real tolerance = 1.0e-6; @@ -961,8 +945,6 @@ BOOST_AUTO_TEST_CASE(testImpliedVolWithDividends) { BOOST_TEST_MESSAGE("Testing European option implied volatility with dividends..."); - using namespace european_option_test; - Size maxEvaluations = 100; Real tolerance = 1.0e-6; @@ -1151,8 +1133,6 @@ BOOST_AUTO_TEST_CASE(testJRBinomialEngines) { BOOST_TEST_MESSAGE("Testing JR binomial European engines " "against analytic results..."); - using namespace european_option_test; - EngineType engine = JR; Size steps = 251; Size samples = Null(); @@ -1169,8 +1149,6 @@ BOOST_AUTO_TEST_CASE(testCRRBinomialEngines) { BOOST_TEST_MESSAGE("Testing CRR binomial European engines " "against analytic results..."); - using namespace european_option_test; - EngineType engine = CRR; Size steps = 501; Size samples = Null(); @@ -1187,8 +1165,6 @@ BOOST_AUTO_TEST_CASE(testEQPBinomialEngines) { BOOST_TEST_MESSAGE("Testing EQP binomial European engines " "against analytic results..."); - using namespace european_option_test; - EngineType engine = EQP; Size steps = 501; Size samples = Null(); @@ -1205,8 +1181,6 @@ BOOST_AUTO_TEST_CASE(testTGEOBinomialEngines) { BOOST_TEST_MESSAGE("Testing TGEO binomial European engines " "against analytic results..."); - using namespace european_option_test; - EngineType engine = TGEO; Size steps = 251; Size samples = Null(); @@ -1223,8 +1197,6 @@ BOOST_AUTO_TEST_CASE(testTIANBinomialEngines) { BOOST_TEST_MESSAGE("Testing TIAN binomial European engines " "against analytic results..."); - using namespace european_option_test; - EngineType engine = TIAN; Size steps = 251; Size samples = Null(); @@ -1241,8 +1213,6 @@ BOOST_AUTO_TEST_CASE(testLRBinomialEngines) { BOOST_TEST_MESSAGE("Testing LR binomial European engines " "against analytic results..."); - using namespace european_option_test; - EngineType engine = LR; Size steps = 251; Size samples = Null(); @@ -1259,8 +1229,6 @@ BOOST_AUTO_TEST_CASE(testJOSHIBinomialEngines) { BOOST_TEST_MESSAGE("Testing Joshi binomial European engines " "against analytic results..."); - using namespace european_option_test; - EngineType engine = JOSHI; Size steps = 251; Size samples = Null(); @@ -1277,8 +1245,6 @@ BOOST_AUTO_TEST_CASE(testFdEngines) { BOOST_TEST_MESSAGE("Testing finite-difference European engines " "against analytic results..."); - using namespace european_option_test; - EngineType engine = FiniteDifferences; Size timeSteps = 500; Size gridPoints = 500; @@ -1294,8 +1260,6 @@ BOOST_AUTO_TEST_CASE(testIntegralEngines) { BOOST_TEST_MESSAGE("Testing integral engines against analytic results..."); - using namespace european_option_test; - EngineType engine = Integral; Size timeSteps = 300; Size gridPoints = 300; @@ -1309,8 +1273,6 @@ BOOST_AUTO_TEST_CASE(testMcEngines) { BOOST_TEST_MESSAGE("Testing Monte Carlo European engines " "against analytic results..."); - using namespace european_option_test; - EngineType engine = PseudoMonteCarlo; Size steps = Null(); Size samples = 40000; @@ -1324,8 +1286,6 @@ BOOST_AUTO_TEST_CASE(testQmcEngines) { BOOST_TEST_MESSAGE("Testing Quasi Monte Carlo European engines " "against analytic results..."); - using namespace european_option_test; - EngineType engine = QuasiMonteCarlo; Size steps = Null(); Size samples = 4095; // 2^12-1 @@ -1337,8 +1297,6 @@ BOOST_AUTO_TEST_CASE(testQmcEngines) { BOOST_AUTO_TEST_CASE(testLocalVolatility) { BOOST_TEST_MESSAGE("Testing finite-differences with local volatility..."); - using namespace european_option_test; - const Date settlementDate(5, July, 2002); Settings::instance().evaluationDate() = settlementDate; @@ -1786,8 +1744,6 @@ BOOST_AUTO_TEST_CASE(testFFTEngines) { BOOST_TEST_MESSAGE("Testing FFT European engines " "against analytic results..."); - using namespace european_option_test; - EngineType engine = FFT; Size steps = Null(); Size samples = Null(); diff --git a/test-suite/everestoption.cpp b/test-suite/everestoption.cpp index 34ed30847da..5b4fdda57d1 100644 --- a/test-suite/everestoption.cpp +++ b/test-suite/everestoption.cpp @@ -28,9 +28,9 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) -BOOST_AUTO_TEST_SUITE(EverestOptionTest) +BOOST_AUTO_TEST_SUITE(EverestOptionTests) BOOST_AUTO_TEST_CASE(testCached) { diff --git a/test-suite/exchangerate.cpp b/test-suite/exchangerate.cpp index d9577338031..81967253e08 100644 --- a/test-suite/exchangerate.cpp +++ b/test-suite/exchangerate.cpp @@ -28,9 +28,9 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) -BOOST_AUTO_TEST_SUITE(ExchangeRateTest) +BOOST_AUTO_TEST_SUITE(ExchangeRateTests) BOOST_AUTO_TEST_CASE(testDirect) { @@ -380,4 +380,4 @@ BOOST_AUTO_TEST_CASE(testSmartLookup) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/extendedtrees.cpp b/test-suite/extendedtrees.cpp index 078bab89775..820932d4ca6 100644 --- a/test-suite/extendedtrees.cpp +++ b/test-suite/extendedtrees.cpp @@ -33,6 +33,10 @@ using namespace QuantLib; using namespace boost::unit_test_framework; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(ExtendedTreesTests) + #undef REPORT_FAILURE #define REPORT_FAILURE(greekName, payoff, exercise, s, q, r, today, \ v, expected, calculated, error, tolerance) \ @@ -51,7 +55,7 @@ using namespace boost::unit_test_framework; << " error: " << error << "\n" \ << " tolerance: " << tolerance); -namespace extended_trees_test { +namespace { // utilities @@ -137,16 +141,10 @@ namespace extended_trees_test { return option; } -} - -namespace { - - void testEngineConsistency(extended_trees_test::EngineType engine, + void testEngineConsistency(EngineType engine, Size binomialSteps, std::map tolerance) { - using namespace extended_trees_test; - std::map calculated, expected; // test options @@ -230,17 +228,11 @@ namespace { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(ExtendedTreesTest) - BOOST_AUTO_TEST_CASE(testJRBinomialEngines) { BOOST_TEST_MESSAGE("Testing time-dependent JR binomial European engines " "against analytic results..."); - using namespace extended_trees_test; - EngineType engine = JR; Size steps = 251; std::map relativeTol; @@ -256,8 +248,6 @@ BOOST_AUTO_TEST_CASE(testCRRBinomialEngines) { BOOST_TEST_MESSAGE("Testing time-dependent CRR binomial European engines " "against analytic results..."); - using namespace extended_trees_test; - EngineType engine = CRR; Size steps = 501; std::map relativeTol; @@ -273,8 +263,6 @@ BOOST_AUTO_TEST_CASE(testEQPBinomialEngines) { BOOST_TEST_MESSAGE("Testing time-dependent EQP binomial European engines " "against analytic results..."); - using namespace extended_trees_test; - EngineType engine = EQP; Size steps = 501; std::map relativeTol; @@ -290,8 +278,6 @@ BOOST_AUTO_TEST_CASE(testTGEOBinomialEngines) { BOOST_TEST_MESSAGE("Testing time-dependent TGEO binomial European engines " "against analytic results..."); - using namespace extended_trees_test; - EngineType engine = TGEO; Size steps = 251; std::map relativeTol; @@ -307,8 +293,6 @@ BOOST_AUTO_TEST_CASE(testTIANBinomialEngines) { BOOST_TEST_MESSAGE("Testing time-dependent TIAN binomial European engines " "against analytic results..."); - using namespace extended_trees_test; - EngineType engine = TIAN; Size steps = 251; std::map relativeTol; @@ -324,8 +308,6 @@ BOOST_AUTO_TEST_CASE(testLRBinomialEngines) { BOOST_TEST_MESSAGE("Testing time-dependent LR binomial European engines " "against analytic results..."); - using namespace extended_trees_test; - EngineType engine = LR; Size steps = 251; std::map relativeTol; @@ -341,8 +323,6 @@ BOOST_AUTO_TEST_CASE(testJOSHIBinomialEngines) { BOOST_TEST_MESSAGE("Testing time-dependent Joshi binomial European engines " "against analytic results..."); - using namespace extended_trees_test; - EngineType engine = JOSHI; Size steps = 251; std::map relativeTol; diff --git a/test-suite/extensibleoptions.cpp b/test-suite/extensibleoptions.cpp index d8dd1f73973..2bc53da9d7c 100644 --- a/test-suite/extensibleoptions.cpp +++ b/test-suite/extensibleoptions.cpp @@ -31,9 +31,9 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) -BOOST_AUTO_TEST_SUITE(ExtensibleOptionsTest) +BOOST_AUTO_TEST_SUITE(ExtensibleOptionsTests) BOOST_AUTO_TEST_CASE(testAnalyticHolderExtensibleOptionEngine) { BOOST_TEST_MESSAGE( diff --git a/test-suite/fastfouriertransform.cpp b/test-suite/fastfouriertransform.cpp index 0651e9e7060..298bf92bf5b 100644 --- a/test-suite/fastfouriertransform.cpp +++ b/test-suite/fastfouriertransform.cpp @@ -29,9 +29,9 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) -BOOST_AUTO_TEST_SUITE(FastFourierTransformTest) +BOOST_AUTO_TEST_SUITE(FastFourierTransformTests) BOOST_AUTO_TEST_CASE(testSimple) { BOOST_TEST_MESSAGE("Testing complex direct FFT..."); @@ -107,4 +107,4 @@ BOOST_AUTO_TEST_CASE(testInverse) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/fdcev.cpp b/test-suite/fdcev.cpp index 0030693c269..dbc944adb19 100644 --- a/test-suite/fdcev.cpp +++ b/test-suite/fdcev.cpp @@ -30,6 +30,9 @@ using namespace QuantLib; using boost::unit_test_framework::test_suite; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(FdCevTests) namespace { class ExpectationFct { @@ -45,10 +48,6 @@ namespace { }; } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(FdCevTest) - BOOST_AUTO_TEST_CASE(testLocalMartingale) { BOOST_TEST_MESSAGE( "Testing local martingale property of CEV process with PDF..."); @@ -207,4 +206,4 @@ BOOST_AUTO_TEST_CASE(testFdmCevOp) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/fdcir.cpp b/test-suite/fdcir.cpp index 189a0f095d5..e1624d4ab45 100644 --- a/test-suite/fdcir.cpp +++ b/test-suite/fdcir.cpp @@ -34,9 +34,9 @@ using namespace QuantLib; using boost::unit_test_framework::test_suite; -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) -BOOST_AUTO_TEST_SUITE(FdCIRTest) +BOOST_AUTO_TEST_SUITE(FdCIRTests) BOOST_AUTO_TEST_CASE(testFdmCIRConvergence) { BOOST_TEST_MESSAGE("Testing FDM CIR convergence..."); diff --git a/test-suite/fdheston.cpp b/test-suite/fdheston.cpp index a1734d9c2d8..b5a8e87607e 100644 --- a/test-suite/fdheston.cpp +++ b/test-suite/fdheston.cpp @@ -46,8 +46,11 @@ using namespace QuantLib; using namespace boost::unit_test_framework; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) -namespace fd_heston_test { +BOOST_AUTO_TEST_SUITE(FdHestonTests) + +namespace { struct NewBarrierOptionData { Barrier::Type barrierType; Real barrier; @@ -87,9 +90,7 @@ namespace fd_heston_test { const Date referenceDate_; const Real s0_, alpha_; }; -} -namespace { struct HestonTestData { Real kappa; Real theta; @@ -101,15 +102,10 @@ namespace { Real K; }; } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(FdHestonTest) BOOST_AUTO_TEST_CASE(testFdmHestonVarianceMesher) { BOOST_TEST_MESSAGE("Testing FDM Heston variance mesher..."); - using namespace fd_heston_test; - const Date today = Date(22, February, 2018); const DayCounter dc = Actual365Fixed(); Settings::instance().evaluationDate() = today; @@ -207,8 +203,6 @@ BOOST_AUTO_TEST_CASE(testFdmHestonBarrierVsBlackScholes, *precondition(if_speed( BOOST_TEST_MESSAGE("Testing FDM with barrier option in Heston model..."); - using namespace fd_heston_test; - NewBarrierOptionData values[] = { /* The data below are from "Option pricing formulas", E.G. Haug, McGraw-Hill 1998 pag. 72 @@ -1091,4 +1085,4 @@ BOOST_AUTO_TEST_CASE(testAmericanCallPutParity) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/fdmlinearop.cpp b/test-suite/fdmlinearop.cpp index 74e28686660..7229e38a0b9 100644 --- a/test-suite/fdmlinearop.cpp +++ b/test-suite/fdmlinearop.cpp @@ -79,6 +79,10 @@ using namespace QuantLib; using namespace boost::unit_test_framework; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(FdmLinearOpTests) + namespace { class FdmHestonExpressCondition : public StepCondition { @@ -129,10 +133,6 @@ namespace { V operator()(T t, U u) { return t*u;} }; -} - -namespace { - ext::shared_ptr createHestonHullWhite( Time maturity) { @@ -265,10 +265,6 @@ namespace { } } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(FdmLinearOpTest) - BOOST_AUTO_TEST_CASE(testFdmLinearOpLayout) { BOOST_TEST_MESSAGE("Testing indexing of a linear operator..."); @@ -1640,4 +1636,4 @@ BOOST_AUTO_TEST_CASE(testLowVolatilityHighDiscreteDividendBlackScholesMesher) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/fdsabr.cpp b/test-suite/fdsabr.cpp index 20694952fe8..39bc9414203 100644 --- a/test-suite/fdsabr.cpp +++ b/test-suite/fdsabr.cpp @@ -39,6 +39,10 @@ using namespace QuantLib; using namespace boost::unit_test_framework; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(FdSabrTests) + namespace { class SabrMonteCarloPricer { public: @@ -137,10 +141,6 @@ namespace { }; } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(FdSabrTest) - BOOST_AUTO_TEST_CASE(testFdmSabrOp, *precondition(if_speed(Fast))) { BOOST_TEST_MESSAGE("Testing FDM SABR operator..."); @@ -510,4 +510,4 @@ BOOST_AUTO_TEST_CASE(testBenchOpSabrCase) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/fittedbonddiscountcurve.cpp b/test-suite/fittedbonddiscountcurve.cpp index ccbe22d6b6d..03c9e11fafb 100644 --- a/test-suite/fittedbonddiscountcurve.cpp +++ b/test-suite/fittedbonddiscountcurve.cpp @@ -33,9 +33,9 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) -BOOST_AUTO_TEST_SUITE(FittedBondDiscountCurveTest) +BOOST_AUTO_TEST_SUITE(FittedBondDiscountCurveTests) BOOST_AUTO_TEST_CASE(testEvaluation) { @@ -199,4 +199,4 @@ BOOST_AUTO_TEST_CASE(testFlatExtrapolation) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/forwardoption.cpp b/test-suite/forwardoption.cpp index c1745787c82..b81d0b4c17a 100644 --- a/test-suite/forwardoption.cpp +++ b/test-suite/forwardoption.cpp @@ -40,6 +40,10 @@ using namespace QuantLib; using namespace boost::unit_test_framework; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(ForwardOptionTests) + #undef REPORT_FAILURE #define REPORT_FAILURE(greekName, payoff, exercise, s, q, r, today, \ v, moneyness, reset, expected, calculated, \ @@ -221,10 +225,6 @@ namespace { } } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(ForwardOptionTest) - BOOST_AUTO_TEST_CASE(testValues) { BOOST_TEST_MESSAGE("Testing forward option values..."); @@ -805,4 +805,4 @@ BOOST_AUTO_TEST_CASE(testHestonAnalyticalVsMCPrices, *precondition(if_speed(Fast BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/forwardrateagreement.cpp b/test-suite/forwardrateagreement.cpp index 9cc5ffcade6..77a3b2318b0 100644 --- a/test-suite/forwardrateagreement.cpp +++ b/test-suite/forwardrateagreement.cpp @@ -30,9 +30,9 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) -BOOST_AUTO_TEST_SUITE(ForwardRateAgreementTest) +BOOST_AUTO_TEST_SUITE(ForwardRateAgreementTests) BOOST_AUTO_TEST_CASE(testConstructionWithoutACurve) { BOOST_TEST_MESSAGE("Testing forward rate agreement construction..."); @@ -117,4 +117,4 @@ BOOST_AUTO_TEST_CASE(testConstructionWithoutACurve) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/functions.cpp b/test-suite/functions.cpp index 0ed8f73d304..5b2b3512501 100644 --- a/test-suite/functions.cpp +++ b/test-suite/functions.cpp @@ -31,9 +31,9 @@ using namespace boost::unit_test_framework; using std::exp; -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) -BOOST_AUTO_TEST_SUITE(FunctionsTest) +BOOST_AUTO_TEST_SUITE(FunctionsTests) BOOST_AUTO_TEST_CASE(testFactorial) { @@ -295,4 +295,4 @@ BOOST_AUTO_TEST_CASE(testWeightedModifiedBesselFunctions) { } BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/garch.cpp b/test-suite/garch.cpp index 69f3208e088..fdb6bb882ff 100644 --- a/test-suite/garch.cpp +++ b/test-suite/garch.cpp @@ -29,7 +29,11 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -namespace garch_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(GARCHTests) + +namespace { class DummyOptimizationMethod : public OptimizationMethod { public: @@ -80,16 +84,10 @@ namespace garch_test { << "\n expected: " << results.member); \ } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(GARCHTest) - BOOST_AUTO_TEST_CASE(testCalibration) { BOOST_TEST_MESSAGE("Testing GARCH model calibration..."); - using namespace garch_test; - Date start(7, July, 1962), d = start; TimeSeries ts; Garch11 garch(0.2, 0.3, 0.4); @@ -173,8 +171,6 @@ BOOST_AUTO_TEST_CASE(testCalibration) { BOOST_AUTO_TEST_CASE(testCalculation) { BOOST_TEST_MESSAGE("Testing GARCH model calculation..."); - using namespace garch_test; - Date d(7, July, 1962); TimeSeries ts; Garch11 garch(0.2, 0.3, 0.4); @@ -190,4 +186,4 @@ BOOST_AUTO_TEST_CASE(testCalculation) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/gaussianquadratures.cpp b/test-suite/gaussianquadratures.cpp index 6a25c9539c2..20e414fec00 100644 --- a/test-suite/gaussianquadratures.cpp +++ b/test-suite/gaussianquadratures.cpp @@ -44,7 +44,11 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -namespace gaussian_quadratures_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(GaussianQuadraturesTests) + +namespace { template void testSingle(const T& I, const std::string& tag, @@ -155,15 +159,9 @@ namespace gaussian_quadratures_test { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(GaussianQuadraturesTest) - BOOST_AUTO_TEST_CASE(testJacobi) { BOOST_TEST_MESSAGE("Testing Gauss-Jacobi integration..."); - using namespace gaussian_quadratures_test; - testSingleJacobi(GaussLegendreIntegration(16)); testSingleJacobi(GaussChebyshevIntegration(130)); testSingleJacobi(GaussChebyshev2ndIntegration(130)); @@ -173,8 +171,6 @@ BOOST_AUTO_TEST_CASE(testJacobi) { BOOST_AUTO_TEST_CASE(testLaguerre) { BOOST_TEST_MESSAGE("Testing Gauss-Laguerre integration..."); - using namespace gaussian_quadratures_test; - testSingleLaguerre(GaussLaguerreIntegration(16)); testSingleLaguerre(GaussLaguerreIntegration(150,0.01)); @@ -187,8 +183,6 @@ BOOST_AUTO_TEST_CASE(testLaguerre) { BOOST_AUTO_TEST_CASE(testHermite) { BOOST_TEST_MESSAGE("Testing Gauss-Hermite integration..."); - using namespace gaussian_quadratures_test; - testSingle(GaussHermiteIntegration(16), "f(x) = Gaussian(x)", NormalDistribution(), 1.0); testSingle(GaussHermiteIntegration(16,0.5), "f(x) = x*Gaussian(x)", @@ -200,8 +194,6 @@ BOOST_AUTO_TEST_CASE(testHermite) { BOOST_AUTO_TEST_CASE(testHyperbolic) { BOOST_TEST_MESSAGE("Testing Gauss hyperbolic integration..."); - using namespace gaussian_quadratures_test; - testSingle(GaussHyperbolicIntegration(16), "f(x) = 1/cosh(x)", inv_cosh, M_PI); testSingle(GaussHyperbolicIntegration(16), "f(x) = x/cosh(x)", @@ -211,10 +203,6 @@ BOOST_AUTO_TEST_CASE(testHyperbolic) { BOOST_AUTO_TEST_CASE(testTabulated) { BOOST_TEST_MESSAGE("Testing tabulated Gauss-Laguerre integration..."); - using namespace gaussian_quadratures_test; - - testSingleTabulated([](Real x) -> Real { return 1.0; }, "f(x) = 1", - 2.0, 1.0e-13); testSingleTabulated([](Real x) -> Real { return x; }, "f(x) = x", 0.0, 1.0e-13); testSingleTabulated([](Real x) -> Real { return x * x; }, "f(x) = x^2", @@ -228,8 +216,6 @@ BOOST_AUTO_TEST_CASE(testTabulated) { BOOST_AUTO_TEST_CASE(testMomentBasedGaussianPolynomial) { BOOST_TEST_MESSAGE("Testing moment-based Gaussian polynomials..."); - using namespace gaussian_quadratures_test; - GaussLaguerrePolynomial g; std::vector > ml; @@ -267,8 +253,6 @@ BOOST_AUTO_TEST_CASE(testMomentBasedGaussianPolynomial) { BOOST_AUTO_TEST_CASE(testGaussLaguerreCosinePolynomial) { BOOST_TEST_MESSAGE("Testing Gauss-Laguerre-Cosine quadrature..."); - using namespace gaussian_quadratures_test; - const GaussianQuadrature quadCosine( 16, GaussLaguerreCosinePolynomial(0.2)); @@ -290,8 +274,6 @@ BOOST_AUTO_TEST_CASE(testNonCentralChiSquared) { BOOST_TEST_MESSAGE( "Testing Gauss non-central chi-squared integration..."); - using namespace gaussian_quadratures_test; - testSingle( GaussianQuadrature(2, GaussNonCentralChiSquaredPolynomial(4.0, 1.0)), "f(x) = x^2 * nonCentralChiSquared(4, 1)(x)", @@ -307,8 +289,6 @@ BOOST_AUTO_TEST_CASE(testNonCentralChiSquaredSumOfNodes) { BOOST_TEST_MESSAGE( "Testing Gauss non-central chi-squared sum of nodes..."); - using namespace gaussian_quadratures_test; - // Walter Gautschi, How and How not to check Gaussian Quadrature Formulae // https://www.cs.purdue.edu/homes/wxg/selected_works/section_08/084.pdf diff --git a/test-suite/gjrgarchmodel.cpp b/test-suite/gjrgarchmodel.cpp index fa83db070b9..c42220c7c66 100644 --- a/test-suite/gjrgarchmodel.cpp +++ b/test-suite/gjrgarchmodel.cpp @@ -41,9 +41,9 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) -BOOST_AUTO_TEST_SUITE(GJRGARCHModelTest) +BOOST_AUTO_TEST_SUITE(GJRGARCHModelTests) BOOST_AUTO_TEST_CASE(testEngines, *precondition(if_speed(Slow))) { BOOST_TEST_MESSAGE( @@ -307,4 +307,4 @@ BOOST_AUTO_TEST_CASE(testDAXCalibration, *precondition(if_speed(Fast))) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/gsr.cpp b/test-suite/gsr.cpp index dae1e6bba2c..bb09e0d243d 100644 --- a/test-suite/gsr.cpp +++ b/test-suite/gsr.cpp @@ -46,9 +46,9 @@ using boost::unit_test_framework::test_suite; using std::fabs; -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) -BOOST_AUTO_TEST_SUITE(GsrTest) +BOOST_AUTO_TEST_SUITE(GsrTests) BOOST_AUTO_TEST_CASE(testGsrProcess) { @@ -291,4 +291,4 @@ BOOST_AUTO_TEST_CASE(testGsrModel) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/hestonmodel.cpp b/test-suite/hestonmodel.cpp index e2db2d302b0..d8121d98d6e 100644 --- a/test-suite/hestonmodel.cpp +++ b/test-suite/hestonmodel.cpp @@ -63,6 +63,10 @@ using namespace QuantLib; using namespace boost::unit_test_framework; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(HestonModelTests) + namespace { struct CalibrationMarketData { @@ -227,10 +231,6 @@ namespace { }; } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(HestonModelTest) - BOOST_AUTO_TEST_CASE(testBlackCalibration) { BOOST_TEST_MESSAGE( "Testing Heston model calibration using a flat volatility surface..."); diff --git a/test-suite/hestonslvmodel.cpp b/test-suite/hestonslvmodel.cpp index 2605e584816..7d134bcb196 100644 --- a/test-suite/hestonslvmodel.cpp +++ b/test-suite/hestonslvmodel.cpp @@ -93,6 +93,10 @@ using namespace QuantLib; using namespace boost::unit_test_framework; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(HestonSLVModelTests) + namespace { Real fokkerPlanckPrice1D(const ext::shared_ptr& mesher, const ext::shared_ptr& op, @@ -725,10 +729,6 @@ namespace { } } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(HestonSLVModelTest) - BOOST_AUTO_TEST_CASE(testBlackScholesFokkerPlanckFwdEquation) { BOOST_TEST_MESSAGE("Testing Fokker-Planck forward equation for BS process..."); diff --git a/test-suite/himalayaoption.cpp b/test-suite/himalayaoption.cpp index 10c4b5b491f..7776b19f3f5 100644 --- a/test-suite/himalayaoption.cpp +++ b/test-suite/himalayaoption.cpp @@ -28,9 +28,9 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) -BOOST_AUTO_TEST_SUITE(HimalayaOptionTest) +BOOST_AUTO_TEST_SUITE(HimalayaOptionTests) BOOST_AUTO_TEST_CASE(testCached) { @@ -131,4 +131,4 @@ BOOST_AUTO_TEST_CASE(testCached) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/hybridhestonhullwhiteprocess.cpp b/test-suite/hybridhestonhullwhiteprocess.cpp index de36916343a..bb6d224cf7f 100644 --- a/test-suite/hybridhestonhullwhiteprocess.cpp +++ b/test-suite/hybridhestonhullwhiteprocess.cpp @@ -56,9 +56,9 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) -BOOST_AUTO_TEST_SUITE(HybridHestonHullWhiteProcessTest) +BOOST_AUTO_TEST_SUITE(HybridHestonHullWhiteProcessTests) BOOST_AUTO_TEST_CASE(testBsmHullWhiteEngine) { BOOST_TEST_MESSAGE("Testing European option pricing for a BSM process" @@ -883,7 +883,7 @@ BOOST_AUTO_TEST_CASE(testFdmHestonHullWhiteEngine, *precondition(if_speed(Fast)) } -namespace hybrid_heston_hullwhite_process_test { +namespace { struct HestonModelData { const char* const name; @@ -978,8 +978,6 @@ namespace hybrid_heston_hullwhite_process_test { BOOST_AUTO_TEST_CASE(testBsmHullWhitePricing) { BOOST_TEST_MESSAGE("Testing convergence speed of Heston-Hull-White engine..."); - using namespace hybrid_heston_hullwhite_process_test; - Date today(27, December, 2004); Settings::instance().evaluationDate() = today; @@ -1064,8 +1062,6 @@ BOOST_AUTO_TEST_CASE(testBsmHullWhitePricing) { BOOST_AUTO_TEST_CASE(testSpatialDiscretizatinError, *precondition(if_speed(Fast))) { BOOST_TEST_MESSAGE("Testing spatial convergence speed of Heston engine..."); - using namespace hybrid_heston_hullwhite_process_test; - Date today(27, December, 2004); Settings::instance().evaluationDate() = today; @@ -1121,7 +1117,7 @@ BOOST_AUTO_TEST_CASE(testSpatialDiscretizatinError, *precondition(if_speed(Fast) -namespace hybrid_heston_hullwhite_process_test { +namespace { class HestonHullWhiteCorrelationConstraint : public Constraint { private: class Impl : public Constraint::Impl { @@ -1150,8 +1146,6 @@ namespace hybrid_heston_hullwhite_process_test { BOOST_AUTO_TEST_CASE(testHestonHullWhiteCalibration, *precondition(if_speed(Slow))) { BOOST_TEST_MESSAGE("Testing the Heston Hull-White calibration..."); - using namespace hybrid_heston_hullwhite_process_test; - // Calibration of a hybrid Heston-Hull-White model using // the finite difference HestonHullWhite pricing engine // @@ -1430,4 +1424,4 @@ BOOST_AUTO_TEST_CASE(testH1HWPricingEngine) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/indexes.cpp b/test-suite/indexes.cpp index f818af28402..b094d1da649 100644 --- a/test-suite/indexes.cpp +++ b/test-suite/indexes.cpp @@ -29,9 +29,9 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) -BOOST_AUTO_TEST_SUITE(IndexTest) +BOOST_AUTO_TEST_SUITE(IndexTests) BOOST_AUTO_TEST_CASE(testFixingObservability) { BOOST_TEST_MESSAGE("Testing observability of index fixings..."); @@ -161,4 +161,4 @@ BOOST_AUTO_TEST_CASE(testTenorNormalization) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/inflation.cpp b/test-suite/inflation.cpp index 7fe1b98f4fc..f98cd2db5f9 100644 --- a/test-suite/inflation.cpp +++ b/test-suite/inflation.cpp @@ -51,6 +51,10 @@ using std::fabs; using std::pow; using std::vector; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(InflationTests) + #undef REPORT_FAILURE #define REPORT_FAILURE(d, res, periodName) \ BOOST_ERROR("wrong " << periodName << " inflation period for Date (1 " \ @@ -58,7 +62,7 @@ using std::vector; << res.first << "), End Date (" \ << res.second << ")"); \ -namespace inflation_test { +namespace { struct Datum { Date date; @@ -233,10 +237,6 @@ namespace inflation_test { // zero inflation tests, index, termstructure, and swaps //=========================================================================================== -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(InflationTest) - BOOST_AUTO_TEST_CASE(testZeroIndex) { BOOST_TEST_MESSAGE("Testing zero inflation indices..."); @@ -336,8 +336,6 @@ BOOST_AUTO_TEST_CASE(testZeroIndex) { BOOST_AUTO_TEST_CASE(testZeroTermStructure) { BOOST_TEST_MESSAGE("Testing zero inflation term structure..."); - using namespace inflation_test; - // try the Zero UK Calendar calendar = UnitedKingdom(); BusinessDayConvention bdc = ModifiedFollowing; @@ -576,8 +574,6 @@ BOOST_AUTO_TEST_CASE(testZeroTermStructure) { BOOST_AUTO_TEST_CASE(testSeasonalityCorrection) { BOOST_TEST_MESSAGE("Testing seasonality correction on zero inflation term structure..."); - using namespace inflation_test; - // try the Zero UK Calendar calendar = UnitedKingdom(); Date evaluationDate(13, August, 2007); @@ -1034,8 +1030,6 @@ BOOST_AUTO_TEST_CASE(testOldRatioYYIndex) { BOOST_AUTO_TEST_CASE(testYYTermStructure) { BOOST_TEST_MESSAGE("Testing year-on-year inflation term structure..."); - using namespace inflation_test; - // try the YY UK Calendar calendar = UnitedKingdom(); BusinessDayConvention bdc = ModifiedFollowing; @@ -1447,4 +1441,4 @@ BOOST_AUTO_TEST_CASE(testCpiAsIndexInterpolation) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/inflationcapfloor.cpp b/test-suite/inflationcapfloor.cpp index a546001cd7b..20194bd8e59 100644 --- a/test-suite/inflationcapfloor.cpp +++ b/test-suite/inflationcapfloor.cpp @@ -52,7 +52,11 @@ using namespace boost::unit_test_framework; using std::fabs; -namespace inflation_capfloor_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(InflationCapFloorTests) + +namespace { struct Datum { Date date; @@ -267,17 +271,11 @@ namespace inflation_capfloor_test { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(InflationCapFloorTest) - BOOST_AUTO_TEST_CASE(testConsistency) { BOOST_TEST_MESSAGE("Testing consistency between yoy inflation cap," " floor and collar..."); - using namespace inflation_capfloor_test; - CommonVars vars; Integer lengths[] = { 1, 2, 3, 5, 7, 10, 15, 20 }; @@ -397,8 +395,6 @@ BOOST_AUTO_TEST_CASE(testParity) { BOOST_TEST_MESSAGE("Testing yoy inflation cap/floor parity..."); - using namespace inflation_capfloor_test; - CommonVars vars; Integer lengths[] = { 1, 2, 3, 5, 7, 10, 15, 20 }; @@ -464,8 +460,6 @@ BOOST_AUTO_TEST_CASE(testCachedValue) { BOOST_TEST_MESSAGE("Testing Black yoy inflation cap/floor price" " against cached values..."); - using namespace inflation_capfloor_test; - CommonVars vars; Size whichPricer = 0; // black @@ -535,4 +529,4 @@ BOOST_AUTO_TEST_CASE(testCachedValue) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/inflationcapflooredcoupon.cpp b/test-suite/inflationcapflooredcoupon.cpp index 6c9f585043a..6d4f9c12b26 100644 --- a/test-suite/inflationcapflooredcoupon.cpp +++ b/test-suite/inflationcapflooredcoupon.cpp @@ -53,7 +53,11 @@ using namespace boost::unit_test_framework; using std::fabs; -namespace inflation_capfloored_coupon_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(InflationCapFlooredCouponTests) + +namespace { struct Datum { Date date; Rate rate; @@ -364,16 +368,10 @@ namespace inflation_capfloored_coupon_test { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(InflationCapFlooredCouponTest) - BOOST_AUTO_TEST_CASE(testDecomposition) { BOOST_TEST_MESSAGE("Testing collared coupon against its decomposition..."); - using namespace inflation_capfloored_coupon_test; - CommonVars vars; Real tolerance = 1e-10; @@ -690,8 +688,6 @@ BOOST_AUTO_TEST_CASE(testInstrumentEquality) { BOOST_TEST_MESSAGE("Testing inflation capped/floored coupon against" " inflation capfloor instrument..."); - using namespace inflation_capfloored_coupon_test; - CommonVars vars; Integer lengths[] = { 1, 2, 3, 5, 7, 10, 15, 20 }; @@ -789,4 +785,4 @@ BOOST_AUTO_TEST_CASE(testInstrumentEquality) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/inflationcpibond.cpp b/test-suite/inflationcpibond.cpp index c6a99a63b96..7018b644652 100644 --- a/test-suite/inflationcpibond.cpp +++ b/test-suite/inflationcpibond.cpp @@ -41,9 +41,11 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -#include +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) -namespace inflation_cpi_bond_test { +BOOST_AUTO_TEST_SUITE(InflationCPIBondTests) + +namespace { struct Datum { Date date; @@ -164,15 +166,9 @@ namespace inflation_cpi_bond_test { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(InflationCPIBondTest) - BOOST_AUTO_TEST_CASE(testCleanPrice) { BOOST_TEST_MESSAGE("Checking cached pricers for CPI bond..."); - using namespace inflation_cpi_bond_test; - CommonVars common; Real notional = 1000000.0; @@ -228,8 +224,6 @@ BOOST_AUTO_TEST_CASE(testCleanPrice) { BOOST_AUTO_TEST_CASE(testCPILegWithoutBaseCPI) { BOOST_TEST_MESSAGE("Checking CPI leg with or without explicit base CPI fixing..."); - using namespace inflation_cpi_bond_test; - CommonVars common; Real notional = 1000000.0; @@ -307,4 +301,4 @@ BOOST_AUTO_TEST_CASE(testCPILegWithoutBaseCPI) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/inflationcpicapfloor.cpp b/test-suite/inflationcpicapfloor.cpp index 990332e82e1..a02de01ddbd 100644 --- a/test-suite/inflationcpicapfloor.cpp +++ b/test-suite/inflationcpicapfloor.cpp @@ -44,12 +44,14 @@ #include #include -#include - using namespace QuantLib; using namespace boost::unit_test_framework; -namespace inflation_cpi_capfloor_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(InflationCPICapFloorTests) + +namespace { struct Datum { Date date; Rate rate; @@ -307,15 +309,9 @@ namespace inflation_cpi_capfloor_test { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(InflationCPICapFloorTest) - BOOST_AUTO_TEST_CASE(cpicapfloorpricesurface) { BOOST_TEST_MESSAGE("Checking CPI cap/floor against price surface..."); - using namespace inflation_cpi_capfloor_test; - CommonVars common; Real nominal = 1.0; @@ -382,8 +378,6 @@ BOOST_AUTO_TEST_CASE(cpicapfloorpricesurface) { BOOST_AUTO_TEST_CASE(cpicapfloorpricer) { BOOST_TEST_MESSAGE("Checking CPI cap/floor pricer..."); - using namespace inflation_cpi_capfloor_test; - CommonVars common; Real nominal = 1.0; ext::shared_ptr cpiCFpriceSurf(new InterpolatedCPICapFloorTermPriceSurface diff --git a/test-suite/inflationcpiswap.cpp b/test-suite/inflationcpiswap.cpp index ccc7b841f40..3f7226a568d 100644 --- a/test-suite/inflationcpiswap.cpp +++ b/test-suite/inflationcpiswap.cpp @@ -41,11 +41,13 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -#include - using std::fabs; -namespace inflation_cpi_swap_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(CPISwapTests) + +namespace { struct Datum { Date date; Rate rate; @@ -247,15 +249,9 @@ namespace inflation_cpi_swap_test { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(CPISwapTest) - BOOST_AUTO_TEST_CASE(consistency) { BOOST_TEST_MESSAGE("Checking CPI swap against inflation term structure..."); - using namespace inflation_cpi_swap_test; - bool usingAtParCoupons = IborCoupon::Settings::instance().usingAtParCoupons(); // check inflation leg vs calculation directly from inflation TS @@ -367,8 +363,6 @@ BOOST_AUTO_TEST_CASE(consistency) { BOOST_AUTO_TEST_CASE(zciisconsistency) { BOOST_TEST_MESSAGE("Checking CPI swap against zero-coupon inflation swap..."); - using namespace inflation_cpi_swap_test; - CommonVars common; Swap::Type ztype = Swap::Payer; @@ -423,8 +417,6 @@ BOOST_AUTO_TEST_CASE(zciisconsistency) { BOOST_AUTO_TEST_CASE(cpibondconsistency) { BOOST_TEST_MESSAGE("Checking CPI swap against CPI bond..."); - using namespace inflation_cpi_swap_test; - CommonVars common; // ZeroInflationSwap aka CPISwap @@ -514,4 +506,4 @@ BOOST_AUTO_TEST_CASE(cpibondconsistency) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/inflationvolatility.cpp b/test-suite/inflationvolatility.cpp index 6d1e02e250f..b8890f3d9db 100644 --- a/test-suite/inflationvolatility.cpp +++ b/test-suite/inflationvolatility.cpp @@ -34,14 +34,16 @@ #include #include -#include - using namespace QuantLib; using namespace boost::unit_test; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(InflationVolTests) + // local namespace for data //************************************************************************* -namespace inflation_volatility_test { +namespace { using namespace QuantLib; @@ -273,16 +275,10 @@ namespace inflation_volatility_test { //*************************************************************************** -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(InflationVolTest) - BOOST_AUTO_TEST_CASE(testYoYPriceSurfaceToVol) { BOOST_TEST_MESSAGE("Testing conversion from YoY price surface " "to YoY volatility surface..."); - using namespace inflation_volatility_test; - setup(); // first get the price surface set up @@ -366,8 +362,6 @@ BOOST_AUTO_TEST_CASE(testYoYPriceSurfaceToATM) { BOOST_TEST_MESSAGE("Testing conversion from YoY cap-floor surface " "to YoY inflation term structure..."); - using namespace inflation_volatility_test; - setup(); setupPriceSurface(); diff --git a/test-suite/instruments.cpp b/test-suite/instruments.cpp index fa94c8e1e3e..90127e8c254 100644 --- a/test-suite/instruments.cpp +++ b/test-suite/instruments.cpp @@ -29,9 +29,9 @@ using namespace QuantLib; using namespace boost::unit_test; -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, QuantLib::TopLevelFixture) +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, QuantLib::TopLevelFixture) -BOOST_AUTO_TEST_SUITE(InstrumentTest) +BOOST_AUTO_TEST_SUITE(InstrumentTests) BOOST_AUTO_TEST_CASE(testObservable) { @@ -115,4 +115,4 @@ BOOST_AUTO_TEST_CASE(testCompositeWhenShiftingDates) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/integrals.cpp b/test-suite/integrals.cpp index 861a70c36e8..0db44d29272 100644 --- a/test-suite/integrals.cpp +++ b/test-suite/integrals.cpp @@ -40,7 +40,11 @@ using namespace QuantLib; using namespace boost::unit_test; -namespace integrals_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(IntegralTests) + +namespace { Real tolerance = 1.0e-6; @@ -49,7 +53,7 @@ namespace integrals_test { const ext::function& f, Real xMin, Real xMax, Real expected) { Real calculated = I(f,xMin,xMax); - if (std::fabs(calculated-expected) > integrals_test::tolerance) { + if (std::fabs(calculated-expected) > tolerance) { BOOST_FAIL(std::setprecision(10) << "integrating " << tag << " calculated: " << calculated @@ -132,15 +136,9 @@ namespace integrals_test { } } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(IntegralTest) - BOOST_AUTO_TEST_CASE(testSegment) { BOOST_TEST_MESSAGE("Testing segment integration..."); - using namespace integrals_test; - testSeveral(SegmentIntegral(10000)); testDegeneratedDomain(SegmentIntegral(10000)); } @@ -148,47 +146,37 @@ BOOST_AUTO_TEST_CASE(testSegment) { BOOST_AUTO_TEST_CASE(testTrapezoid) { BOOST_TEST_MESSAGE("Testing trapezoid integration..."); - using namespace integrals_test; - - testSeveral(TrapezoidIntegral(integrals_test::tolerance, 10000)); - testDegeneratedDomain(TrapezoidIntegral(integrals_test::tolerance, 10000)); + testSeveral(TrapezoidIntegral(tolerance, 10000)); + testDegeneratedDomain(TrapezoidIntegral(tolerance, 10000)); } BOOST_AUTO_TEST_CASE(testMidPointTrapezoid) { BOOST_TEST_MESSAGE("Testing mid-point trapezoid integration..."); - using namespace integrals_test; - - testSeveral(TrapezoidIntegral(integrals_test::tolerance, 10000)); - testDegeneratedDomain(TrapezoidIntegral(integrals_test::tolerance, 10000)); + testSeveral(TrapezoidIntegral(tolerance, 10000)); + testDegeneratedDomain(TrapezoidIntegral(tolerance, 10000)); } BOOST_AUTO_TEST_CASE(testSimpson) { BOOST_TEST_MESSAGE("Testing Simpson integration..."); - using namespace integrals_test; - - testSeveral(SimpsonIntegral(integrals_test::tolerance, 10000)); - testDegeneratedDomain(SimpsonIntegral(integrals_test::tolerance, 10000)); + testSeveral(SimpsonIntegral(tolerance, 10000)); + testDegeneratedDomain(SimpsonIntegral(tolerance, 10000)); } BOOST_AUTO_TEST_CASE(testGaussKronrodAdaptive) { BOOST_TEST_MESSAGE("Testing adaptive Gauss-Kronrod integration..."); - using namespace integrals_test; - Size maxEvaluations = 1000; - testSeveral(GaussKronrodAdaptive(integrals_test::tolerance, maxEvaluations)); - testDegeneratedDomain(GaussKronrodAdaptive(integrals_test::tolerance, maxEvaluations)); + testSeveral(GaussKronrodAdaptive(tolerance, maxEvaluations)); + testDegeneratedDomain(GaussKronrodAdaptive(tolerance, maxEvaluations)); } BOOST_AUTO_TEST_CASE(testGaussLobatto) { BOOST_TEST_MESSAGE("Testing adaptive Gauss-Lobatto integration..."); - using namespace integrals_test; - Size maxEvaluations = 1000; - testSeveral(GaussLobattoIntegral(maxEvaluations, integrals_test::tolerance)); + testSeveral(GaussLobattoIntegral(maxEvaluations, tolerance)); // on degenerated domain [1,1+macheps] an exception is thrown // which is also ok, but not tested here } @@ -197,7 +185,6 @@ BOOST_AUTO_TEST_CASE(testGaussLobatto) { BOOST_AUTO_TEST_CASE(testTanhSinh) { BOOST_TEST_MESSAGE("Testing tanh-sinh integration..."); - using namespace integrals_test; testSeveral(TanhSinhIntegral()); } #endif @@ -205,8 +192,6 @@ BOOST_AUTO_TEST_CASE(testTanhSinh) { BOOST_AUTO_TEST_CASE(testGaussLegendreIntegrator) { BOOST_TEST_MESSAGE("Testing Gauss-Legendre integrator..."); - using namespace integrals_test; - const GaussLegendreIntegrator integrator(64); testSeveral(integrator); testDegeneratedDomain(integrator); @@ -215,8 +200,6 @@ BOOST_AUTO_TEST_CASE(testGaussLegendreIntegrator) { BOOST_AUTO_TEST_CASE(testGaussChebyshevIntegrator) { BOOST_TEST_MESSAGE("Testing Gauss-Chebyshev integrator..."); - using namespace integrals_test; - const GaussChebyshevIntegrator integrator(64); testSingle(integrator, "f(x) = Gaussian(x)", NormalDistribution(), -10.0, 10.0, 1.0); @@ -226,8 +209,6 @@ BOOST_AUTO_TEST_CASE(testGaussChebyshevIntegrator) { BOOST_AUTO_TEST_CASE(testGaussChebyshev2ndIntegrator) { BOOST_TEST_MESSAGE("Testing Gauss-Chebyshev 2nd integrator..."); - using namespace integrals_test; - const GaussChebyshev2ndIntegrator integrator(64); testSingle(integrator, "f(x) = Gaussian(x)", NormalDistribution(), -10.0, 10.0, 1.0); @@ -237,11 +218,9 @@ BOOST_AUTO_TEST_CASE(testGaussChebyshev2ndIntegrator) { BOOST_AUTO_TEST_CASE(testGaussKronrodNonAdaptive) { BOOST_TEST_MESSAGE("Testing non-adaptive Gauss-Kronrod integration..."); - using namespace integrals_test; - - Real precision = integrals_test::tolerance; + Real precision = tolerance; Size maxEvaluations = 100; - Real relativeAccuracy = integrals_test::tolerance; + Real relativeAccuracy = tolerance; GaussKronrodNonAdaptive gaussKronrodNonAdaptive(precision, maxEvaluations, relativeAccuracy); testSeveral(gaussKronrodNonAdaptive); @@ -252,19 +231,17 @@ BOOST_AUTO_TEST_CASE(testTwoDimensionalIntegration) { BOOST_TEST_MESSAGE("Testing two dimensional adaptive " "Gauss-Lobatto integration..."); - using namespace integrals_test; - const Size maxEvaluations = 1000; const Real calculated = TwoDimensionalIntegral( ext::shared_ptr( - new TrapezoidIntegral(integrals_test::tolerance, maxEvaluations)), + new TrapezoidIntegral(tolerance, maxEvaluations)), ext::shared_ptr( - new TrapezoidIntegral(integrals_test::tolerance, maxEvaluations)))( + new TrapezoidIntegral(tolerance, maxEvaluations)))( std::multiplies<>(), std::make_pair(0.0, 0.0), std::make_pair(1.0, 2.0)); const Real expected = 1.0; - if (std::fabs(calculated-expected) > integrals_test::tolerance) { + if (std::fabs(calculated-expected) > tolerance) { BOOST_FAIL(std::setprecision(10) << "two dimensional integration: " << "\n calculated: " << calculated @@ -275,8 +252,6 @@ BOOST_AUTO_TEST_CASE(testTwoDimensionalIntegration) { BOOST_AUTO_TEST_CASE(testFolinIntegration) { BOOST_TEST_MESSAGE("Testing Folin's integral formulae..."); - using namespace integrals_test; - // Examples taken from // http://www.tat.physik.uni-tuebingen.de/~kokkotas/Teaching/Num_Methods_files/Comp_Phys5.pdf const Size nr[] = { 4, 8, 16, 128, 256, 1024, 2048 }; @@ -315,8 +290,6 @@ BOOST_AUTO_TEST_CASE(testFolinIntegration) { BOOST_AUTO_TEST_CASE(testDiscreteIntegrals) { BOOST_TEST_MESSAGE("Testing discrete integral formulae..."); - using namespace integrals_test; - Array x(6), f(6); x[0] = 1.0; x[1] = 2.02; x[2] = 2.34; x[3] = 3.3; x[4] = 4.2; x[5] = 4.6; @@ -354,8 +327,6 @@ BOOST_AUTO_TEST_CASE(testDiscreteIntegrals) { BOOST_AUTO_TEST_CASE(testDiscreteIntegrator) { BOOST_TEST_MESSAGE("Testing discrete integrator formulae..."); - using namespace integrals_test; - testSeveral(DiscreteSimpsonIntegrator(300)); testSeveral(DiscreteTrapezoidIntegrator(3000)); } @@ -363,8 +334,6 @@ BOOST_AUTO_TEST_CASE(testDiscreteIntegrator) { BOOST_AUTO_TEST_CASE(testPiecewiseIntegral) { BOOST_TEST_MESSAGE("Testing piecewise integral..."); - using namespace integrals_test; - x = { 1.0, 2.0, 3.0, 4.0, 5.0 }; y = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 }; ext::shared_ptr segment = @@ -505,7 +474,7 @@ BOOST_AUTO_TEST_CASE(testExponentialIntegral) { if (diff > tol || (std::abs(ref.real()) < tol && std::abs(si.real()) > tol) || (std::abs(ref.imag()) < tol && std::abs(si.imag()) > tol)) { - integrals_test::reportSiCiFail("Si", z, si, ref, diff, tol); + reportSiCiFail("Si", z, si, ref, diff, tol); } const std::complex ci = Ci(z); @@ -514,7 +483,7 @@ BOOST_AUTO_TEST_CASE(testExponentialIntegral) { if (diff > tol || (std::abs(ref.real()) < tol && std::abs(ci.real()) > tol) || (std::abs(ref.imag()) < tol && std::abs(ci.imag()) > tol)) { - integrals_test::reportSiCiFail("Ci", z, ci, ref, diff, tol); + reportSiCiFail("Ci", z, ci, ref, diff, tol); } const std::complex ei = Ei(z); @@ -523,7 +492,7 @@ BOOST_AUTO_TEST_CASE(testExponentialIntegral) { if (diff > tol || (std::abs(ref.real()) < tol && std::abs(ei.real()) > tol) || (std::abs(ref.imag()) < tol && std::abs(ei.imag()) > tol)) { - integrals_test::reportSiCiFail("Ei", z, ei, ref, diff, tol); + reportSiCiFail("Ei", z, ei, ref, diff, tol); } const std::complex e1 = E1(z); @@ -533,7 +502,7 @@ BOOST_AUTO_TEST_CASE(testExponentialIntegral) { if (diff > tol || (std::abs(ref.real()) < tol && std::abs(e1.real()) > tol) || (std::abs(ref.imag()) < tol && std::abs(e1.imag()) > tol)) { - integrals_test::reportSiCiFail("E1", z, e1, ref, diff, tol); + reportSiCiFail("E1", z, e1, ref, diff, tol); } } } @@ -573,24 +542,24 @@ BOOST_AUTO_TEST_CASE(testRealSiCiIntegrals) { Real diff = std::fabs(si - i[1]); if (diff > tol) { - integrals_test::reportSiCiFail("SineIntegral", x, si, i[1], diff, tol); + reportSiCiFail("SineIntegral", x, si, i[1], diff, tol); } const Real ci = Ci(x); diff = std::fabs(ci - i[2]); if (diff > tol) { - integrals_test::reportSiCiFail("CosineIntegral", x, ci, i[2], diff, tol); + reportSiCiFail("CosineIntegral", x, ci, i[2], diff, tol); } x = -i[0]; si = Si(x); diff = std::fabs(si + i[1]); if (diff > tol) { - integrals_test::reportSiCiFail("SineIntegral", x, si, Real(-i[1]), diff, tol); + reportSiCiFail("SineIntegral", x, si, Real(-i[1]), diff, tol); } } } BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/interestrates.cpp b/test-suite/interestrates.cpp index dc325f98aed..d716212f202 100644 --- a/test-suite/interestrates.cpp +++ b/test-suite/interestrates.cpp @@ -29,6 +29,10 @@ using namespace QuantLib; using namespace boost::unit_test_framework; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(InterestRateTests) + namespace { struct InterestRateData { @@ -44,10 +48,6 @@ namespace { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(InterestRateTest) - BOOST_AUTO_TEST_CASE(testConversions) { BOOST_TEST_MESSAGE("Testing interest-rate conversions..."); @@ -195,4 +195,4 @@ BOOST_AUTO_TEST_CASE(testConversions) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/interpolations.cpp b/test-suite/interpolations.cpp index d6ef11710d1..a79838728f0 100644 --- a/test-suite/interpolations.cpp +++ b/test-suite/interpolations.cpp @@ -53,6 +53,10 @@ using namespace QuantLib; using namespace boost::unit_test_framework; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(InterpolationTests) + namespace { std::vector xRange(Real start, Real finish, Size points) { @@ -239,9 +243,6 @@ namespace { SIAM J. of Scientific and Statistical Computing, v. 4, 1983, pp. 645-654. http://math.lanl.gov/~mac/papers/numerics/H83.pdf */ -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(InterpolationTest) BOOST_AUTO_TEST_CASE(testSplineErrorOnGaussianValues) { @@ -2505,4 +2506,4 @@ BOOST_AUTO_TEST_CASE(testChebyshevInterpolationUpdateY) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/jumpdiffusion.cpp b/test-suite/jumpdiffusion.cpp index 66ac9b468fb..faca2736baa 100644 --- a/test-suite/jumpdiffusion.cpp +++ b/test-suite/jumpdiffusion.cpp @@ -33,6 +33,10 @@ using namespace QuantLib; using namespace boost::unit_test_framework; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(JumpDiffusionTests) + #undef REPORT_FAILURE_1 #define REPORT_FAILURE_1(greekName, payoff, exercise, s, q, r, today, v, \ intensity, meanLogJump, jumpVol, expected, \ @@ -94,10 +98,6 @@ namespace { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(JumpDiffusionTest) - BOOST_AUTO_TEST_CASE(testMerton76) { BOOST_TEST_MESSAGE("Testing Merton 76 jump-diffusion model " @@ -524,4 +524,4 @@ BOOST_AUTO_TEST_CASE(testGreeks) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/lazyobject.cpp b/test-suite/lazyobject.cpp index 012ef15190c..792e0bf3f7c 100644 --- a/test-suite/lazyobject.cpp +++ b/test-suite/lazyobject.cpp @@ -26,7 +26,11 @@ using namespace QuantLib; using namespace boost::unit_test_framework; using ext::shared_ptr; -namespace lazy_object_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(LazyObjectTests) + +namespace { class TearDown { // NOLINT(cppcoreguidelines-special-member-functions) bool alwaysForward; @@ -42,15 +46,11 @@ namespace lazy_object_test { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(LazyObjectTest) - BOOST_AUTO_TEST_CASE(testDiscardingNotifications) { BOOST_TEST_MESSAGE("Testing that lazy objects can discard notifications after the first against default..."); - lazy_object_test::TearDown teardown; + TearDown teardown; LazyObject::Defaults::instance().alwaysForwardNotifications(); @@ -83,7 +83,7 @@ BOOST_AUTO_TEST_CASE(testDiscardingNotificationsByDefault) { BOOST_TEST_MESSAGE("Testing that lazy objects can discard notifications after the first by default..."); - lazy_object_test::TearDown teardown; + TearDown teardown; LazyObject::Defaults::instance().forwardFirstNotificationOnly(); @@ -114,7 +114,7 @@ BOOST_AUTO_TEST_CASE(testForwardingNotificationsByDefault) { BOOST_TEST_MESSAGE("Testing that lazy objects can forward all notifications by default..."); - lazy_object_test::TearDown teardown; + TearDown teardown; LazyObject::Defaults::instance().alwaysForwardNotifications(); @@ -139,7 +139,7 @@ BOOST_AUTO_TEST_CASE(testForwardingNotifications) { BOOST_TEST_MESSAGE("Testing that lazy objects can forward all notifications against default..."); - lazy_object_test::TearDown teardown; + TearDown teardown; LazyObject::Defaults::instance().forwardFirstNotificationOnly(); @@ -166,7 +166,7 @@ BOOST_AUTO_TEST_CASE(testNotificationLoop) { BOOST_TEST_MESSAGE("Testing that lazy objects manage recursive notifications..."); - lazy_object_test::TearDown teardown; + TearDown teardown; LazyObject::Defaults::instance().alwaysForwardNotifications(); @@ -204,4 +204,4 @@ BOOST_AUTO_TEST_CASE(testNotificationLoop) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/libormarketmodel.cpp b/test-suite/libormarketmodel.cpp index e6e36a337e3..b5b7f61e1e6 100644 --- a/test-suite/libormarketmodel.cpp +++ b/test-suite/libormarketmodel.cpp @@ -48,7 +48,11 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -namespace libor_market_model_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) // tests for deprecated classes + +BOOST_AUTO_TEST_SUITE(LiborMarketModelTests) + +namespace { ext::shared_ptr makeIndex(std::vector dates, const std::vector& rates) { DayCounter dayCounter = Actual360(); @@ -101,15 +105,9 @@ namespace libor_market_model_test { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) // tests for deprecated classes - -BOOST_AUTO_TEST_SUITE(LiborMarketModelTest) - BOOST_AUTO_TEST_CASE(testSimpleCovarianceModels) { BOOST_TEST_MESSAGE("Testing simple covariance models..."); - using namespace libor_market_model_test; - const Size size = 10; const Real tolerance = 1e-14; Size i; @@ -184,8 +182,6 @@ BOOST_AUTO_TEST_CASE(testSimpleCovarianceModels) { BOOST_AUTO_TEST_CASE(testCapletPricing) { BOOST_TEST_MESSAGE("Testing caplet pricing..."); - using namespace libor_market_model_test; - bool usingAtParCoupons = IborCoupon::Settings::instance().usingAtParCoupons(); const Size size = 10; @@ -234,8 +230,6 @@ BOOST_AUTO_TEST_CASE(testCapletPricing) { BOOST_AUTO_TEST_CASE(testCalibration, *precondition(if_speed(Slow))) { BOOST_TEST_MESSAGE("Testing calibration of a Libor forward model..."); - using namespace libor_market_model_test; - const Size size = 14; const Real tolerance = 8e-3; @@ -338,8 +332,6 @@ BOOST_AUTO_TEST_CASE(testCalibration, *precondition(if_speed(Slow))) { BOOST_AUTO_TEST_CASE(testSwaptionPricing) { BOOST_TEST_MESSAGE("Testing forward swap and swaption pricing..."); - using namespace libor_market_model_test; - bool usingAtParCoupons = IborCoupon::Settings::instance().usingAtParCoupons(); const Size size = 10; @@ -472,4 +464,4 @@ BOOST_AUTO_TEST_CASE(testSwaptionPricing) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/libormarketmodelprocess.cpp b/test-suite/libormarketmodelprocess.cpp index ae35163f4c1..38d000a94f3 100644 --- a/test-suite/libormarketmodelprocess.cpp +++ b/test-suite/libormarketmodelprocess.cpp @@ -35,7 +35,11 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -namespace libor_market_model_process_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(LiborMarketModelProcessTests) + +namespace { Size len = 10; @@ -103,10 +107,6 @@ namespace libor_market_model_process_test { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) // tests for deprecated classes - -BOOST_AUTO_TEST_SUITE(LiborMarketModelProcessTest) - BOOST_AUTO_TEST_CASE(testInitialisation) { BOOST_TEST_MESSAGE("Testing caplet LMM process initialisation..."); @@ -151,8 +151,6 @@ BOOST_AUTO_TEST_CASE(testInitialisation) { BOOST_AUTO_TEST_CASE(testLambdaBootstrapping) { BOOST_TEST_MESSAGE("Testing caplet LMM lambda bootstrapping..."); - using namespace libor_market_model_process_test; - Real tolerance = 1e-10; Volatility lambdaExpected[]= {14.3010297550, 19.3821411939, 15.9816590141, 15.9953118303, 14.0570815635, 13.5687599894, @@ -198,8 +196,6 @@ BOOST_AUTO_TEST_CASE(testLambdaBootstrapping) { BOOST_AUTO_TEST_CASE(testMonteCarloCapletPricing, *precondition(if_speed(Fast))) { BOOST_TEST_MESSAGE("Testing caplet LMM Monte-Carlo caplet pricing..."); - using namespace libor_market_model_process_test; - /* factor loadings are taken from Hull & White article plus extra normalisation to get orthogonal eigenvectors http://www.rotman.utoronto.ca/~amackay/fin/libormktmodel2.pdf */ @@ -331,4 +327,4 @@ BOOST_AUTO_TEST_CASE(testMonteCarloCapletPricing, *precondition(if_speed(Fast))) BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/linearleastsquaresregression.cpp b/test-suite/linearleastsquaresregression.cpp index c600c8ec6e1..99ed8e82aa5 100644 --- a/test-suite/linearleastsquaresregression.cpp +++ b/test-suite/linearleastsquaresregression.cpp @@ -28,9 +28,9 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) -BOOST_AUTO_TEST_SUITE(LinearLeastSquaresRegressionTest) +BOOST_AUTO_TEST_SUITE(LinearLeastSquaresRegressionTests) BOOST_AUTO_TEST_CASE(testRegression) { @@ -105,7 +105,7 @@ BOOST_AUTO_TEST_CASE(testRegression) { } } -namespace linear_least_square_regression_test { +namespace { struct get_item { Size i; @@ -122,8 +122,6 @@ BOOST_AUTO_TEST_CASE(testMultiDimRegression) { BOOST_TEST_MESSAGE( "Testing multi-dimensional linear least-squares regression..."); - using namespace linear_least_square_regression_test; - const Size nr=100000; const Size dims = 4; const Real tolerance = 0.01; @@ -249,4 +247,4 @@ BOOST_AUTO_TEST_CASE(test1dLinearRegression) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/lookbackoptions.cpp b/test-suite/lookbackoptions.cpp index 8a216d5e894..79eaf526181 100644 --- a/test-suite/lookbackoptions.cpp +++ b/test-suite/lookbackoptions.cpp @@ -37,6 +37,10 @@ using namespace QuantLib; using namespace boost::unit_test_framework; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(LookbackOptionTests) + #undef REPORT_FAILURE_FLOATING #define REPORT_FAILURE_FLOATING(greekName, minmax, payoff, exercise, \ s, q, r, today, v, \ @@ -107,10 +111,6 @@ namespace { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(LookbackOptionTest) - BOOST_AUTO_TEST_CASE(testAnalyticContinuousFloatingLookback) { BOOST_TEST_MESSAGE( @@ -662,4 +662,4 @@ BOOST_AUTO_TEST_CASE(testMonteCarloLookback, *precondition(if_speed(Slow))) { BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/lowdiscrepancysequences.cpp b/test-suite/lowdiscrepancysequences.cpp index b9c4f681f60..dfec2fd4459 100644 --- a/test-suite/lowdiscrepancysequences.cpp +++ b/test-suite/lowdiscrepancysequences.cpp @@ -46,9 +46,9 @@ using namespace boost::unit_test_framework; using std::fabs; -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) -BOOST_AUTO_TEST_SUITE(LowDiscrepancyTest) +BOOST_AUTO_TEST_SUITE(LowDiscrepancyTests) BOOST_AUTO_TEST_CASE(testSeedGenerator) { BOOST_TEST_MESSAGE("Testing random-seed generator..."); diff --git a/test-suite/margrabeoption.cpp b/test-suite/margrabeoption.cpp index 4b7ad956bee..99887f2fed2 100644 --- a/test-suite/margrabeoption.cpp +++ b/test-suite/margrabeoption.cpp @@ -29,6 +29,10 @@ using namespace QuantLib; using namespace boost::unit_test_framework; +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(MargrabeOptionTests) + #undef REPORT_FAILURE #define REPORT_FAILURE(greekName, exercise, \ s1, s2, Q1, Q2, q1, q2, r, today, v1, v2, rho, \ @@ -117,10 +121,6 @@ namespace { } -BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) - -BOOST_AUTO_TEST_SUITE(MargrabeOptionTest) - BOOST_AUTO_TEST_CASE(testEuroExchangeTwoAssets) { BOOST_TEST_MESSAGE("Testing European one-asset-for-another option..."); @@ -553,4 +553,4 @@ BOOST_AUTO_TEST_CASE(testAmericanExchangeTwoAssets) { } BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/marketmodel_cms.cpp b/test-suite/marketmodel_cms.cpp index ae18fbe77f0..833dff01bbd 100644 --- a/test-suite/marketmodel_cms.cpp +++ b/test-suite/marketmodel_cms.cpp @@ -52,7 +52,11 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -namespace market_model_cms_test { +BOOST_FIXTURE_TEST_SUITE(QuantLibTests, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(MarketModelCmsTests) + +namespace { Date todaysDate, startDate, endDate; std::vector