ReactOS 0.4.16-dev-109-gf4cb10f
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.

94{ kNotInExceptionTest = -1 };
@ kNotInExceptionTest
Definition: nc_alloc.h:94

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;
152}
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
static void ClearAllocationSet()
Definition: nc_alloc.cpp:281

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 {
160}

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 {
156}

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

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 {
320 EH_STD::cerr<<"["<<current_container<<"] :";
321 EH_STD::cerr<<"testing "<<current_test <<" (" << current_test_category <<")";
322 if (err)
323 EH_STD::cerr<<EH_STD::endl;
324 else
325 EH_STD::cerr<<" ... ";
326}
#define err(...)
static const char * current_container
Definition: nc_alloc.h:104
static const char * current_test_category
Definition: nc_alloc.h:103
static const char * current_test
Definition: nc_alloc.h:102

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}
#define EH_ASSERT
Definition: Prefix.h:37
GLsizeiptr size
Definition: glext.h:5919
static void PrintTestName(bool err=false)
Definition: nc_alloc.cpp:318
static void EndLeakDetection()
Definition: nc_alloc.h:158

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
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

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)
166}

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

◆ SetCurrentTestName()

◆ SetFailureCountdown()

void TestController::SetFailureCountdown ( long  n)
inlinestatic

Definition at line 138 of file nc_alloc.h.

138 {
141}

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

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}

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}

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: