Skip to content

Commit f40d227

Browse files
Address PR feedback: remove implementation details and add JSON content validation
Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
1 parent c219e4c commit f40d227

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ public static void TimeOnly_Write_Success(string value, string? expectedValue =
192192
public static void Int128_AsDictionaryKey_SerializesCorrectly()
193193
{
194194
// Regression test for https://github.com/dotnet/runtime/issues/116855
195-
// Int128Converter.WriteAsPropertyNameCore was passing unsliced buffer to WritePropertyName
196195
var dict = new Dictionary<Int128, string>
197196
{
198197
[0] = "Zero",
@@ -204,6 +203,14 @@ public static void Int128_AsDictionaryKey_SerializesCorrectly()
204203

205204
string json = JsonSerializer.Serialize(dict);
206205

206+
// Validate JSON content contains expected keys and no junk data
207+
Assert.Contains("\"0\"", json);
208+
Assert.Contains("\"1\"", json);
209+
Assert.Contains("\"-1\"", json);
210+
Assert.Contains("\"170141183460469231731687303715884105727\"", json); // Int128.MaxValue
211+
Assert.Contains("\"-170141183460469231731687303715884105728\"", json); // Int128.MinValue
212+
Assert.DoesNotContain('\0', json); // No null characters (junk data)
213+
207214
// E2E validation: should roundtrip correctly without any junk data
208215
var deserialized = JsonSerializer.Deserialize<Dictionary<Int128, string>>(json);
209216
Assert.Equal(dict, deserialized);

0 commit comments

Comments
 (0)