Skip to content

Commit 2ba89ea

Browse files
authored
Merge pull request #26 from PANFACTORY/feature/#25
Feature/#25
2 parents 8fb1ad2 + eb7f818 commit 2ba89ea

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/lexer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ namespace JsonParser {
7272
ch = ss.get();
7373
}
7474
str = str.substr(0, str.find_last_not_of(" \f\t\v\r\n") + 1);
75-
if (!std::regex_match(str, std::regex("-?(0|[1-9]\\d*)(\\.\\d+)?(e[-+](0|[1-9]\\d*)(\\.\\d+)?)?"))) {
75+
if (!std::regex_match(str, std::regex("-?(0|[1-9]\\d*)(\\.\\d+)?(e[-+]?(0|[1-9]\\d*)(\\.\\d+)?)?"))) {
7676
throw std::runtime_error("At LexicalAnalyzer(): \"str\" is not a number.");
7777
}
7878
chs.push_back(str);

test/lexer_test.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ TEST(JsonParserTest, LexicalHappyTest10) {
6363
ASSERT_EQ(JsonParser::Lexer(ss).size(), 5);
6464
}
6565

66+
TEST(JsonParserTest, LexicalHappyTest11) {
67+
std::stringstream ss;
68+
ss << R"({ "number": 1e4 })";
69+
ASSERT_EQ(JsonParser::Lexer(ss).size(), 5);
70+
}
71+
6672
// Unhappy path testing
6773
TEST(JsonParserTest, LexicalUnhappyTest1) {
6874
std::stringstream ss;

0 commit comments

Comments
 (0)