Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
Add test to verify that JsonEncodedText and Utf8JsonWriter use upper-…
Browse files Browse the repository at this point in the history
…case hex digits when escaping (2). (#42566)

* Add test to verify that JsonEncodedText and Utf8JsonWriter use
upper-case hex digits when escaping.

* Add test to verify that JsonEncodedText and Utf8JsonWriter use
upper-case hex digits when escaping.

* Fix spacing issue in expected text.
  • Loading branch information
ahsonkhan authored and msftbot[bot] committed Nov 13, 2019
1 parent ac02476 commit 6878693
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/System.Text.Json/tests/Utf8JsonWriterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4661,6 +4661,24 @@ public void Utf16SurrogatePairReplacement_ValidPropertyName_ValidValue(bool skip
JsonTestHelper.AssertContents("{" + ValidUtf16Expected + ":" + ValidUtf16Expected + "}", output);
}

// Test case from https://github.com/dotnet/corefx/issues/40702
[Fact]
public void OutputConsistentWithJsonEncodedText()
{
string jsonEncodedText = $"{{\"{JsonEncodedText.Encode("propertyName+1")}\":\"{JsonEncodedText.Encode("value+1")}\"}}";

var output = new ArrayBufferWriter<byte>(1024);

using (var writer = new Utf8JsonWriter(output))
{
writer.WriteStartObject();
writer.WriteString("propertyName+1", "value+1");
writer.WriteEndObject();
}

JsonTestHelper.AssertContents(jsonEncodedText, output);
}

public static IEnumerable<object[]> JsonEncodedTextStringsCustomAll
{
get
Expand Down

0 comments on commit 6878693

Please sign in to comment.