Author fuzz tests and fix a comment-related issue (#2935)

Co-authored-by: James Newton-King <james@newtonking.com>
This commit is contained in:
George Pollard
2024-04-17 08:22:10 +08:00
committed by GitHub
co-authored by James Newton-King
parent 55a7204f9b
commit 2eaa475f88
7 changed files with 288 additions and 7 deletions
@@ -1699,7 +1699,8 @@ null//comment
w.WriteToken(r, true);
StringAssert.AreEqual(@"/*comment*//*hi*/*/{/*comment*/
StringAssert.AreEqual(@"//comment*//*hi*/
{/*comment*/
""Name"": /*comment*/ true/*comment after true*//*comment after comma*/,
""ExpiryDate"": /*comment*/ new Constructor(
/*comment*/,
@@ -1715,6 +1716,20 @@ null//comment
}/*comment *//*comment 1 */", sw.ToString());
}
[Test]
public void NewlinesInSingleLineComments()
{
// it’s not possible for this to be created by parsing JSON,
// but if someone gets creative with the API…
var sw = new StringWriter();
using (var w = new JsonTextWriter(sw))
{
w.WriteComment("*/\nsomething else");
}
StringAssert.AreEqual("//*/\n//something else\n", sw.ToString());
}
[Test]
public void DisposeSupressesFinalization()
{
@@ -1820,4 +1835,4 @@ null//comment
throw new NotImplementedException();
}
}
}
}