FreeNOS
Public Member Functions | Protected Attributes
TestData< T > Class Template Referenceabstract

Generate test data for a certain data type. More...

#include <TestData.h>

Inheritance diagram for TestData< T >:
TestChar< T > TestInt< T >

Public Member Functions

 TestData ()
 Constructor. More...
 
virtual ~TestData ()
 Destructor. More...
 
void seed ()
 Initialize the random number generator. More...
 
Size count () const
 The number of generated values. More...
 
T & get (Size index)
 Retrieve previously random generated test data by index. More...
 
T & operator[] (Size index)
 Retrieve previously random generated test data by index. More...
 
virtual T random (Size count=1)=0
 Get random test value(s). More...
 
virtual T unique (Size count=1)=0
 Get unique random test value(s). More...
 

Protected Attributes

Vector< T > m_values
 Vector with generated values. More...
 

Detailed Description

template<class T>
class TestData< T >

Generate test data for a certain data type.

Definition at line 44 of file TestData.h.

Constructor & Destructor Documentation

◆ TestData()

template<class T >
TestData< T >::TestData ( )
inline

Constructor.

Definition at line 51 of file TestData.h.

References TestData< T >::seed().

◆ ~TestData()

template<class T >
virtual TestData< T >::~TestData ( )
inlinevirtual

Destructor.

Definition at line 59 of file TestData.h.

Member Function Documentation

◆ count()

template<class T >
Size TestData< T >::count ( ) const
inline

The number of generated values.

Definition at line 87 of file TestData.h.

References TestData< T >::m_values.

◆ get()

template<class T >
T& TestData< T >::get ( Size  index)
inline

Retrieve previously random generated test data by index.

Parameters
indexIndex of the value to retrieve.
Returns
T value reference.

Definition at line 99 of file TestData.h.

References TestData< T >::m_values.

◆ operator[]()

template<class T >
T& TestData< T >::operator[] ( Size  index)
inline

Retrieve previously random generated test data by index.

Definition at line 107 of file TestData.h.

References TestData< T >::m_values.

◆ random()

template<class T >
virtual T TestData< T >::random ( Size  count = 1)
pure virtual

Get random test value(s).

Parameters
countNumber or values to generate.
Returns
The last generated T value.

Implemented in TestChar< T >, TestInt< T >, TestInt< T >, TestChar< T >, and TestInt< T >.

◆ seed()

template<class T >
void TestData< T >::seed ( )
inline

Initialize the random number generator.

Definition at line 66 of file TestData.h.

References getpid(), gettimeofday(), NULL, srandom(), timestamp(), timeval::tv_sec, and timeval::tv_usec.

Referenced by TestData< T >::TestData().

◆ unique()

template<class T >
virtual T TestData< T >::unique ( Size  count = 1)
pure virtual

Get unique random test value(s).

Parameters
countNumber of unique values to generate.
Returns
The last generated T value.

Implemented in TestChar< T >, TestInt< T >, TestInt< T >, TestChar< T >, and TestInt< T >.

Field Documentation

◆ m_values

template<class T >
Vector<T> TestData< T >::m_values
protected

Vector with generated values.

Definition at line 133 of file TestData.h.

Referenced by TestData< T >::count(), TestData< T >::get(), TestData< T >::operator[](), and TestChar< T >::~TestChar().


The documentation for this class was generated from the following file: