~brianaker/libmemcached/merge-of-1.0

« back to all changes in this revision

Viewing changes to libtest/result.cc

  • Committer: Brian Aker
  • Date: 2013-05-04 09:20:42 UTC
  • mfrom: (1079.30.26 libmemcached-1.0)
  • mto: This revision was merged to the branch mainline in revision 1103.
  • Revision ID: brian@tangent.org-20130504092042-tuaolr38te8qhwmu
Mergre 1.0 tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
namespace libtest {
42
42
 
43
43
__test_result::__test_result(const char *file_arg, int line_arg, const char *func_arg):
44
 
  _line(line_arg),
45
 
  _file(file_arg),
46
 
  _func(func_arg),
47
 
  _error_message(NULL),
48
 
  _error_message_size(0)
49
 
{
50
 
}
51
 
 
52
 
#ifndef __INTEL_COMPILER
53
 
# pragma GCC diagnostic ignored "-Wformat-nonliteral"
54
 
#endif
55
 
void __test_result::init(va_list args_)
56
 
{
57
 
  const char *format= va_arg(args_, const char *);
58
 
  _error_message_size= vasprintf(&_error_message, format, args_);
59
 
  assert(_error_message_size != -1);
60
 
  if (_error_message_size > 0)
61
 
  {
62
 
    _error_message_size++;
63
 
  }
64
 
}
65
 
 
66
 
__test_result::~__test_result() throw()
67
 
{
68
 
  free(_error_message);
69
 
}
70
 
 
71
 
__test_result::__test_result(const __test_result& other) :
72
 
  std::exception(),
73
 
  _line(other._line),
74
 
  _file(other._file),
75
 
  _func(other._func),
76
 
  _error_message_size(other._error_message_size)
77
 
{
78
 
  if (_error_message_size > 0)
79
 
  {
80
 
    _error_message= (char*) malloc(_error_message_size);
81
 
    if (_error_message)
82
 
    {
83
 
      memcpy(_error_message, other._error_message, _error_message_size);
84
 
    }
85
 
    else
86
 
    {
87
 
      _error_message_size= -1;
88
 
    }
89
 
  }
90
 
}
 
44
  libtest::exception(file_arg, line_arg, func_arg)
 
45
  {
 
46
  }
91
47
 
92
48
__success::__success(const char *file_arg, int line_arg, const char *func_arg):
93
49
  __test_result(file_arg, line_arg, func_arg)