From 85a30813c8d9b0eccefcdc59e9e4e602a7fffae7 Mon Sep 17 00:00:00 2001 From: Niels Date: Sat, 7 May 2016 20:22:58 +0200 Subject: [PATCH] removed unnecessary code (numbers must not begin with "+") --- README.md | 2 +- src/json.hpp | 4 ---- src/json.hpp.re2c | 4 ---- test/unit.cpp | 4 ++++ 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index f8cb20d6..c9f3a713 100644 --- a/README.md +++ b/README.md @@ -449,7 +449,7 @@ $ make $ ./json_unit "*" =============================================================================== -All tests passed (5568703 assertions in 31 test cases) +All tests passed (5568705 assertions in 31 test cases) ``` For more information, have a look at the file [.travis.yml](https://github.com/nlohmann/json/blob/master/.travis.yml). diff --git a/src/json.hpp b/src/json.hpp index 932ab9e5..51536550 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -8448,10 +8448,6 @@ basic_json_parser_63: { type = value_t::number_unsigned; max = static_cast(std::numeric_limits::max()); - if (*curptr == '+') - { - curptr++; - } } // count the significant figures diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index 77a1eea9..c8b66e92 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -7758,10 +7758,6 @@ class basic_json { type = value_t::number_unsigned; max = static_cast(std::numeric_limits::max()); - if (*curptr == '+') - { - curptr++; - } } // count the significant figures diff --git a/test/unit.cpp b/test/unit.cpp index de00166f..9b735108 100644 --- a/test/unit.cpp +++ b/test/unit.cpp @@ -9776,6 +9776,10 @@ TEST_CASE("parser class") CHECK_THROWS_AS(json::parser("-0e-:").parse(), std::invalid_argument); CHECK_THROWS_AS(json::parser("-0f").parse(), std::invalid_argument); + // numbers must not begin with "+" + CHECK_THROWS_AS(json::parser("+1").parse(), std::invalid_argument); + CHECK_THROWS_AS(json::parser("+0").parse(), std::invalid_argument); + CHECK_THROWS_WITH(json::parser("01").parse(), "parse error - unexpected number literal; expected end of input"); CHECK_THROWS_WITH(json::parser("--1").parse(), "parse error - unexpected '-'");