Skip to content

Commit

Permalink
fixed a bug that was found in the discussion of #274
Browse files Browse the repository at this point in the history
  • Loading branch information
nlohmann committed Jul 22, 2016
1 parent 51a3829 commit ddfe86c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7283,7 +7283,7 @@ class basic_json
explicit lexer(const string_t& s) noexcept
: m_stream(nullptr), m_buffer(s)
{
m_content = reinterpret_cast<const lexer_char_t*>(s.c_str());
m_content = reinterpret_cast<const lexer_char_t*>(m_buffer.c_str());
assert(m_content != nullptr);
m_start = m_cursor = m_content;
m_limit = m_content + s.size();
Expand Down
2 changes: 1 addition & 1 deletion src/json.hpp.re2c
Original file line number Diff line number Diff line change
Expand Up @@ -7283,7 +7283,7 @@ class basic_json
explicit lexer(const string_t& s) noexcept
: m_stream(nullptr), m_buffer(s)
{
m_content = reinterpret_cast<const lexer_char_t*>(s.c_str());
m_content = reinterpret_cast<const lexer_char_t*>(m_buffer.c_str());
assert(m_content != nullptr);
m_start = m_cursor = m_content;
m_limit = m_content + s.size();
Expand Down
8 changes: 8 additions & 0 deletions test/src/unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10359,6 +10359,14 @@ TEST_CASE("parser class")
CHECK(j_empty_array == json());
}
}

SECTION("copy constructor")
{
json::string_t* s = new json::string_t("[1,2,3,4]");
json::parser p(*s);
delete s;
CHECK(p.parse() == json({1, 2, 3, 4}));
}
}

TEST_CASE("README", "[hide]")
Expand Down

0 comments on commit ddfe86c

Please sign in to comment.