#include <LeaValidate.h>
Public Member Functions | |
| LeaValidate () | |
| virtual | ~LeaValidate () |
| Bool_t | RunAllTests () |
| Bool_t | RunTest (Int_t testNum) |
Private Types | |
| enum | { kNUMTESTS = 1 } |
Private Member Functions | |
| Bool_t | Test_1 () |
Private Attributes | |
| Int_t | fNumFail |
| Int_t | fNumPass |
|
|
Definition at line 37 of file LeaValidate.h. 00037 { kNUMTESTS = 1 };
|
|
|
Definition at line 50 of file LeaValidate.cxx. References MSG. 00050 : 00051 fNumFail(0), 00052 fNumPass(0) 00053 { 00054 00055 // Purpose: Default constructor. 00056 // Arguments: None. 00057 // Return: None. 00058 00059 // Contact: N. West 00060 00061 // Specification:- 00062 // ============= 00063 00064 // o Create default object. 00065 00066 00067 MSG("Lea",Msg::kVerbose) << "LeaValidate ctor 1 at " << this 00068 << "\n"; 00069 00070 }
|
|
|
Definition at line 75 of file LeaValidate.cxx. References MSG. 00075 {
00076
00077
00078 // Purpose: Destructor.
00079 // Arguments: None.
00080 // Return: None.
00081
00082 // Contact: N. West
00083
00084 // Specification:-
00085 // =============
00086
00087 // o Destroy object.
00088
00089 MSG("Lea",Msg::kVerbose) << "LeaValidate dtor at " << this << "\n";
00090
00091 }
|
|
|
Definition at line 97 of file LeaValidate.cxx. References RunTest(). Referenced by main(). 00097 {
00098
00099
00100 // Purpose: Run all tests.
00101 // Arguments: None.
00102 // Return: = kTRUE if all tests are O.K., kFALSE otherwise.
00103
00104 // Contact: N. West
00105
00106
00107 // Specification:-
00108 // =============
00109
00110 // o Run all tests
00111
00112
00113
00114 Bool_t ok = kTRUE;
00115
00116 for ( Int_t testNum = 1; testNum <= kNUMTESTS; testNum++ ) {
00117 if ( ! RunTest(testNum) ) ok = kFALSE;
00118 }
00119 return ok;
00120 }
|
|
|
Definition at line 125 of file LeaValidate.cxx. Referenced by RunAllTests(). 00125 {
00126
00127
00128 // Purpose: Run a specific test.
00129 // Arguments:
00130 // testNum in Test to be run.
00131
00132 // Return: = kTRUE if all tests are O.K., kFALSE otherwise.
00133
00134 // Contact: N. West
00135
00136 // Specification:-
00137 // =============
00138
00139 // Program Notes
00140 // =============
00141
00142 // Banner printing not yet implemented.
00143
00144 // Dispatch to appropriate test.
00145
00146 switch ( testNum ) {
00147 case 1: return Test_1();
00148 }
00149 MSG("Lea",Msg::kError) << "Undefined test: " << testNum << "\n";
00150 return kFALSE;
00151
00152 }
|
|
|
Definition at line 155 of file LeaValidate.cxx. References fNumFail, fNumPass, LeaLeakChecker::GetNumActive(), LeaLeakChecker::GetNumCreated(), LeaLeakChecker::Instance(), MSG, and LeaLeakChecker::Reset(). Referenced by RunTest(). 00155 {
00156
00157
00158 // Purpose:
00159 // Arguments: None.
00160 // Return: = kTRUE if all tests are O.K., kFALSE otherwise.
00161
00162 // Contact: N. West
00163
00164 // Specification:-
00165 // =============
00166
00167 // o Create and delete objects on stack and heap and ensure
00168 // creation and active counts agree.
00169
00170 // o Create and delete objects by value in an STL container on stack
00171 // and ensure creation and active counts agree.
00172
00173
00174
00175 Bool_t ok = kTRUE;
00176
00177 LeaLeakChecker* lea = LeaLeakChecker::Instance();
00178 lea->Reset();
00179
00180 LeaTestA* a1 = new LeaTestA;
00181 LeaTestA* a2 = new LeaTestA;
00182
00183 // Test objects created on the stack and heap.
00184
00185 if ( lea->GetNumActive("LeaTestA") != 2
00186 || lea->GetNumActive("LeaTestB") != 0 ) {
00187 MSG("Lea",Msg::kError) << "Wrong number active." << endl
00188 << "Should be 2,0, but is " << lea->GetNumActive("LeaTestA")
00189 << "," << lea->GetNumActive("LeaTestB") << endl;
00190 ok = kFALSE;
00191 }
00192 {
00193 LeaTestB b1;
00194 LeaTestB b2;
00195 }
00196
00197 delete a1;
00198 a1 = 0;
00199 delete a2;
00200 a2 = 0;
00201
00202 if ( lea->GetNumActive() != 0
00203 || lea->GetNumCreated("LeaTestA") != 2
00204 || lea->GetNumCreated("LeaTestB") != 2 ) {
00205 MSG("Lea",Msg::kError) << "Wrong number active,created A,B" << endl
00206 << " should be 0,2,2 but is:- " << endl << lea;
00207 ok = kFALSE;
00208 }
00209
00210 // Test objects created by value in an STL continer.
00211
00212 lea->Reset();
00213
00214 {
00215 map<Int_t,LeaTestA> table;
00216 LeaTestA a;
00217 table[1] = a;
00218 table[2] = a;
00219 table[3] = a;
00220 }
00221
00222 if ( lea->GetNumActive() != 0 ) {
00223 MSG("Lea",Msg::kError) << "Wrong number active" << endl
00224 << " should be 0 but is:- " << endl << lea;
00225 ok = kFALSE;
00226 }
00227
00228
00229 MSG("Lea",Msg::kInfo)
00230 << "Test 1: Counts of stack and heap objects ...... ";
00231 MSG("Lea",Msg::kInfo) << ( ok ? "O.K." : "Failed") ;
00232 MSG("Lea",Msg::kInfo) << "\n";
00233
00234 if ( ok ) fNumPass++; else fNumFail++;
00235
00236 return ok;
00237
00238 }
|
|
|
Definition at line 43 of file LeaValidate.h. Referenced by Test_1(). |
|
|
Definition at line 44 of file LeaValidate.h. Referenced by Test_1(). |
1.3.9.1