File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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);
Original file line number Diff line number Diff 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
6773TEST (JsonParserTest, LexicalUnhappyTest1) {
6874 std::stringstream ss;
You can’t perform that action at this time.
0 commit comments