diff --git a/src/Att.cpp b/src/Att.cpp index 312c91f36..29847ebf2 100644 --- a/src/Att.cpp +++ b/src/Att.cpp @@ -107,7 +107,12 @@ bool Att::parse (Nibbler& n) { std::string 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 throw std::string ("Missing . or : after modifier"); } @@ -212,7 +217,10 @@ std::string Att::composeF4 () const //////////////////////////////////////////////////////////////////////////////// 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"; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/tests/att.t.cpp b/src/tests/att.t.cpp index 88f1f4b59..3ee651195 100644 --- a/src/tests/att.t.cpp +++ b/src/tests/att.t.cpp @@ -140,11 +140,6 @@ int main (int argc, char** argv) try {a6.addMod ("endswith");} catch (...) {good = false;} t.ok (good, "Att::addMod (endswith)"); - - - - - good = true; try {a6.addMod ("fartwizzle");} catch (...) {good = false;} t.notok (good, "Att::addMod (fartwizzle)"); @@ -152,8 +147,8 @@ int main (int argc, char** argv) // Att::mods std::vector mods; a6.mods (mods); - t.is (mods.size (), (size_t)1, "Att::mods () size == 1"); - t.is (mods[0], "is", "Att::mods [0] == 'is'"); + t.is (mods.size (), (size_t)18, "Att::mods () size == 18"); + t.is (mods[0], "is", "Att::mods [0] == 'is'"); // Att::parse Nibbler n ("");