diff --git a/test-suite/CMakeLists.txt b/test-suite/CMakeLists.txt index b36bb5dbe23..3d9a1050d39 100644 --- a/test-suite/CMakeLists.txt +++ b/test-suite/CMakeLists.txt @@ -174,7 +174,6 @@ set(QL_TEST_SOURCES ) set(QL_TEST_HEADERS - lowdiscrepancysequences.hpp margrabeoption.hpp marketmodel.hpp marketmodel_cms.hpp @@ -269,8 +268,8 @@ set(QL_BENCHMARK_SOURCES fdheston.cpp hestonmodel.cpp interpolations.cpp - jumpdiffusion.cpp - lowdiscrepancysequences.cpp lowdiscrepancysequences.hpp + jumpdiffusion.cpp + lowdiscrepancysequences.cpp marketmodel_cms.cpp marketmodel_cms.hpp marketmodel_smm.cpp marketmodel_smm.hpp quantooption.cpp quantooption.hpp diff --git a/test-suite/Makefile.am b/test-suite/Makefile.am index fa5bd15da43..03f366045df 100644 --- a/test-suite/Makefile.am +++ b/test-suite/Makefile.am @@ -174,7 +174,6 @@ QL_TEST_SRCS = \ zerocouponswap.cpp QL_TEST_HDRS = \ - lowdiscrepancysequences.hpp \ margrabeoption.hpp \ marketmodel.hpp \ marketmodel_cms.hpp \ @@ -281,7 +280,6 @@ QL_BENCHMARK_SRCS = \ utilities.cpp QL_BENCHMARK_HDRS = \ - lowdiscrepancysequences.hpp \ marketmodel_cms.hpp \ marketmodel_smm.hpp \ quantlibglobalfixture.hpp \ diff --git a/test-suite/lowdiscrepancysequences.cpp b/test-suite/lowdiscrepancysequences.cpp index 122bc5fff39..5d161b03c93 100644 --- a/test-suite/lowdiscrepancysequences.cpp +++ b/test-suite/lowdiscrepancysequences.cpp @@ -18,7 +18,7 @@ FOR A PARTICULAR PURPOSE. See the license for more details. */ -#include "lowdiscrepancysequences.hpp" +#include "toplevelfixture.hpp" #include "utilities.hpp" #include #include @@ -44,12 +44,16 @@ using namespace boost::unit_test_framework; using std::fabs; -void LowDiscrepancyTest::testSeedGenerator() { +BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture) + +BOOST_AUTO_TEST_SUITE(LowDiscrepancyTest) + +BOOST_AUTO_TEST_CASE(testSeedGenerator) { BOOST_TEST_MESSAGE("Testing random-seed generator..."); SeedGenerator::instance().get(); } -void LowDiscrepancyTest::testPolynomialsModuloTwo() { +BOOST_AUTO_TEST_CASE(testPolynomialsModuloTwo) { BOOST_TEST_MESSAGE("Testing " << PPMT_MAX_DIM << " primitive polynomials modulo two..."); @@ -82,7 +86,7 @@ void LowDiscrepancyTest::testPolynomialsModuloTwo() { } -void LowDiscrepancyTest::testRandomizedLowDiscrepancySequence() { +BOOST_AUTO_TEST_CASE(testRandomizedLowDiscrepancySequence) { BOOST_TEST_MESSAGE("Testing randomized low-discrepancy sequences up to " "dimension " << PPMT_MAX_DIM << "..."); @@ -165,18 +169,15 @@ namespace } } +BOOST_AUTO_TEST_CASE(testRandomizedLattices){ -void LowDiscrepancyTest::testRandomizedLattices() -{ testRandomizedLatticeRule(LatticeRule::A, "A"); testRandomizedLatticeRule(LatticeRule::B, "B"); testRandomizedLatticeRule(LatticeRule::C, "C"); testRandomizedLatticeRule(LatticeRule::D, "D"); - } - -void LowDiscrepancyTest::testSobol() { +BOOST_AUTO_TEST_CASE(testSobol) { BOOST_TEST_MESSAGE("Testing Sobol sequences up to dimension " << PPMT_MAX_DIM << "..."); @@ -260,7 +261,7 @@ void LowDiscrepancyTest::testSobol() { } } -void LowDiscrepancyTest::testFaure() { +BOOST_AUTO_TEST_CASE(testFaure) { BOOST_TEST_MESSAGE("Testing Faure sequences..."); @@ -409,7 +410,7 @@ void LowDiscrepancyTest::testFaure() { } } -void LowDiscrepancyTest::testHalton() { +BOOST_AUTO_TEST_CASE(testHalton) { BOOST_TEST_MESSAGE("Testing Halton sequences..."); @@ -883,8 +884,7 @@ namespace { } - -void LowDiscrepancyTest::testMersenneTwisterDiscrepancy() { +BOOST_AUTO_TEST_CASE(testMersenneTwisterDiscrepancy) { BOOST_TEST_MESSAGE("Testing Mersenne-twister discrepancy..."); @@ -901,7 +901,7 @@ void LowDiscrepancyTest::testMersenneTwisterDiscrepancy() { "DiscrMersenneTwis"); } -void LowDiscrepancyTest::testPlainHaltonDiscrepancy() { +BOOST_AUTO_TEST_CASE(testPlainHaltonDiscrepancy) { BOOST_TEST_MESSAGE("Testing plain Halton discrepancy..."); @@ -917,7 +917,7 @@ void LowDiscrepancyTest::testPlainHaltonDiscrepancy() { "DiscrPlain_Halton"); } -void LowDiscrepancyTest::testRandomStartHaltonDiscrepancy() { +BOOST_AUTO_TEST_CASE(testRandomStartHaltonDiscrepancy) { BOOST_TEST_MESSAGE("Testing random-start Halton discrepancy..."); @@ -933,7 +933,7 @@ void LowDiscrepancyTest::testRandomStartHaltonDiscrepancy() { "DiscrRStartHalton"); } -void LowDiscrepancyTest::testRandomShiftHaltonDiscrepancy() { +BOOST_AUTO_TEST_CASE(testRandomShiftHaltonDiscrepancy) { BOOST_TEST_MESSAGE("Testing random-shift Halton discrepancy..."); @@ -949,7 +949,7 @@ void LowDiscrepancyTest::testRandomShiftHaltonDiscrepancy() { "DiscrRShiftHalton"); } -void LowDiscrepancyTest::testRandomStartRandomShiftHaltonDiscrepancy() { +BOOST_AUTO_TEST_CASE(testRandomStartRandomShiftHaltonDiscrepancy) { BOOST_TEST_MESSAGE("Testing random-start, random-shift Halton discrepancy..."); @@ -965,7 +965,7 @@ void LowDiscrepancyTest::testRandomStartRandomShiftHaltonDiscrepancy() { "DiscrRStRShHalton"); } -void LowDiscrepancyTest::testJackelSobolDiscrepancy() { +BOOST_AUTO_TEST_CASE(testJackelSobolDiscrepancy) { BOOST_TEST_MESSAGE("Testing Jaeckel-Sobol discrepancy..."); @@ -981,7 +981,7 @@ void LowDiscrepancyTest::testJackelSobolDiscrepancy() { "DiscrJackel_Sobol"); } -void LowDiscrepancyTest::testSobolLevitanSobolDiscrepancy() { +BOOST_AUTO_TEST_CASE(testSobolLevitanSobolDiscrepancy) { BOOST_TEST_MESSAGE("Testing Levitan-Sobol discrepancy..."); @@ -997,7 +997,7 @@ void LowDiscrepancyTest::testSobolLevitanSobolDiscrepancy() { "DiscrSobLev_Sobol"); } -void LowDiscrepancyTest::testSobolLevitanLemieuxSobolDiscrepancy() { +BOOST_AUTO_TEST_CASE(testSobolLevitanLemieuxSobolDiscrepancy) { BOOST_TEST_MESSAGE("Testing Levitan-Lemieux-Sobol discrepancy..."); @@ -1013,7 +1013,7 @@ void LowDiscrepancyTest::testSobolLevitanLemieuxSobolDiscrepancy() { "DiscrSobLevLem_Sobol"); } -void LowDiscrepancyTest::testUnitSobolDiscrepancy() { +BOOST_AUTO_TEST_CASE(testUnitSobolDiscrepancy) { BOOST_TEST_MESSAGE("Testing unit Sobol discrepancy..."); @@ -1026,8 +1026,7 @@ void LowDiscrepancyTest::testUnitSobolDiscrepancy() { "Discr__Unit_Sobol"); } - -void LowDiscrepancyTest::testSobolSkipping() { +BOOST_AUTO_TEST_CASE(testSobolSkipping) { BOOST_TEST_MESSAGE("Testing Sobol sequence skipping..."); @@ -1070,47 +1069,6 @@ void LowDiscrepancyTest::testSobolSkipping() { } } +BOOST_AUTO_TEST_SUITE_END() -test_suite* LowDiscrepancyTest::suite() { - auto* suite = BOOST_TEST_SUITE("Low-discrepancy sequence tests"); - - suite->add(QUANTLIB_TEST_CASE( - &LowDiscrepancyTest::testRandomizedLattices)); - - - suite->add(QUANTLIB_TEST_CASE( - &LowDiscrepancyTest::testSeedGenerator)); - - suite->add(QUANTLIB_TEST_CASE( - &LowDiscrepancyTest::testPolynomialsModuloTwo)); - - suite->add(QUANTLIB_TEST_CASE(&LowDiscrepancyTest::testSobol)); - suite->add(QUANTLIB_TEST_CASE(&LowDiscrepancyTest::testHalton)); - suite->add(QUANTLIB_TEST_CASE(&LowDiscrepancyTest::testFaure)); - - suite->add(QUANTLIB_TEST_CASE( - &LowDiscrepancyTest::testMersenneTwisterDiscrepancy)); - suite->add(QUANTLIB_TEST_CASE( - &LowDiscrepancyTest::testPlainHaltonDiscrepancy)); - suite->add(QUANTLIB_TEST_CASE( - &LowDiscrepancyTest::testRandomStartHaltonDiscrepancy)); - suite->add(QUANTLIB_TEST_CASE( - &LowDiscrepancyTest::testRandomShiftHaltonDiscrepancy)); - suite->add(QUANTLIB_TEST_CASE( - &LowDiscrepancyTest::testRandomStartRandomShiftHaltonDiscrepancy)); - suite->add(QUANTLIB_TEST_CASE( - &LowDiscrepancyTest::testUnitSobolDiscrepancy)); - suite->add(QUANTLIB_TEST_CASE( - &LowDiscrepancyTest::testJackelSobolDiscrepancy)); - suite->add(QUANTLIB_TEST_CASE( - &LowDiscrepancyTest::testSobolLevitanSobolDiscrepancy)); - suite->add(QUANTLIB_TEST_CASE( - &LowDiscrepancyTest::testSobolLevitanLemieuxSobolDiscrepancy)); - - suite->add(QUANTLIB_TEST_CASE(&LowDiscrepancyTest::testSobolSkipping)); - - suite->add(QUANTLIB_TEST_CASE( - &LowDiscrepancyTest::testRandomizedLowDiscrepancySequence)); - - return suite; -} +BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file diff --git a/test-suite/lowdiscrepancysequences.hpp b/test-suite/lowdiscrepancysequences.hpp deleted file mode 100644 index 5c4832ff00f..00000000000 --- a/test-suite/lowdiscrepancysequences.hpp +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ - -/* - Copyright (C) 2003, 2004 Ferdinando Ametrano - - This file is part of QuantLib, a free-software/open-source library - for financial quantitative analysts and developers - http://quantlib.org/ - - QuantLib is free software: you can redistribute it and/or modify it - under the terms of the QuantLib license. You should have received a - copy of the license along with this program; if not, please email - . The license is also available online at - . - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the license for more details. -*/ - -#ifndef quantlib_test_lowdiscrepancysequences_hpp -#define quantlib_test_lowdiscrepancysequences_hpp - -#include - -/* remember to document new and/or updated tests in the Doxygen - comment block of the corresponding class */ - -class LowDiscrepancyTest { - public: - static void testSeedGenerator(); - - static void testPolynomialsModuloTwo(); - - static void testSobol(); - static void testHalton(); - static void testFaure(); - - static void testMersenneTwisterDiscrepancy(); - static void testPlainHaltonDiscrepancy(); - static void testRandomStartHaltonDiscrepancy(); - static void testRandomShiftHaltonDiscrepancy(); - static void testRandomStartRandomShiftHaltonDiscrepancy(); - static void testJackelSobolDiscrepancy(); - static void testSobolLevitanSobolDiscrepancy(); - static void testSobolLevitanLemieuxSobolDiscrepancy(); - static void testUnitSobolDiscrepancy(); - - static void testRandomizedLowDiscrepancySequence(); - - static void testSobolSkipping(); - - static void testRandomizedLattices(); - - static boost::unit_test_framework::test_suite* suite(); -}; - - -#endif diff --git a/test-suite/quantlibbenchmark.cpp b/test-suite/quantlibbenchmark.cpp index 094c52a656b..719e75bc3b9 100644 --- a/test-suite/quantlibbenchmark.cpp +++ b/test-suite/quantlibbenchmark.cpp @@ -139,7 +139,6 @@ #include "utilities.hpp" #include "marketmodel_smm.hpp" #include "marketmodel_cms.hpp" -#include "lowdiscrepancysequences.hpp" #include "quantooption.hpp" #include "riskstats.hpp" #include "shortratemodels.hpp" @@ -224,6 +223,11 @@ namespace QuantLibTest { struct testGreeks: public BOOST_AUTO_TEST_CASE_FIXTURE { void test_method(); }; } + + namespace LowDiscrepancyTest { + struct testMersenneTwisterDiscrepancy: + public BOOST_AUTO_TEST_CASE_FIXTURE { void test_method(); }; + } } namespace { @@ -276,7 +280,7 @@ namespace { Benchmark("MarketModelCmsTest::testCmSwapsSwaptions", &MarketModelCmsTest::testMultiStepCmSwapsAndSwaptions, 11497.73), Benchmark("MarketModelSmmTest::testMultiSmmSwaptions", &MarketModelSmmTest::testMultiStepCoterminalSwapsAndSwaptions, 11244.95), Benchmark("QuantoOption::ForwardGreeks", &QuantoOptionTest::testForwardGreeks, 90.98), - Benchmark("RandomNumber::MersenneTwisterDescrepancy", &LowDiscrepancyTest::testMersenneTwisterDiscrepancy, 951.98), + Benchmark("RandomNumber::MersenneTwisterDescrepancy", std::bind(&QuantLibTest::LowDiscrepancyTest::testMersenneTwisterDiscrepancy::test_method, QuantLibTest::LowDiscrepancyTest::testMersenneTwisterDiscrepancy()), 951.98), Benchmark("RiskStatistics::Results", &RiskStatisticsTest::testResults, 300.28), Benchmark("ShortRateModel::Swaps", &ShortRateModelTest::testSwaps, 454.73) }; diff --git a/test-suite/quantlibtestsuite.cpp b/test-suite/quantlibtestsuite.cpp index c80dfef0bd7..e4325835cda 100644 --- a/test-suite/quantlibtestsuite.cpp +++ b/test-suite/quantlibtestsuite.cpp @@ -18,10 +18,8 @@ FOR A PARTICULAR PURPOSE. See the license for more details. */ -#include #include #include -#include #ifdef QL_ENABLE_PARALLEL_UNIT_TEST_RUNNER #include "paralleltestrunner.hpp" @@ -36,7 +34,6 @@ # include #endif -#include "lowdiscrepancysequences.hpp" #include "margrabeoption.hpp" #include "marketmodel.hpp" #include "marketmodel_cms.hpp" @@ -101,7 +98,6 @@ #include "twoassetbarrieroption.hpp" #include "twoassetcorrelationoption.hpp" #include "ultimateforwardtermstructure.hpp" -#include "utilities.hpp" #include "variancegamma.hpp" #include "varianceoption.hpp" #include "varianceswaps.hpp" @@ -110,9 +106,6 @@ #include "xoshiro256starstar.hpp" #include "zabr.hpp" #include "zerocouponswap.hpp" -#include -#include -#include using namespace boost::unit_test_framework; @@ -145,7 +138,6 @@ test_suite* init_unit_test_suite(int, char* []) { auto* test = BOOST_TEST_SUITE("QuantLib test suite"); - test->add(LowDiscrepancyTest::suite()); test->add(MargrabeOptionTest::suite()); test->add(MarketModelTest::suite(speed)); test->add(MarketModelCmsTest::suite(speed)); diff --git a/test-suite/testsuite.vcxproj b/test-suite/testsuite.vcxproj index f818e3c5bd9..9e7bd99060d 100644 --- a/test-suite/testsuite.vcxproj +++ b/test-suite/testsuite.vcxproj @@ -810,7 +810,6 @@ - diff --git a/test-suite/testsuite.vcxproj.filters b/test-suite/testsuite.vcxproj.filters index e194b2d8fed..8b822d4a34b 100644 --- a/test-suite/testsuite.vcxproj.filters +++ b/test-suite/testsuite.vcxproj.filters @@ -527,9 +527,6 @@ - - Header Files - Header Files