Classes | Namespaces | Functions
FloatingPointControl_t.cc File Reference
#include "catch2/catch.hpp"
#include "art/Framework/Services/Registry/ActivityRegistry.h"
#include "art/Framework/Services/System/FloatingPointControl.h"
#include "art/Framework/Services/System/detail/fpControl.h"
#include "messagefacility/plugins/stringstream.h"
#include <sstream>
#include <string>
#include <type_traits>

Go to the source code of this file.

Classes

struct  Catch::StringMaker< Hexable< T > >
 

Namespaces

 Catch
 

Functions

 SCENARIO ("We wish to affect the floating point control on our system")
 

Function Documentation

SCENARIO ( "We wish to affect the floating point control on our system"  )

Definition at line 86 of file FloatingPointControl_t.cc.

87 {
88  GIVEN("An empty activity registry and simple parameter set")
89  {
91 
93  ps.put("reportSettings", true);
94 
95  // Note config above sends output to stream we can capture:
96  auto& tstream = mf::getStringStream("TSTREAM_1");
97  tstream.str("");
98 
99  auto const fpcw_def = getFPCW();
100  auto const fpcw_ref = fpcw_def;
101  auto const fpcw_ref_dp =
102  (fpcw_ref & ~fpControl_ALL_PREC) | fpControl_DOUBLE_PREC;
103 
104  static auto verify_cleanup = [fpcw_def, &reg](auto& fpc) {
105  reg.sPostEndJob.invoke();
106  compare_fpcw(fpc, fpcw_def, "Checking final FP state against default"s);
107  };
108 
109  WHEN("We want the basic configuration")
110  {
111  art::FloatingPointControl fpc(ps, reg);
112  THEN("The configuration is unchanged except for double precision math.")
113  {
114  compare_fpcw(fpc, fpcw_ref_dp);
115  verify_report(tstream);
116  verify_cleanup(fpc);
117  }
118  }
119 
120  WHEN("We want to suppress divide-by-zero exceptions")
121  {
122  ps.put("enableDivByZeroEx", true);
123  art::FloatingPointControl fpc(ps, reg);
124  THEN("The configuration shows suppressed divide-by-zero exceptions")
125  {
126  compare_fpcw(fpc, fpcw_ref_dp & ~FE_DIVBYZERO);
127  verify_report(tstream, FE_DIVBYZERO);
128  verify_cleanup(fpc);
129  }
130  }
131 
132  WHEN("We want to suppress \"invalid\" exceptions")
133  {
134  ps.put("enableInvalidEx", true);
135  art::FloatingPointControl fpc(ps, reg);
136  THEN("The configuration shows suppressed \"invalid\" exceptions")
137  {
138  compare_fpcw(fpc, fpcw_ref_dp & ~FE_INVALID);
139  verify_report(tstream, FE_INVALID);
140  verify_cleanup(fpc);
141  }
142  }
143 
144  WHEN("We want to suppress overflow exceptions")
145  {
146  ps.put("enableOverFlowEx", true);
147  art::FloatingPointControl fpc(ps, reg);
148  THEN("The configuration shows suppressed overflow exceptions")
149  {
150  compare_fpcw(fpc, fpcw_ref_dp & ~FE_OVERFLOW);
151  verify_report(tstream, FE_OVERFLOW);
152  verify_cleanup(fpc);
153  }
154  }
155 
156  WHEN("We want to suppress underflow exceptions")
157  {
158  ps.put("enableUnderFlowEx", true);
159  art::FloatingPointControl fpc(ps, reg);
160  THEN("The configuration shows suppressed underflow exceptions")
161  {
162  compare_fpcw(fpc, fpcw_ref_dp & ~FE_UNDERFLOW);
163  verify_report(tstream, FE_UNDERFLOW);
164  verify_cleanup(fpc);
165  }
166  }
167 
168  WHEN("We want default precision")
169  {
170  ps.put("setPrecisionDouble", false);
171  art::FloatingPointControl fpc(ps, reg);
172  THEN("The configuration shows default precision")
173  {
174  compare_fpcw(fpc, fpcw_ref);
175  verify_report(tstream);
176  verify_cleanup(fpc);
177  }
178  }
179  }
180 }
GlobalSignal< detail::SignalResponseType::LIFO, void()> sPostEndJob
std::ostringstream & getStringStream(std::string const &psetName)
Definition: stringstream.cc:15
static constexpr double ps
Definition: Units.h:99
fpcw_t getFPCW()
Definition: fpControl.cc:28
cet::registry_via_id< success_t, val > reg
static QCString * s
Definition: config.cpp:1042
void put(std::string const &key)