diff options
author | Benjamin Paassen <bpaassen@techfak.uni-bielefeld.de> | 2015-01-23 13:31:26 +0100 |
---|---|---|
committer | Benjamin Paassen <bpaassen@techfak.uni-bielefeld.de> | 2015-01-23 13:31:26 +0100 |
commit | adc37703cd6897bc98c4f1655dca0946880ae134 (patch) | |
tree | 7a5798f12f6c43b45bc0677fd1085f3197f9e5c9 | |
parent | 78bdb210ad81edd0ba41a6adfc4797b1ccc62228 (diff) |
corrected a bug in parseGeneric
-rw-r--r-- | src/core/common/VariantReader.cpp | 1 | ||||
-rw-r--r-- | test/core/common/VariantReaderTest.cpp | 7 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/core/common/VariantReader.cpp b/src/core/common/VariantReader.cpp index 600fd9b..db82954 100644 --- a/src/core/common/VariantReader.cpp +++ b/src/core/common/VariantReader.cpp @@ -563,6 +563,7 @@ std::pair<bool, Variant> VariantReader::parseGenericToken( // Parse a string if a quote is reached if (c == '"' || c == '\'') { + reader.resetPeek(); auto res = parseString(reader, logger); return std::make_pair(res.first, res.second.c_str()); } diff --git a/test/core/common/VariantReaderTest.cpp b/test/core/common/VariantReaderTest.cpp index 9a9b694..cfdb1a0 100644 --- a/test/core/common/VariantReaderTest.cpp +++ b/test/core/common/VariantReaderTest.cpp @@ -610,6 +610,13 @@ TEST(VariantReader, parseGenericToken) ASSERT_EQ("hello world", res.second.asString()); } + // String with whitespaces at the beginning. + { + CharReader reader(" \' test\'"); + auto res = VariantReader::parseGenericToken(reader, logger, {';'}, true); + ASSERT_EQ(" test", res.second); + } + // Integer { CharReader reader("1234"); |