SqlStringTestGen Class Reference

List of all members.

Public Member Functions

 SqlStringTestGen (int storage, int size, int leftpad=0, int rightpad=0, char text= 'x', char pad= ' ', int leftBumper=BUMPERLEN, int rightBumper=BUMPERLEN)
bool verify ()
void randomize (unsigned char start= 'A', unsigned char lower= ' ', unsigned char upper= '~')
void patternfill (unsigned char start= 'A', unsigned char lower= ' ', unsigned char upper= '~')

Public Attributes

char * mStr
char * mRightP
char * mLeftP
const int mStorage
const int mSize
const int mLeftPad
const int mRightPad
const int mLeftBump
const int mRightBump
const int mTotal
string mS

Private Member Functions

string vectortostring (vector< char > &v)

Detailed Description

Definition at line 45 of file SqlStringTestAscii.cpp.


Constructor & Destructor Documentation

SqlStringTestGen::SqlStringTestGen ( int  storage,
int  size,
int  leftpad = 0,
int  rightpad = 0,
char  text = 'x',
char  pad = ' ',
int  leftBumper = BUMPERLEN,
int  rightBumper = BUMPERLEN 
) [inline]

Definition at line 48 of file SqlStringTestAscii.cpp.

References mLeftBump, mLeftP, mLeftPad, mRightP, mS, mSize, mStorage, and mStr.

00057         : mStorage(storage),
00058           mSize(size),
00059           mLeftPad(leftpad),
00060           mRightPad(rightpad),
00061           mLeftBump(leftBumper),
00062           mRightBump(rightBumper),
00063           mTotal(storage + leftBumper + rightBumper),
00064           mS(mTotal, BUMPERCH)
00065     {
00066         assert(leftBumper > 0);
00067         assert(rightBumper > 0);
00068         assert(storage == size + leftpad + rightpad);
00069 
00070         mLeftP = const_cast<char *>(mS.c_str()); // Too abusive of string()?
00071         mStr = mLeftP + mLeftBump;
00072         mRightP = mStr + mStorage;
00073 
00074         string padS(mStorage, pad);
00075         string textS(size, text);
00076 
00077         mS.replace(mLeftBump, mStorage, padS, 0, mStorage); // pad all first
00078         mS.replace(mLeftBump + mLeftPad, mSize, textS, 0, mSize);
00079     }


Member Function Documentation

bool SqlStringTestGen::verify (  )  [inline]

Definition at line 82 of file SqlStringTestAscii.cpp.

References BUMPERCH, mLeftBump, mLeftPad, mRightBump, mRightPad, mS, mSize, and mTotal.

Referenced by SqlStringTest::testSqlStringAsciiCatF(), SqlStringTest::testSqlStringAsciiCatV(), SqlStringTest::testSqlStringAsciiCatV2(), SqlStringTest::testSqlStringAsciiCmpFHelper(), SqlStringTest::testSqlStringAsciiCmpVHelper(), SqlStringTest::testSqlStringAsciiOverlay(), SqlStringTest::testSqlStringAsciiSubStr(), SqlStringTest::testSqlStringAsciiToLower(), SqlStringTest::testSqlStringAsciiToUpper(), SqlStringTest::testSqlStringAsciiTrim(), and SqlStringTest::testSqlStringClass().

00083     {
00084         string verS(mTotal, BUMPERCH);
00085         if (mS.compare(0, mLeftBump, verS, 0, mLeftBump)) {
00086             return false;
00087         }
00088         if (mS.compare(
00089             mLeftBump + mLeftPad + mSize + mRightPad,
00090             mRightBump, verS, 0, mRightBump))
00091         {
00092             return false;
00093         }
00094         return true;
00095     }

void SqlStringTestGen::randomize ( unsigned char  start = 'A',
unsigned char  lower = ' ',
unsigned char  upper = '~' 
) [inline]

Definition at line 98 of file SqlStringTestAscii.cpp.

References mLeftBump, mLeftPad, mS, mSize, mStr, and patternfill().

Referenced by SqlStringTest::testSqlStringAsciiCmpFEqLen(), SqlStringTest::testSqlStringAsciiCmpVEqLen(), SqlStringTest::testSqlStringAsciiSubStr(), SqlStringTest::testSqlStringAsciiToLower(), SqlStringTest::testSqlStringAsciiToUpper(), and SqlStringTest::testSqlStringClass().

00102     {
00103         patternfill(start, lower, upper);
00104         string r(mStr, mSize);
00105         random_shuffle(r.begin(), r.end());
00106         mS.replace(mLeftBump + mLeftPad, mSize, r);
00107     }

void SqlStringTestGen::patternfill ( unsigned char  start = 'A',
unsigned char  lower = ' ',
unsigned char  upper = '~' 
) [inline]

Definition at line 110 of file SqlStringTestAscii.cpp.

References mLeftBump, mLeftPad, mS, and mSize.

Referenced by randomize(), SqlStringTest::testSqlStringAsciiCmpFDiffLen(), SqlStringTest::testSqlStringAsciiCmpVDiffLen(), and SqlStringTest::testSqlStringAsciiOverlay().

00114     {
00115         uint c; // deal with overflow easier than char
00116         int toGen = mSize;
00117 
00118         string r;
00119 
00120         c = start;
00121         while (toGen) {
00122             r.push_back(static_cast<unsigned char>(c));
00123             toGen--;
00124             if (++c > upper) {
00125                 c = lower;
00126             }
00127         }
00128         mS.replace(mLeftBump + mLeftPad, mSize, r);
00129     }

string SqlStringTestGen::vectortostring ( vector< char > &  v  )  [inline, private]

Definition at line 147 of file SqlStringTestAscii.cpp.

00148     {
00149         string s;
00150         vector<char>::iterator i = v.begin();
00151         while (i != v.end()) {
00152             s.push_back(*i);
00153             i++;
00154         }
00155         return s;
00156     }


Member Data Documentation

char* SqlStringTestGen::mStr

Definition at line 132 of file SqlStringTestAscii.cpp.

Referenced by randomize(), SqlStringTestGen(), SqlStringTest::testSqlStringAsciiCatF(), SqlStringTest::testSqlStringAsciiCatV(), SqlStringTest::testSqlStringAsciiCatV2(), SqlStringTest::testSqlStringAsciiCmpFHelper(), SqlStringTest::testSqlStringAsciiCmpVHelper(), SqlStringTest::testSqlStringAsciiOverlay(), SqlStringTest::testSqlStringAsciiPos(), SqlStringTest::testSqlStringAsciiSubStr(), SqlStringTest::testSqlStringAsciiToLower(), SqlStringTest::testSqlStringAsciiToUpper(), SqlStringTest::testSqlStringAsciiTrim(), and SqlStringTest::testSqlStringClass().

char* SqlStringTestGen::mRightP

Definition at line 133 of file SqlStringTestAscii.cpp.

Referenced by SqlStringTestGen(), and SqlStringTest::testSqlStringClass().

char* SqlStringTestGen::mLeftP

Definition at line 134 of file SqlStringTestAscii.cpp.

Referenced by SqlStringTestGen(), SqlStringTest::testSqlStringAsciiSubStr(), and SqlStringTest::testSqlStringClass().

const int SqlStringTestGen::mStorage

Definition at line 135 of file SqlStringTestAscii.cpp.

Referenced by SqlStringTestGen(), and SqlStringTest::testSqlStringClass().

const int SqlStringTestGen::mSize

Definition at line 136 of file SqlStringTestAscii.cpp.

Referenced by patternfill(), randomize(), SqlStringTestGen(), SqlStringTest::testSqlStringClass(), and verify().

const int SqlStringTestGen::mLeftPad

Definition at line 137 of file SqlStringTestAscii.cpp.

Referenced by patternfill(), randomize(), SqlStringTestGen(), SqlStringTest::testSqlStringClass(), and verify().

const int SqlStringTestGen::mRightPad

Definition at line 138 of file SqlStringTestAscii.cpp.

Referenced by SqlStringTest::testSqlStringClass(), and verify().

const int SqlStringTestGen::mLeftBump

Definition at line 139 of file SqlStringTestAscii.cpp.

Referenced by patternfill(), randomize(), SqlStringTestGen(), and verify().

const int SqlStringTestGen::mRightBump

Definition at line 140 of file SqlStringTestAscii.cpp.

Referenced by SqlStringTest::testSqlStringClass(), and verify().

const int SqlStringTestGen::mTotal

Definition at line 141 of file SqlStringTestAscii.cpp.

Referenced by verify().

string SqlStringTestGen::mS

Definition at line 142 of file SqlStringTestAscii.cpp.

Referenced by patternfill(), randomize(), SqlStringTestGen(), SqlStringTest::testSqlStringClass(), and verify().


The documentation for this class was generated from the following file:
Generated on Mon Jun 22 04:00:47 2009 for Fennel by  doxygen 1.5.1