Test: Added Lexer::dequote tests

This commit is contained in:
Paul Beckingham 2015-07-28 19:33:58 -04:00
parent f1651862a0
commit d4b450bc53

View file

@ -37,7 +37,7 @@ Context context;
////////////////////////////////////////////////////////////////////////////////
int main (int argc, char** argv)
{
UnitTest t (1170);
UnitTest t (1173);
std::vector <std::pair <std::string, Lexer::Type>> tokens;
std::string token;
@ -93,6 +93,19 @@ int main (int argc, char** argv)
t.ok (Lexer::wasQuoted ("a b"), "'a b' --> wasQuoted");
t.ok (Lexer::wasQuoted ("(a)"), "'(a)' --> wasQuoted");
// static bool Lexer::dequote (std::string&, const std::string& quotes = "'\"");
token = "foo";
Lexer::dequote (token);
t.is (token, "foo", "dequote foo --> foo");
token = "'foo'";
Lexer::dequote (token);
t.is (token, "foo", "dequote 'foo' --> foo");
token = "'o\\'clock'";
Lexer::dequote (token);
t.is (token, "o\\'clock", "dequote 'o\\'clock' --> o\\'clock");
// Should result in no tokens.
Lexer l0 ("");
t.notok (l0.token (token, type), "'' --> no tokens");