From 65b1dd3dae0d407f44c8988a39180b289edeb7ff Mon Sep 17 00:00:00 2001 From: Francis Dupont Date: Fri, 6 Nov 2015 11:05:22 +0100 Subject: [PATCH] [4088fd] Added some parser unit tests --- src/lib/eval/tests/context_unittest.cc | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/lib/eval/tests/context_unittest.cc b/src/lib/eval/tests/context_unittest.cc index df6e2bb84e..c7440b8cbc 100644 --- a/src/lib/eval/tests/context_unittest.cc +++ b/src/lib/eval/tests/context_unittest.cc @@ -224,4 +224,34 @@ TEST_F(EvalContextTest, scanParseErrors) { "or constant hexstring"); } +// Tests some parser error cases +TEST_F(EvalContextTest, parseErrors) { + checkError("'foo''bar'", ":1.6-10: syntax error, unexpected " + "constant string, expecting end of file"); + checkError("== 'ab'", ":1.1-2: syntax error, unexpected ==, " + "expecting option or substring or constant string " + "or constant hexstring"); + checkError("'foo' ==", ":1.9: syntax error, unexpected end " + "of file, expecting option or substring or " + "constant string or constant hexstring"); + checkError("option 'ab'", ":1.8-11: syntax error, unexpected " + "constant string, expecting ["); + checkError("option(10) == 'ab'", ":1.7: syntax error, " + "unexpected (, expecting ["); + checkError("option['ab'] == 'foo'", ":1.8-11: syntax error, " + "unexpected constant string, " + "expecting option code"); + checkError("option[0xa] == 'ab'", ":1.8-10: syntax error, " + "unexpected constant hexstring, " + "expecting option code"); + checkError("substring('foobar') == 'f'", ":1.19: syntax error, " + "unexpected ), expecting \",\""); + checkError("substring('foobar','3') == 'bar'", + ":1.23: syntax error, unexpected ), expecting \",\""); + checkError("substring('foobar',3,3) == 'bar'", + ":1.20: syntax error, unexpected option code, " + "expecting option or substring or constant string or " + "constant hexstring"); +} + }; -- 2.47.3