From: Francis Dupont Date: Mon, 9 Nov 2015 12:03:13 +0000 (+0100) Subject: [4088fd] Added hexstring parsing unit tests X-Git-Tag: trac4088fd_before_unquote~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7e64f067b3490640ebcd23add6edafc07d200207;p=thirdparty%2Fkea.git [4088fd] Added hexstring parsing unit tests --- diff --git a/src/lib/eval/tests/context_unittest.cc b/src/lib/eval/tests/context_unittest.cc index 0c94bf290c..8cb6f6d31b 100644 --- a/src/lib/eval/tests/context_unittest.cc +++ b/src/lib/eval/tests/context_unittest.cc @@ -172,6 +172,21 @@ TEST_F(EvalContextTest, hexstring) { checkTokenHexString(tmp, "foo"); } +// Test the parsing of a hexstring terminal with an odd number of +// hexadecimal digits +TEST_F(EvalContextTest, oddHexstring) { + EvalContext eval; + + EXPECT_NO_THROW(parsed_ = eval.parseString("untyped: 0X7")); + EXPECT_TRUE(parsed_); + + ASSERT_EQ(1, eval.expression.size()); + + TokenPtr tmp = eval.expression.at(0); + + checkTokenHexString(tmp, "\a"); +} + // Test the parsing of an equal expression TEST_F(EvalContextTest, equal) { EvalContext eval; @@ -255,6 +270,10 @@ TEST_F(EvalContextTest, parseErrors) { checkError("'foo''bar'", ":1.6-10: syntax error, unexpected constant string, " "expecting =="); + checkError("0x", + ":1.1: syntax error, unexpected option code"); + checkError("0abc", + ":1.1: syntax error, unexpected option code"); checkError("== 'ab'", ":1.1-2: syntax error, unexpected =="); checkError("'foo' ==", ":1.9: syntax error, unexpected end of file");