Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FpeMonitorTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FpeMonitorTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2022 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #include <boost/test/unit_test.hpp>
10 
11 #include "Acts/Utilities/FpeMonitor.hpp"
12 
13 #include <cmath>
14 #include <cstdio>
15 #include <iostream>
16 #include <limits>
17 
18 namespace utf = boost::unit_test;
19 
20 namespace Acts::Test {
21 
22 BOOST_AUTO_TEST_SUITE(FpeMonitorTest)
23 
24 #if defined(_FE_INVALID)
26  {
27  FpeMonitor mon;
28  volatile const double x = -1;
29  printf("y = %f\n", std::sqrt(x));
30  }
31 }
32 #endif
33 
34 #if defined(_FE_DIVBYZERO)
35 BOOST_AUTO_TEST_CASE(DivByZero) {
36  {
37  FpeMonitor mon;
38  volatile double z = 0;
39  volatile double x = 1 / z;
40  std::cout << "x: " << x << std::endl;
41  }
42 }
43 #endif
44 
45 #if defined(_FE_OVERFLOW)
46 BOOST_AUTO_TEST_CASE(Overflow) {
47  {
48  FpeMonitor mon;
49  volatile float v = 0;
50  volatile double w = std::numeric_limits<double>::max();
51  v = 2 * w;
52  std::cout << v << std::endl;
53  }
54 }
55 #endif
56 
57 BOOST_AUTO_TEST_SUITE_END()
58 
59 } // namespace Acts::Test