1
0
mirror of https://github.com/nlohmann/json synced 2024-12-11 04:00:07 +00:00

Fixed suffixing .0 and modified the unit tests accordingly

This commit is contained in:
Alex Astashyn 2016-12-04 01:38:23 -05:00
parent 21cae35930
commit 2197856395
3 changed files with 9 additions and 7 deletions

View File

@ -6520,8 +6520,9 @@ class basic_json
const bool value_is_int_like = const bool value_is_int_like =
std::find_if(m_buf.begin(), data_end, std::find_if(m_buf.begin(), data_end,
[](const char c) [](const char c)
{ return (c >= '0' and c <= '9') { return c == '.'
or c == '-'; }) or c == 'e'
or c == 'E'; })
== data_end; == data_end;
assert(data_end + 2 < m_buf.end()); assert(data_end + 2 < m_buf.end());

View File

@ -6520,8 +6520,9 @@ class basic_json
const bool value_is_int_like = const bool value_is_int_like =
std::find_if(m_buf.begin(), data_end, std::find_if(m_buf.begin(), data_end,
[](const char c) [](const char c)
{ return (c >= '0' and c <= '9') { return c == '.'
or c == '-'; }) or c == 'e'
or c == 'E'; })
== data_end; == data_end;
assert(data_end + 2 < m_buf.end()); assert(data_end + 2 < m_buf.end());

View File

@ -394,9 +394,9 @@ TEST_CASE("regression tests")
//issue #230 //issue #230
//CHECK(j2b.dump() == "23.42"); //CHECK(j2b.dump() == "23.42");
CHECK(j3a.dump() == "10000"); CHECK(j3a.dump() == "10000.0");
CHECK(j3b.dump() == "10000"); CHECK(j3b.dump() == "10000.0");
CHECK(j3c.dump() == "10000"); CHECK(j3c.dump() == "10000.0");
//CHECK(j3b.dump() == "1E04"); // roundtrip error //CHECK(j3b.dump() == "1E04"); // roundtrip error
//CHECK(j3c.dump() == "1e04"); // roundtrip error //CHECK(j3c.dump() == "1e04"); // roundtrip error
} }