Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages   Examples  

CTBveri Class Reference

Framework for building a verification program. More...

#include "CTBveri.hxx"

List of all members.

Public Types

typedef bool(* pveriproc_t )(CTBveri &)

Public Methods

 CTBveri ()
 ~CTBveri ()
void Register (CTBint i_ind, pveriproc_t p_vp, const char *c_text)
int Exec (int argc, char *argv[])
bool Verbosity (int i_level) const
CTBuint32 RandomInt ()
double Random ()
CTBint RandomInt (CTBint i_high)
CTBint RandomInt (CTBint i_low, CTBint i_high)
CTBint RandomInt1X (CTBint i_low, CTBint i_high)
double Random (double d_low, double d_high)
bool RandomBool (double d_prob)
void RandomVector (CTBint i_ran[], CTBint i_size, CTBint i_high)
void RandomVector (CTBint i_ran[], CTBint i_size, CTBint i_low, CTBint i_high)
void RandomVector (bool b_ran[], CTBint i_size, double d_prob)
void RandomPermutation (CTBint i_perm[], CTBint i_size)

Private Methods

void RandomSeed (CTBuint32 i_seed)

Private Attributes

CTBint mi_nalloc
pveriproc_tmp_vp
const char ** mc_text
bool * mb_active
CTBuint32 mi_seed
CTBuint32 mi_sx
CTBuint32 mi_sy
CTBuint32 mi_sz
CTBuint32 mi_sc
CTBuint32 mi_sn
int mi_verbosity


Detailed Description

Framework for building a verification program.

The class CTBveri provides all the infrastructure to implement a test and verification program. It is essentially a driver to execute a set of test routines under the control of command line options.

Definition at line 16 of file CTBveri.hxx.


Member Typedef Documentation

typedef bool(* CTBveri::pveriproc_t
 

Typedef for a `pointer to a test procedure'. Note that all test procedures have the signature

      bool test(CTBveri&)


Constructor & Destructor Documentation

CTBveri::CTBveri
 

Constructor.

Definition at line 43 of file CTBveri.cxx.

CTBveri::~CTBveri
 

Destructor.

Definition at line 56 of file CTBveri.cxx.


Member Function Documentation

void CTBveri::Register CTBint i_ind,
pveriproc_t p_vp,
const char * c_text
 

Register a test procedure.

Registers the function p_vp as test number i_ind and associates the text c_text with this test. Note, that the test number i_ind must be >= 1. The text c_text should be a literal constant. It is displayed when the test program is called with the -? option.

Definition at line 71 of file CTBveri.cxx.

int CTBveri::Exec int argc,
char * argv[]
 

Execute tests.

Interprets the command line arguments passed as argc and argv and executes the selected tests. It returns 0 if all selected tests passed and != 0 if one test failed. A call to Exec() is usually called in the return statement of the main program, like in

int main(int argc, char* argv[]) {
  CTBveri  vd;

  vd.Register( 1,test_01,"Random insert/delete, check find");
  vd.Register( 2,test_02,"Random map, check Find, FindLess(Greater)Equal");

  return vd.Exec(argc,argv);
}

Definition at line 136 of file CTBveri.cxx.

bool CTBveri::Verbosity int i_level const
 

Checks desired output verbosity level.

Returns true if the desired output verbosity level, controlled with the -v switches, is above or equal to i_level. The default verbosity level is 0, -v sets it to 1, -vn to n (where n=1-4).

It is typically used in constructs like

  if (vd.Verbosity(1)) cout << "--> Map range " << i_range << endl;
which will only print a message when -v or any -vn switch is given.

Definition at line 245 of file CTBveri.cxx.

CTBuint32 CTBveri::RandomInt
 

Return a random unsigned 32bit integer.

This function returns a random unsigned 32bit integer and is the basis for all other random number functions in this class.

It uses a combination generator proposed in

   George Marsaglia and Arif Zaman,
   Computers in Physics, Vol. 8, 1994, p. 117
as mzran13. It combines a `subtract with borrow' generator and congruential generator and has a period of about 2**125.

Definition at line 264 of file CTBveri.cxx.

Referenced by Random(), RandomPermutation(), and RandomVector().

double CTBveri::Random
 

Return a random double in the range [0,1).

Returns a random double in the range [0,1), so the result can be 0. (and will be with exactly 1 in 2^32 cases) but will always be less than 1.

Definition at line 290 of file CTBveri.cxx.

Referenced by Random(), RandomBool(), RandomInt(), and RandomInt1X().

CTBint CTBveri::RandomInt CTBint i_high
 

Return a random integer in the range [0,i_high).

Return a random signed integer in the range [0,i_high). All integers between 0 and i_high - 1 will be returned with equal probability.

Definition at line 301 of file CTBveri.cxx.

CTBint CTBveri::RandomInt CTBint i_low,
CTBint i_high
 

Return a random integer in the range [i_low,i_high).

Return a random signed integer in the range [i_low,i_high). All integers between i_low and i_high - 1 will be returned with equal probability.

Definition at line 316 of file CTBveri.cxx.

CTBint CTBveri::RandomInt1X CTBint i_low,
CTBint i_high
 

Returns a random integer with a 1/x distribution.

Return a random signed integer in the range [i_low,i_high). All integers i between i_low and i_high - 1 will be returned with equal probability of 1/i. Thus small numbers are more probable than large numbers.

Definition at line 332 of file CTBveri.cxx.

double CTBveri::Random double d_low,
double d_high
 

Return a random double in the range [d_low,d_high).

Definition at line 352 of file CTBveri.cxx.

bool CTBveri::RandomBool double d_prob
 

Generate a random boolean.

Returns true with a probability of d_prob.

Definition at line 362 of file CTBveri.cxx.

Referenced by RandomVector().

void CTBveri::RandomVector CTBint i_ran[],
CTBint i_size,
CTBint i_high
 

Generate vector with random integers.

The vector i_ran is fill with i_size random integers in the range [0,i_high).

Definition at line 373 of file CTBveri.cxx.

void CTBveri::RandomVector CTBint i_ran[],
CTBint i_size,
CTBint i_low,
CTBint i_high
 

Generate vector with random integers.

The vector i_ran is fill with i_size random integers in the range [i_low,i_high).

Definition at line 385 of file CTBveri.cxx.

void CTBveri::RandomVector bool b_ran[],
CTBint i_size,
double d_prob
 

Generate vector with random booleans.

The vector b_ran is fill with i_size random booleans which have a probability of d_prob of being true.

Definition at line 398 of file CTBveri.cxx.

void CTBveri::RandomPermutation CTBint i_perm[],
CTBint i_size
 

Generate a random permutation.

The integer array i_perm of size i_size is filled with a random permutation of the numbers 0,1,..,i_size-1.

Definition at line 410 of file CTBveri.cxx.

void CTBveri::RandomSeed CTBuint32 i_seed [private]
 

Definition at line 445 of file CTBveri.cxx.

Referenced by CTBveri(), and Exec().


Member Data Documentation

CTBint CTBveri::mi_nalloc [private]
 

Definition at line 56 of file CTBveri.hxx.

pveriproc_t* CTBveri::mp_vp [private]
 

Definition at line 57 of file CTBveri.hxx.

const char** CTBveri::mc_text [private]
 

Definition at line 58 of file CTBveri.hxx.

bool* CTBveri::mb_active [private]
 

Definition at line 59 of file CTBveri.hxx.

CTBuint32 CTBveri::mi_seed [private]
 

Definition at line 60 of file CTBveri.hxx.

CTBuint32 CTBveri::mi_sx [private]
 

Definition at line 61 of file CTBveri.hxx.

CTBuint32 CTBveri::mi_sy [private]
 

Definition at line 62 of file CTBveri.hxx.

CTBuint32 CTBveri::mi_sz [private]
 

Definition at line 63 of file CTBveri.hxx.

CTBuint32 CTBveri::mi_sc [private]
 

Definition at line 64 of file CTBveri.hxx.

CTBuint32 CTBveri::mi_sn [private]
 

Definition at line 65 of file CTBveri.hxx.

int CTBveri::mi_verbosity [private]
 

Definition at line 66 of file CTBveri.hxx.


The documentation for this class was generated from the following files:
Generated at Fri Oct 24 18:14:14 2003 for CTBbase by doxygen1.2.9-20010812 written by Dimitri van Heesch, © 1997-2001