GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 0.0% 0 / 0 / 6
Functions: 0.0% 0 / 0 / 1
Branches: 0.0% 0 / 0 / 19

src/utilities/core/Assert.hpp
Line Branch Exec Source
1 /***********************************************************************************************************************
2 * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC.
3 * See also https://openstudio.net/license
4 ***********************************************************************************************************************/
5
6 #ifndef UTILITIES_CORE_ASSERT_HPP
7 #define UTILITIES_CORE_ASSERT_HPP
8
9 /****************************************************************************
10 !!! THIS FILE MUST BE INCLUDED BY ANY SOURCE FILE THAT USES OPENSTUDIO_ASSERT!!!
11 !!! THIS FILE MUST BE INCLUDED BY ANY SOURCE FILE THAT USES BOOST_ASSERT!!!
12 *****************************************************************************/
13
14 #include "../UtilitiesAPI.hpp"
15 #include "Logger.hpp"
16
17 #include <sstream>
18
19 #define OS_ASSERT(expr) BOOST_ASSERT(expr)
20
21 #ifdef NDEBUG
22 //#define BOOST_DISABLE_ASSERTS
23 # define BOOST_ENABLE_ASSERT_HANDLER
24 #else
25 # define BOOST_ENABLE_ASSERT_HANDLER
26 #endif
27
28 // include after definitions
29 #include <boost/assert.hpp>
30
31 namespace boost {
32 ✗ inline void assertion_failed(char const* expr, char const* function, char const* file, long line) {
33 ✗ std::stringstream ss;
34 ✗ ss << "Assertion " << expr << " failed on line " << line << " of " << function << " in file " << file << ".";
35 ✗ openstudio::Logger::instance().standardErrLogger().enable();
36 ✗ LOG_FREE(Fatal, "BOOST_ASSERT", ss.str());
37 assert(false);
38 ✗ }
39
40 inline void assertion_failed_msg(char const* expr, char const* msg, char const* function, char const* file, long line) {
41 std::stringstream ss;
42 ss << "Assertion " << expr << " failed on line " << line << " of " << function << " in file " << file << "." << '\n' << msg;
43 openstudio::Logger::instance().standardErrLogger().enable();
44 LOG_FREE(Fatal, "BOOST_ASSERT", ss.str());
45 assert(false);
46 }
47 } // namespace boost
48
49 #endif // UTILITIES_CORE_ASSERT_HPP
50