ReactOS 0.4.15-dev-7924-g5949c20
LeakCheck.h File Reference
#include "Prefix.h"
#include "nc_alloc.h"
#include <cstdio>
#include <cassert>
#include <iterator>
#include <iostream>
Include dependency graph for LeakCheck.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<class T1 , class T2 >
EH_BEGIN_NAMESPACE ostreamoperator<< (ostream &s, const pair< T1, T2 > &p)
 
template<class C >
EH_END_NAMESPACE void CheckInvariant (const C &)
 
template<class Value , class Operation >
void WeakCheck (const Value &v, const Operation &op, long max_iters=2000000)
 
template<class Value , class Operation >
void ConstCheck (const Value &v, const Operation &op, long max_iters=2000000)
 
template<class Value , class Operation >
void StrongCheck (const Value &v, const Operation &op, long max_iters=2000000)
 

Function Documentation

◆ CheckInvariant()

◆ ConstCheck()

template<class Value , class Operation >
void ConstCheck ( const Value v,
const Operation op,
long  max_iters = 2000000 
)

Definition at line 103 of file LeakCheck.h.

103 {
104 bool succeeded = false;
105 bool failed = false;
107 for (long count = 0; !succeeded && !failed && count < max_iters; ++count) {
109 {
110#ifndef EH_NO_EXCEPTIONS
111 try {
112#endif
114 op( v );
115 succeeded = true;
116#ifndef EH_NO_EXCEPTIONS
117 }
118 catch(...) {} // Just try again.
119# endif
121 }
122 failed = gTestController.ReportLeaked();
123 EH_ASSERT( !failed );
124
125 if ( succeeded )
127 }
128 EH_ASSERT( succeeded || failed ); // Make sure the count hasn't gone over
129}
#define EH_ASSERT
Definition: Prefix.h:37
UINT op
Definition: effect.c:236
const GLdouble * v
Definition: gl.h:2040
GLuint GLuint GLsizei count
Definition: gl.h:1545
TestController gTestController
Definition: nc_alloc.cpp:46
static void BeginLeakDetection()
Definition: nc_alloc.h:147
static bool ReportLeaked()
Definition: nc_alloc.cpp:290
static void CancelFailureCountdown()
Definition: nc_alloc.h:143
static void SetFailureCountdown(long n)
Definition: nc_alloc.h:138
static void ReportSuccess(int)
Definition: nc_alloc.cpp:328
static void SetCurrentTestCategory(const char *str)
Definition: nc_alloc.h:162

Referenced by test_bit_vector(), test_deque(), test_hash_map(), test_hash_multimap(), test_hash_multiset(), test_hash_set(), test_list(), test_map(), test_multimap(), test_multiset(), test_rope(), test_set(), test_slist(), test_string(), and test_vector().

◆ operator<<()

template<class T1 , class T2 >
EH_BEGIN_NAMESPACE ostream & operator<< ( ostream s,
const pair< T1, T2 > &  p 
)
inline

Definition at line 38 of file LeakCheck.h.

40 {
41 return s<<'['<<p.first<<":"<<p.second<<']';
42}
GLdouble s
Definition: gl.h:2039
GLfloat GLfloat p
Definition: glext.h:8902

◆ StrongCheck()

template<class Value , class Operation >
void StrongCheck ( const Value v,
const Operation op,
long  max_iters = 2000000 
)

Definition at line 145 of file LeakCheck.h.

145 {
146 bool succeeded = false;
147 bool failed = false;
149 for ( long count = 0; !succeeded && !failed && count < max_iters; count++ ) {
151
152 {
153 Value dup = v;
154 {
155#ifndef EH_NO_EXCEPTIONS
156 try {
157#endif
159 op( dup );
160 succeeded = true;
162# ifndef EH_NO_EXCEPTIONS
163 }
164 catch (...) {
166 bool unchanged = (dup == v);
167 EH_ASSERT( unchanged );
168
169 if ( !unchanged ) {
170#if 0
171 typedef typename Value::value_type value_type;
172 EH_STD::ostream_iterator<value_type> o(EH_STD::cerr, " ");
173 EH_STD::cerr<<"EH test FAILED:\nStrong guaranee failed !\n";
174 EH_STD::copy(dup.begin(), dup.end(), o);
175 EH_STD::cerr<<"\nOriginal is:\n";
176 EH_STD::copy(v.begin(), v.end(), o);
177 EH_STD::cerr<<EH_STD::endl;
178#endif
179 failed = true;
180 }
181 } // Just try again.
182# endif
184 }
185 }
186
187 bool leaked = gTestController.ReportLeaked();
188 EH_ASSERT( !leaked );
189 if ( leaked )
190 failed = true;
191
192 if ( succeeded )
194 }
195 EH_ASSERT( succeeded || failed ); // Make sure the count hasn't gone over
196}
EH_END_NAMESPACE void CheckInvariant(const C &)
Definition: LeakCheck.h:52
#define dup
Definition: syshdrs.h:51
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by test_bit_vector(), test_deque(), test_list(), test_map(), test_multimap(), test_multiset(), test_set(), test_slist(), and test_vector().

◆ WeakCheck()

template<class Value , class Operation >
void WeakCheck ( const Value v,
const Operation op,
long  max_iters = 2000000 
)

Definition at line 65 of file LeakCheck.h.

65 {
66 bool succeeded = false;
67 bool failed = false;
69 for (long count = 0; !succeeded && !failed && count < max_iters; ++count) {
71 {
72 Value dup = v;
73#ifndef EH_NO_EXCEPTIONS
74 try {
75#endif
77 op( dup );
78 succeeded = true;
79#ifndef EH_NO_EXCEPTIONS
80 }
81 catch (...) {} // Just try again.
82#endif
85 }
87 EH_ASSERT( !failed );
88
89 if ( succeeded )
91 }
92 EH_ASSERT( succeeded || failed ); // Make sure the count hasn't gone over
93}

Referenced by test_algo(), test_algobase(), test_bit_vector(), test_deque(), test_hash_map(), test_hash_multimap(), test_hash_multiset(), test_hash_set(), test_list(), test_map(), test_multimap(), test_multiset(), test_rope(), test_set(), test_slist(), test_string(), and test_vector().