Checking that Parser initially is case-sensitive.

This commit is contained in:
Patrick Lühne 2016-06-22 09:14:01 +01:00
parent d9578b6f1c
commit 73c9d6c1f3
3 changed files with 10 additions and 0 deletions

View File

@ -57,6 +57,7 @@ class Parser
Coordinate coordinate() const; Coordinate coordinate() const;
void setCaseSensitive(bool isCaseInsensitive = true); void setCaseSensitive(bool isCaseInsensitive = true);
bool isCaseSensitive() const noexcept;
char currentCharacter() const; char currentCharacter() const;
void advance(); void advance();

View File

@ -166,6 +166,13 @@ void Parser::setCaseSensitive(bool isCaseSensitive)
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
bool Parser::isCaseSensitive() const noexcept
{
return m_isCaseSensitive;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
char Parser::currentCharacter() const char Parser::currentCharacter() const
{ {
if (m_isCaseSensitive) if (m_isCaseSensitive)

View File

@ -11,6 +11,8 @@ TEST(UtilsTests, ParseSimple)
std::stringstream s("identifier 5 \n-51\t 0 1 expected unexpected"); std::stringstream s("identifier 5 \n-51\t 0 1 expected unexpected");
plasp::utils::Parser p("input", s); plasp::utils::Parser p("input", s);
ASSERT_TRUE(p.isCaseSensitive());
ASSERT_EQ(p.parse<std::string>(), "identifier"); ASSERT_EQ(p.parse<std::string>(), "identifier");
ASSERT_EQ(p.parse<size_t>(), 5u); ASSERT_EQ(p.parse<size_t>(), 5u);
ASSERT_EQ(p.parse<int>(), -51); ASSERT_EQ(p.parse<int>(), -51);