|
@@ -43,72 +43,45 @@ namespace libtest {
|
|
|
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
|
|
|
|
|
fatal::fatal(const char *file_arg, int line_arg, const char *func_arg, ...) :
|
|
|
- __test_result(file_arg, line_arg, func_arg),
|
|
|
- _error_message(NULL),
|
|
|
- _error_message_size(0)
|
|
|
+ __test_result(file_arg, line_arg, func_arg)
|
|
|
{
|
|
|
va_list args;
|
|
|
va_start(args, func_arg);
|
|
|
- const char *format= va_arg(args, const char *);
|
|
|
- _error_message_size= vasprintf(&_error_message, format, args);
|
|
|
- assert(_error_message_size != -1);
|
|
|
- if (_error_message_size > 0)
|
|
|
- {
|
|
|
- _error_message_size++;
|
|
|
- }
|
|
|
+ init(args);
|
|
|
va_end(args);
|
|
|
}
|
|
|
|
|
|
fatal::fatal( const fatal& other ) :
|
|
|
- __test_result(other),
|
|
|
- _error_message_size(other._error_message_size)
|
|
|
-{
|
|
|
- _error_message= (char*) malloc(_error_message_size);
|
|
|
- if (_error_message)
|
|
|
- {
|
|
|
- memcpy(_error_message, other._error_message, _error_message_size);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- _error_message_size= -1;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-fatal::~fatal() throw()
|
|
|
+ __test_result(other)
|
|
|
{
|
|
|
- if ((_error_message_size > 0) and _error_message)
|
|
|
- {
|
|
|
- free(_error_message);
|
|
|
- _error_message= NULL;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
static bool _disabled= false;
|
|
|
static uint32_t _counter= 0;
|
|
|
|
|
|
-bool fatal::is_disabled()
|
|
|
+bool fatal::is_disabled() throw()
|
|
|
{
|
|
|
return _disabled;
|
|
|
}
|
|
|
|
|
|
-void fatal::disable()
|
|
|
+void fatal::disable() throw()
|
|
|
{
|
|
|
_counter= 0;
|
|
|
_disabled= true;
|
|
|
}
|
|
|
|
|
|
-void fatal::enable()
|
|
|
+void fatal::enable() throw()
|
|
|
{
|
|
|
_counter= 0;
|
|
|
_disabled= false;
|
|
|
}
|
|
|
|
|
|
-uint32_t fatal::disabled_counter()
|
|
|
+uint32_t fatal::disabled_counter() throw()
|
|
|
{
|
|
|
return _counter;
|
|
|
}
|
|
|
|
|
|
-void fatal::increment_disabled_counter()
|
|
|
+void fatal::increment_disabled_counter() throw()
|
|
|
{
|
|
|
_counter++;
|
|
|
}
|
|
@@ -132,4 +105,15 @@ disconnected::disconnected(const char *file_arg, int line_arg, const char *func_
|
|
|
snprintf(_error_message, sizeof(_error_message), "%s:%u %s", instance.c_str(), uint32_t(port), last_error);
|
|
|
}
|
|
|
|
|
|
+disconnected::disconnected(const disconnected& other):
|
|
|
+ std::runtime_error(other._func),
|
|
|
+ _port(other._port),
|
|
|
+ _line(other._line),
|
|
|
+ _file(other._file),
|
|
|
+ _func(other._func)
|
|
|
+{
|
|
|
+ strncpy(_error_message, other._error_message, BUFSIZ);
|
|
|
+ strncpy(_instance, other._instance, BUFSIZ);
|
|
|
+}
|
|
|
+
|
|
|
} // namespace libtest
|