Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lldb] Correctly escape newlines and backslashes in the JSON serializer
JSON serializer fails to escape newlines and backslashes. Let's fix that. Differential Revision: https://reviews.llvm.org/D34322 llvm-svn: 311483
- Loading branch information
1 parent
6bb45f7
commit 20bce85
Showing
4 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include "gtest/gtest.h" | ||
|
||
#include "lldb/Core/StreamString.h" | ||
#include "lldb/Utility/JSON.h" | ||
|
||
using namespace lldb_private; | ||
|
||
TEST(JSONTest, Dictionary) { | ||
JSONObject o; | ||
o.SetObject("key", std::make_shared<JSONString>("value")); | ||
|
||
StreamString stream; | ||
o.Write(stream); | ||
|
||
ASSERT_EQ(stream.GetString(), R"({"key":"value"})"); | ||
} | ||
|
||
TEST(JSONTest, Newlines) { | ||
JSONObject o; | ||
o.SetObject("key", std::make_shared<JSONString>("hello\nworld")); | ||
|
||
StreamString stream; | ||
o.Write(stream); | ||
|
||
ASSERT_EQ(stream.GetString(), R"({"key":"hello\nworld"})"); | ||
} |