From 73c9d6c1f3081826475aefaab584d852afb80d79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Wed, 22 Jun 2016 09:14:01 +0100 Subject: [PATCH] Checking that Parser initially is case-sensitive. --- include/plasp/utils/Parser.h | 1 + src/plasp/utils/Parser.cpp | 7 +++++++ tests/TestUtils.cpp | 2 ++ 3 files changed, 10 insertions(+) diff --git a/include/plasp/utils/Parser.h b/include/plasp/utils/Parser.h index 2d821bc..d6678cf 100644 --- a/include/plasp/utils/Parser.h +++ b/include/plasp/utils/Parser.h @@ -57,6 +57,7 @@ class Parser Coordinate coordinate() const; void setCaseSensitive(bool isCaseInsensitive = true); + bool isCaseSensitive() const noexcept; char currentCharacter() const; void advance(); diff --git a/src/plasp/utils/Parser.cpp b/src/plasp/utils/Parser.cpp index daf51bf..607abb2 100644 --- a/src/plasp/utils/Parser.cpp +++ b/src/plasp/utils/Parser.cpp @@ -166,6 +166,13 @@ void Parser::setCaseSensitive(bool isCaseSensitive) //////////////////////////////////////////////////////////////////////////////////////////////////// +bool Parser::isCaseSensitive() const noexcept +{ + return m_isCaseSensitive; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// + char Parser::currentCharacter() const { if (m_isCaseSensitive) diff --git a/tests/TestUtils.cpp b/tests/TestUtils.cpp index cc4412f..07d48dc 100644 --- a/tests/TestUtils.cpp +++ b/tests/TestUtils.cpp @@ -11,6 +11,8 @@ TEST(UtilsTests, ParseSimple) std::stringstream s("identifier 5 \n-51\t 0 1 expected unexpected"); plasp::utils::Parser p("input", s); + ASSERT_TRUE(p.isCaseSensitive()); + ASSERT_EQ(p.parse(), "identifier"); ASSERT_EQ(p.parse(), 5u); ASSERT_EQ(p.parse(), -51);