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>
21using namespace std;
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 OREDataTestSuite
30#include <boost/test/unit_test.hpp>
31using boost::unit_test::test_suite;
32using boost::unit_test::framework::master_test_suite;
33
34#include <oret/basedatapath.hpp>
35#include <oret/datapaths.hpp>
36#include <oret/oret.hpp>
37using ore::test::getBaseDataPath;
38using ore::test::setupTestLogging;
39
40#ifdef BOOST_MSVC
41#include <ored/auto_link.hpp>
42#include <ql/auto_link.hpp>
43#include <qle/auto_link.hpp>
44#define BOOST_LIB_NAME boost_date_time
45#include <boost/config/auto_link.hpp>
46#define BOOST_LIB_NAME boost_serialization
47#include <boost/config/auto_link.hpp>
48#define BOOST_LIB_NAME boost_regex
49#include <boost/config/auto_link.hpp>
50#define BOOST_LIB_NAME boost_timer
51#include <boost/config/auto_link.hpp>
52#define BOOST_LIB_NAME boost_chrono
53#include <boost/config/auto_link.hpp>
54#endif
55
56// Global base path variable
57string basePath = "";
58
59class OredGlobalFixture {
60public:
61 OredGlobalFixture() {
62 int argc = master_test_suite().argc;
63 char** argv = master_test_suite().argv;
64
65 // Set up test logging
66 setupTestLogging(argc, argv);
67
68 // Set the base data path for the unit tests
69 basePath = getBaseDataPath(argc, argv);
70 }
71
72 ~OredGlobalFixture() { stopTimer(); }
73
74 // Method called in destructor to log time taken
75 void stopTimer() {
76 t.stop();
77 double seconds = t.elapsed().wall * 1e-9;
78 int hours = int(seconds / 3600);
79 seconds -= hours * 3600;
80 int minutes = int(seconds / 60);
81 seconds -= minutes * 60;
82 cout << endl << "OREData tests completed in ";
83 if (hours > 0)
84 cout << hours << " h ";
85 if (hours > 0 || minutes > 0)
86 cout << minutes << " m ";
87 cout << fixed << setprecision(0) << seconds << " s" << endl;
88 }
89
90private:
91 // Timing the test run
92 cpu_timer t;
93};
94
95// Breaking change in 1.65.0
96// https://www.boost.org/doc/libs/1_65_0/libs/test/doc/html/boost_test/change_log.html
97// Deprecating BOOST_GLOBAL_FIXTURE in favor of BOOST_TEST_GLOBAL_FIXTURE
98#if BOOST_VERSION < 106500
99BOOST_GLOBAL_FIXTURE(OredGlobalFixture);
100#else
101BOOST_TEST_GLOBAL_FIXTURE(OredGlobalFixture);
102#endif