From d4b450bc53441465a1ee41df07339d7c2ef35e39 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 28 Jul 2015 19:33:58 -0400 Subject: [PATCH] Test: Added Lexer::dequote tests --- test/lexer.t.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/lexer.t.cpp b/test/lexer.t.cpp index eebb483e4..ffc4f1e3a 100644 --- a/test/lexer.t.cpp +++ b/test/lexer.t.cpp @@ -37,7 +37,7 @@ Context context; //////////////////////////////////////////////////////////////////////////////// int main (int argc, char** argv) { - UnitTest t (1170); + UnitTest t (1173); std::vector > 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");