diff options
| author | ras0219 <533828+ras0219@users.noreply.github.com> | 2020-09-07 15:50:20 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-07 15:50:20 -0700 |
| commit | 0d0a84694c8c939e7ac12cae3975dd4c18ca71ec (patch) | |
| tree | 365c1e5265b38c30a8bd9cc5b88af6732cbb8714 /toolsrc/src/vcpkg-test/json.cpp | |
| parent | 46a129decbe22fd93b5c6a3280d270c51661a273 (diff) | |
| download | vcpkg-0d0a84694c8c939e7ac12cae3975dd4c18ca71ec.tar.gz vcpkg-0d0a84694c8c939e7ac12cae3975dd4c18ca71ec.zip | |
[vcpkg] Improve Json error messages (#12981)
* [vcpkg] Fix error reporting on json parse failure
* [vcpkg] Track manifest path for use in diagnostics
* [vcpkg] Use by-value for consumer API. Improve trailing comma diagnostic.
* [vcpkg] Track errors directly inside Json::Reader
* [vcpkg] Fixup use of .u8string()
Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
Diffstat (limited to 'toolsrc/src/vcpkg-test/json.cpp')
| -rw-r--r-- | toolsrc/src/vcpkg-test/json.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/toolsrc/src/vcpkg-test/json.cpp b/toolsrc/src/vcpkg-test/json.cpp index 0b9941861..6858a5ac8 100644 --- a/toolsrc/src/vcpkg-test/json.cpp +++ b/toolsrc/src/vcpkg-test/json.cpp @@ -28,8 +28,8 @@ static std::string mystringify(const Value& val) { return Json::stringify(val, J TEST_CASE ("JSON stringify weird strings", "[json]") { - vcpkg::StringView str = U8_STR("😀 😁 😂 🤣 😃 😄 😅 😆 😉"); - REQUIRE(mystringify(Value::string(str)) == ('"' + str.to_string() + "\"\n")); + std::string str = U8_STR("😀 😁 😂 🤣 😃 😄 😅 😆 😉"); + REQUIRE(mystringify(Value::string(str)) == ('"' + str + "\"\n")); REQUIRE(mystringify(Value::string("\xED\xA0\x80")) == "\"\\ud800\"\n"); // unpaired surrogate } @@ -228,3 +228,14 @@ TEST_CASE ("JSON parse full file", "[json]") } REQUIRE(res); } + +TEST_CASE ("JSON track newlines", "[json]") +{ + auto res = Json::parse("{\n,", fs::u8path("filename")); + REQUIRE(!res); + REQUIRE(res.error()->format() == + R"(Error: filename:2:1: Unexpected character; expected property name + on expression: , + ^ +)"); +} |
