Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
testsuite.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19#include <iomanip>
20#include <iostream>
21#include <oret/config.hpp>
22
23// Boost
24#include <boost/make_shared.hpp>
25#include <boost/timer/timer.hpp>
26using boost::timer::cpu_timer;
27
28// Boost.Test
29#define BOOST_TEST_MODULE "OREAnalyticsTestSuite"
30#ifdef ORE_ENABLE_PARALLEL_UNIT_TEST_RUNNER
31#include <test-suite/paralleltestrunner.hpp>
32#else
33#include <boost/test/included/unit_test.hpp>
34#endif
35#include <boost/test/parameterized_test.hpp>
36#include <boost/test/test_tools.hpp>
37using boost::unit_test::test_suite;
38using boost::unit_test::framework::master_test_suite;
39
40#include <oret/basedatapath.hpp>
41#include <oret/datapaths.hpp>
42#include <oret/oret.hpp>
43using ore::test::getBaseDataPath;
44using ore::test::setupTestLogging;
45
46#ifdef BOOST_MSVC
47#include <orea/auto_link.hpp>
48#include <ored/auto_link.hpp>
49#include <ql/auto_link.hpp>
50#include <qle/auto_link.hpp>
51#define BOOST_LIB_NAME boost_serialization
52#include <boost/config/auto_link.hpp>
53#define BOOST_LIB_NAME boost_regex
54#include <boost/config/auto_link.hpp>
55#define BOOST_LIB_NAME boost_timer
56#include <boost/config/auto_link.hpp>
57#define BOOST_LIB_NAME boost_chrono
58#include <boost/config/auto_link.hpp>
59#endif
60
61// Global base path variable
62string basePath = "";
63
64class OreaGlobalFixture {
65public:
66 OreaGlobalFixture() {
67 int argc = master_test_suite().argc;
68 char** argv = master_test_suite().argv;
69
70 // Set up test logging
71 setupTestLogging(argc, argv);
72
73 // Set the base data path for the unit tests
74 basePath = getBaseDataPath(argc, argv);
75 }
76
77 ~OreaGlobalFixture() { stopTimer(); }
78
79 // Method called in destructor to log time taken
80 void stopTimer() {
81 t.stop();
82 double seconds = t.elapsed().wall * 1e-9;
83 int hours = int(seconds / 3600);
84 seconds -= hours * 3600;
85 int minutes = int(seconds / 60);
86 seconds -= minutes * 60;
87 std::cout << std::endl << "OREData tests completed in ";
88 if (hours > 0)
89 std::cout << hours << " h ";
90 if (hours > 0 || minutes > 0)
91 std::cout << minutes << " m ";
92 std::cout << std::fixed << std::setprecision(0) << seconds << " s" << std::endl;
93 }
94
95private:
96 // Timing the test run
97 cpu_timer t;
98};
99
100// Breaking change in 1.65.0
101// https://www.boost.org/doc/libs/1_65_0/libs/test/doc/html/boost_test/change_log.html
102// Deprecating BOOST_GLOBAL_FIXTURE in favor of BOOST_TEST_GLOBAL_FIXTURE
103#if BOOST_VERSION < 106500
104BOOST_GLOBAL_FIXTURE(OreaGlobalFixture);
105#else
106BOOST_TEST_GLOBAL_FIXTURE(OreaGlobalFixture);
107#endif