Unit Tests - Att

- Merged all old Mod tests into Att.
- Fixed broken tests.
This commit is contained in:
Paul Beckingham 2009-06-03 21:20:09 -04:00
parent 55771cc999
commit f295fdf78f
2 changed files with 12 additions and 9 deletions

View file

@ -107,7 +107,12 @@ bool Att::parse (Nibbler& n)
{ {
std::string mod; std::string mod;
if (n.getUntilOneOf (".:", mod)) if (n.getUntilOneOf (".:", mod))
mMods.push_back (mod); {
if (validMod (mod))
mMods.push_back (mod);
else
throw std::string ("The name '") + mod + "' is not a valid modifier";
}
else else
throw std::string ("Missing . or : after modifier"); throw std::string ("Missing . or : after modifier");
} }
@ -212,7 +217,10 @@ std::string Att::composeF4 () const
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void Att::addMod (const std::string& mod) void Att::addMod (const std::string& mod)
{ {
mMods.push_back (mod); if (validMod (mod))
mMods.push_back (mod);
else
throw std::string ("The name '") + mod + "' is not a valid modifier";
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View file

@ -140,11 +140,6 @@ int main (int argc, char** argv)
try {a6.addMod ("endswith");} catch (...) {good = false;} try {a6.addMod ("endswith");} catch (...) {good = false;}
t.ok (good, "Att::addMod (endswith)"); t.ok (good, "Att::addMod (endswith)");
good = true; good = true;
try {a6.addMod ("fartwizzle");} catch (...) {good = false;} try {a6.addMod ("fartwizzle");} catch (...) {good = false;}
t.notok (good, "Att::addMod (fartwizzle)"); t.notok (good, "Att::addMod (fartwizzle)");
@ -152,8 +147,8 @@ int main (int argc, char** argv)
// Att::mods // Att::mods
std::vector <std::string> mods; std::vector <std::string> mods;
a6.mods (mods); a6.mods (mods);
t.is (mods.size (), (size_t)1, "Att::mods () size == 1"); t.is (mods.size (), (size_t)18, "Att::mods () size == 18");
t.is (mods[0], "is", "Att::mods [0] == 'is'"); t.is (mods[0], "is", "Att::mods [0] == 'is'");
// Att::parse // Att::parse
Nibbler n (""); Nibbler n ("");