Testing.cxx
Go to the documentation of this file.
1 #include "WireCellUtil/Testing.h"
3 #include "WireCellUtil/Logging.h"
4 
5 #include <sstream>
6 
7 using namespace WireCell;
8 
9 void boost::assertion_failed_msg(char const * expr, char const * msg,
10  char const * function, char const * file, long line)
11 {
12  spdlog::critical("{}:{}:{} {} {}", file, function, line, expr, msg or "");
13 
14  std::stringstream ss;
15  ss << "WireCell::AssertionError: \"" << expr << "\" in " << function << " " << file << ":" << line;
16  if (msg and msg[0]) {
17  ss << "\n" << msg;
18  }
19  THROW(AssertionError() << errmsg{ss.str()});
20 }
21 
22 void boost::assertion_failed(char const * expr, char const * function, char const * file, long line)
23 {
24  boost::assertion_failed_msg(expr, "", function, file, line);
25 }
26 
27 
28 void Testing::log(const char* argv0)
29 {
30  std::string name = argv0;
31  name += ".log";
32  Log::add_stderr(true, "trace");
33  Log::add_file(name, "trace");
34 }
static QCString name
Definition: declinfo.cpp:673
Definition: posix.h:188
void msg(const char *fmt,...)
Definition: message.cpp:107
std::string string
Definition: nybbler.cc:12
boost::error_info< struct tag_errmsg, std::string > errmsg
Definition: Exceptions.h:54
void log(const char *argv0)
Definition: Testing.cxx:28
void critical(const char *fmt, const Args &...args)
Definition: spdlog.h:207
void assertion_failed_msg(char const *expr, char const *msg, char const *function, char const *file, long line)
Definition: Testing.cxx:9
void add_stderr(bool color=true, std::string level="")
Definition: Logging.cxx:59
#define THROW(e)
Definition: Exceptions.h:25
Definition: Main.h:22
void add_file(std::string filename, std::string level="")
Definition: Logging.cxx:42
void assertion_failed(char const *expr, char const *function, char const *file, long line)
Definition: Testing.cxx:22
Thrown when an assertion fails.
Definition: Exceptions.h:52