Unit Tests - Nibbler

- Complete rewrite of all Nibbler tests, this time including all
  boundary conditions.
This commit is contained in:
Paul Beckingham 2009-05-30 17:04:20 -04:00
parent dde044c3d7
commit cebacc7273
2 changed files with 94 additions and 121 deletions

View file

@ -99,11 +99,11 @@ bool Nibbler::getUntil (char c, std::string& result)
}
////////////////////////////////////////////////////////////////////////////////
bool Nibbler::getUntilOneOf (const std::string& chars, std::string& result)
bool Nibbler::getUntil (const std::string& terminator, std::string& result)
{
if (mCursor < mInput.length ())
{
std::string::size_type i = mInput.find_first_of (chars, mCursor);
std::string::size_type i = mInput.find (terminator, mCursor);
if (i != std::string::npos)
{
result = mInput.substr (mCursor, i - mCursor);
@ -122,17 +122,23 @@ bool Nibbler::getUntilOneOf (const std::string& chars, std::string& result)
}
////////////////////////////////////////////////////////////////////////////////
bool Nibbler::getUntil (const std::string& terminator, std::string& result)
bool Nibbler::getUntilOneOf (const std::string& chars, std::string& result)
{
if (mCursor < mInput.length ())
{
std::string::size_type i = mInput.find (terminator, mCursor);
std::string::size_type i = mInput.find_first_of (chars, mCursor);
if (i != std::string::npos)
{
result = mInput.substr (mCursor, i - mCursor);
mCursor = i;
return true;
}
else
{
result = mInput.substr (mCursor, std::string::npos);
mCursor = mInput.length ();
}
return true;
}
return false;