ReactOS  0.4.14-dev-50-g13bb5e2
TestController Struct Reference

#include <nc_alloc.h>

Static Public Member Functions

static void ReportSuccess (int)
 
static void TrackAllocations (bool)
 
static bool TrackingEnabled ()
 
static void BeginLeakDetection ()
 
static bool LeakDetectionEnabled ()
 
static bool ReportLeaked ()
 
static void TurnOffExceptions ()
 
static void SetFailureCountdown (long n)
 
static void CancelFailureCountdown ()
 
static void maybe_fail (long)
 
static void SetCurrentTestCategory (const char *str)
 
static void SetCurrentContainer (const char *str)
 
static void SetCurrentTestName (const char *str)
 
static void SetVerbose (bool val)
 

Private Types

enum  { kNotInExceptionTest = -1 }
 

Static Private Member Functions

static void ClearAllocationSet ()
 
static void EndLeakDetection ()
 
static void PrintTestName (bool err=false)
 
static longFailure_threshold ()
 

Static Private Attributes

static long possible_failure_count = 0
 
static const charcurrent_test = "<unknown>"
 
static const charcurrent_test_category = "no category"
 
static const charcurrent_container = 0
 
static bool nc_verbose = true
 
static bool never_fail = false
 
static bool track_allocations = false
 
static bool leak_detection_enabled = false
 

Detailed Description

Definition at line 34 of file nc_alloc.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
kNotInExceptionTest 

Definition at line 94 of file nc_alloc.h.

Member Function Documentation

◆ BeginLeakDetection()

void TestController::BeginLeakDetection ( )
inlinestatic

Definition at line 147 of file nc_alloc.h.

147  {
148  alloc_count = 0;
149  object_count = 0;
151  leak_detection_enabled = true;
152 }
static void ClearAllocationSet()
Definition: nc_alloc.cpp:281
long alloc_count
Definition: nc_alloc.cpp:36
long object_count
Definition: nc_alloc.cpp:37
static bool leak_detection_enabled
Definition: nc_alloc.h:108

Referenced by ConstCheck(), StrongCheck(), and WeakCheck().

◆ CancelFailureCountdown()

◆ ClearAllocationSet()

void TestController::ClearAllocationSet ( )
staticprivate

Definition at line 281 of file nc_alloc.cpp.

281  {
282  if (!using_alloc_set) {
283  using_alloc_set = true;
284  alloc_set().clear();
285  using_alloc_set = false;
286  }
287 }
static bool using_alloc_set
Definition: nc_alloc.cpp:104
static allocation_set & alloc_set()
Definition: nc_alloc.cpp:98

Referenced by BeginLeakDetection().

◆ EndLeakDetection()

void TestController::EndLeakDetection ( )
inlinestaticprivate

Definition at line 158 of file nc_alloc.h.

158  {
159  leak_detection_enabled = false;
160 }
static bool leak_detection_enabled
Definition: nc_alloc.h:108

Referenced by ReportLeaked().

◆ Failure_threshold()

long & TestController::Failure_threshold ( )
staticprivate

Definition at line 333 of file nc_alloc.cpp.

333  {
334  static long failure_threshold = kNotInExceptionTest;
335  return failure_threshold;
336 }

Referenced by CancelFailureCountdown(), maybe_fail(), and SetFailureCountdown().

◆ LeakDetectionEnabled()

bool TestController::LeakDetectionEnabled ( )
inlinestatic

Definition at line 154 of file nc_alloc.h.

154  {
155  return leak_detection_enabled;
156 }
static bool leak_detection_enabled
Definition: nc_alloc.h:108

Referenced by operator delete(), and OperatorNew().

◆ maybe_fail()

void TestController::maybe_fail ( long  )
static

Definition at line 49 of file nc_alloc.cpp.

49  {
51  return;
52 
53  // throw if allocation would satisfy the threshold
55  // what about doing some standard new_handler() behavior here (to test it!) ???
56 
57  // reset and simulate an out-of-memory failure
59 #ifndef EH_NO_EXCEPTIONS
60  throw EH_STD::bad_alloc();
61 #endif
62  }
63 }
static long possible_failure_count
Definition: nc_alloc.h:101
static bool never_fail
Definition: nc_alloc.h:106
static long & Failure_threshold()
Definition: nc_alloc.cpp:333

Referenced by simulate_constructor(), and simulate_possible_failure().

◆ PrintTestName()

void TestController::PrintTestName ( bool  err = false)
staticprivate

Definition at line 318 of file nc_alloc.cpp.

318  {
319  if (current_container)
320  EH_STD::cerr<<"["<<current_container<<"] :";
321  EH_STD::cerr<<"testing "<<current_test <<" (" << current_test_category <<")";
322  if (err)
324  else
325  EH_STD::cerr<<" ... ";
326 }
basic_ostream< _CharT, _Traits > &_STLP_CALL endl(basic_ostream< _CharT, _Traits > &__os)
Definition: _ostream.h:357
_STLP_DECLSPEC _Stl_aligned_buffer< ostream > cerr
Definition: iostream.cpp:102
static const char * current_test
Definition: nc_alloc.h:102
#define err(...)
static const char * current_container
Definition: nc_alloc.h:104
static const char * current_test_category
Definition: nc_alloc.h:103

Referenced by ReportLeaked(), and SetCurrentTestCategory().

◆ ReportLeaked()

bool TestController::ReportLeaked ( )
static

Definition at line 290 of file nc_alloc.cpp.

290  {
292 
293  EH_ASSERT( !using_alloc_set || (alloc_count == static_cast<int>(alloc_set().size())) );
294 
295  if (alloc_count != 0 || object_count != 0) {
296  EH_STD::cerr<<"\nEH TEST FAILURE !\n";
297  PrintTestName(true);
298  if (alloc_count)
299  EH_STD::cerr << "ERROR : " << alloc_count << " outstanding allocations.\n";
300  if (object_count)
301  EH_STD::cerr << "ERROR : " << object_count << " non-destroyed objects.\n";
303  return true;
304  }
305  return false;
306 }
static bool using_alloc_set
Definition: nc_alloc.cpp:104
static void PrintTestName(bool err=false)
Definition: nc_alloc.cpp:318
static allocation_set & alloc_set()
Definition: nc_alloc.cpp:98
long object_count
Definition: nc_alloc.cpp:37
GLsizeiptr size
Definition: glext.h:5919
_STLP_DECLSPEC _Stl_aligned_buffer< ostream > cerr
Definition: iostream.cpp:102
static void EndLeakDetection()
Definition: nc_alloc.h:158
long alloc_count
Definition: nc_alloc.cpp:36
#define EH_ASSERT
Definition: Prefix.h:37

Referenced by ConstCheck(), StrongCheck(), and WeakCheck().

◆ ReportSuccess()

void TestController::ReportSuccess ( int  count)
static

Definition at line 328 of file nc_alloc.cpp.

328  {
329  if (nc_verbose)
330  EH_STD::cerr<<(count+1)<<" try successful"<<EH_STD::endl;
331 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
basic_ostream< _CharT, _Traits > &_STLP_CALL endl(basic_ostream< _CharT, _Traits > &__os)
Definition: _ostream.h:357
_STLP_DECLSPEC _Stl_aligned_buffer< ostream > cerr
Definition: iostream.cpp:102
static bool nc_verbose
Definition: nc_alloc.h:105

Referenced by ConstCheck(), StrongCheck(), and WeakCheck().

◆ SetCurrentContainer()

void TestController::SetCurrentContainer ( const char str)
inlinestatic

Definition at line 168 of file nc_alloc.h.

168  {
170 }
const WCHAR * str
static const char * current_container
Definition: nc_alloc.h:104

Referenced by main().

◆ SetCurrentTestCategory()

void TestController::SetCurrentTestCategory ( const char str)
inlinestatic

Definition at line 162 of file nc_alloc.h.

162  {
164  if (nc_verbose)
165  PrintTestName();
166 }
static void PrintTestName(bool err=false)
Definition: nc_alloc.cpp:318
const WCHAR * str
static const char * current_test_category
Definition: nc_alloc.h:103
static bool nc_verbose
Definition: nc_alloc.h:105

Referenced by ConstCheck(), StrongCheck(), and WeakCheck().

◆ SetCurrentTestName()

void TestController::SetCurrentTestName ( const char str)
inlinestatic

Definition at line 172 of file nc_alloc.h.

172  {
173  current_test = str;
174 }
const WCHAR * str
static const char * current_test
Definition: nc_alloc.h:102

Referenced by test_assign_op< T >::test_assign_op(), test_BitVector_reserve::test_BitVector_reserve(), test_construct_iter_range< T >::test_construct_iter_range(), test_construct_iter_range_n< T >::test_construct_iter_range_n(), test_construct_n< T >::test_construct_n(), test_construct_n_instance< T >::test_construct_n_instance(), test_construct_pointer_range< T >::test_construct_pointer_range(), test_copy_construct< T >::test_copy_construct(), test_default_construct< T >::test_default_construct(), test_hash_resize< T >::test_hash_resize(), test_inplace_merge_1::test_inplace_merge_1(), test_inplace_merge_2::test_inplace_merge_2(), test_insert_n< C >::test_insert_n(), test_insert_noresize< C >::test_insert_noresize(), test_insert_one< C >::test_insert_one(), test_insert_range< C, Iter >::test_insert_range(), test_insert_value< C >::test_insert_value(), test_list_sort::test_list_sort(), test_push_back< C >::test_push_back(), test_push_front< C >::test_push_front(), test_reserve::test_reserve(), test_slist_sort::test_slist_sort(), test_stable_partition::test_stable_partition(), test_stable_sort_1::test_stable_sort_1(), test_stable_sort_2::test_stable_sort_2(), test_uninitialized_copy::test_uninitialized_copy(), test_uninitialized_fill::test_uninitialized_fill(), and test_uninitialized_fill_n::test_uninitialized_fill_n().

◆ SetFailureCountdown()

void TestController::SetFailureCountdown ( long  n)
inlinestatic

Definition at line 138 of file nc_alloc.h.

138  {
141 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
static long possible_failure_count
Definition: nc_alloc.h:101
static long & Failure_threshold()
Definition: nc_alloc.cpp:333

Referenced by ConstCheck(), StrongCheck(), and WeakCheck().

◆ SetVerbose()

void TestController::SetVerbose ( bool  val)
inlinestatic

Definition at line 176 of file nc_alloc.h.

176  {
177  nc_verbose = val;
178 }
GLuint GLfloat * val
Definition: glext.h:7180
static bool nc_verbose
Definition: nc_alloc.h:105

Referenced by main().

◆ TrackAllocations()

void TestController::TrackAllocations ( bool  track)
inlinestatic

Definition at line 130 of file nc_alloc.h.

130  {
131  track_allocations = track;
132 }
static bool track_allocations
Definition: nc_alloc.h:107

Referenced by main().

◆ TrackingEnabled()

bool TestController::TrackingEnabled ( )
inlinestatic

Definition at line 134 of file nc_alloc.h.

134  {
135  return track_allocations;
136 }
static bool track_allocations
Definition: nc_alloc.h:107

Referenced by operator delete(), and OperatorNew().

◆ TurnOffExceptions()

void TestController::TurnOffExceptions ( )
inlinestatic

Definition at line 180 of file nc_alloc.h.

180  {
181  never_fail = true;
182 }
static bool never_fail
Definition: nc_alloc.h:106

Referenced by main().

Member Data Documentation

◆ current_container

const char * TestController::current_container = 0
staticprivate

Definition at line 104 of file nc_alloc.h.

Referenced by PrintTestName(), and SetCurrentContainer().

◆ current_test

const char * TestController::current_test = "<unknown>"
staticprivate

Definition at line 102 of file nc_alloc.h.

Referenced by PrintTestName(), and SetCurrentTestName().

◆ current_test_category

const char * TestController::current_test_category = "no category"
staticprivate

Definition at line 103 of file nc_alloc.h.

Referenced by PrintTestName(), and SetCurrentTestCategory().

◆ leak_detection_enabled

bool TestController::leak_detection_enabled = false
staticprivate

Definition at line 108 of file nc_alloc.h.

Referenced by BeginLeakDetection(), EndLeakDetection(), and LeakDetectionEnabled().

◆ nc_verbose

bool TestController::nc_verbose = true
staticprivate

Definition at line 105 of file nc_alloc.h.

Referenced by ReportSuccess(), SetCurrentTestCategory(), and SetVerbose().

◆ never_fail

bool TestController::never_fail = false
staticprivate

Definition at line 106 of file nc_alloc.h.

Referenced by maybe_fail(), and TurnOffExceptions().

◆ possible_failure_count

long TestController::possible_failure_count = 0
staticprivate

Definition at line 101 of file nc_alloc.h.

Referenced by maybe_fail(), and SetFailureCountdown().

◆ track_allocations

bool TestController::track_allocations = false
staticprivate

Definition at line 107 of file nc_alloc.h.

Referenced by TrackAllocations(), and TrackingEnabled().


The documentation for this struct was generated from the following files: