From 3899cd3c8fb3eccb73a43208e90d88cfcc64c41c Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Fri, 3 Apr 2015 22:24:35 +0200 Subject: Identifiers may not end with an underscore --- test/core/common/UtilsTest.cpp | 1 + test/formats/osml/OsmlStreamParserTest.cpp | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) (limited to 'test') diff --git a/test/core/common/UtilsTest.cpp b/test/core/common/UtilsTest.cpp index 2aaa430..f1a9af3 100644 --- a/test/core/common/UtilsTest.cpp +++ b/test/core/common/UtilsTest.cpp @@ -31,6 +31,7 @@ TEST(Utils, isIdentifier) EXPECT_FALSE(Utils::isIdentifier("0t-_EST")); EXPECT_FALSE(Utils::isIdentifier("_A")); EXPECT_FALSE(Utils::isIdentifier("invalid key")); + EXPECT_FALSE(Utils::isIdentifier("A_")); EXPECT_FALSE(Utils::isIdentifier("")); } diff --git a/test/formats/osml/OsmlStreamParserTest.cpp b/test/formats/osml/OsmlStreamParserTest.cpp index d47f529..d45a799 100644 --- a/test/formats/osml/OsmlStreamParserTest.cpp +++ b/test/formats/osml/OsmlStreamParserTest.cpp @@ -1435,5 +1435,35 @@ TEST(OsmlStreamParser, userDefinedTokens) assertText(reader, " said.", tokens, WhitespaceMode::PRESERVE, 34, 40); assertEnd(reader); } + +TEST(OsmlStreamParser, commandWithUnderscoreAndEnd) +{ + const char *testString = "\\sum_"; + // 01234 + // 0 + + CharReader charReader(testString); + + OsmlStreamParser parser(charReader, logger); + + assertCommandStart(parser, "sum", false, Variant::mapType{}, 0, 4); + assertData(parser, "_", 4, 5); + assertEnd(parser); +} + +TEST(OsmlStreamParser, commandWithUnderscore) +{ + const char *testString = "\\sum_ a"; + // 0123456 + // 0 + + CharReader charReader(testString); + + OsmlStreamParser parser(charReader, logger); + + assertCommandStart(parser, "sum", false, Variant::mapType{}, 0, 4); + assertData(parser, "_ a", 4, 7); + assertEnd(parser); +} } -- cgit v1.2.3