diff --git a/src/libraries/System.Text.Json/tests/JsonDateTimeTestData.cs b/src/libraries/System.Text.Json/tests/JsonDateTimeTestData.cs index 7ff20c7e1c125..d172726159a2d 100644 --- a/src/libraries/System.Text.Json/tests/JsonDateTimeTestData.cs +++ b/src/libraries/System.Text.Json/tests/JsonDateTimeTestData.cs @@ -42,7 +42,6 @@ public static IEnumerable ValidISO8601Tests() yield return new object[] { "\"1997-07-16T19:20:30.6666660\"", "1997-07-16T19:20:30.666666" }; // Test fraction truncation. - yield return new object[] { "\"1997-07-16T19:20:30.0000000\"", "1997-07-16T19:20:30" }; yield return new object[] { "\"1997-07-16T19:20:30.00000001\"", "1997-07-16T19:20:30" }; yield return new object[] { "\"1997-07-16T19:20:30.000000001\"", "1997-07-16T19:20:30" }; yield return new object[] { "\"1997-07-16T19:20:30.77777770\"", "1997-07-16T19:20:30.7777777" }; @@ -153,7 +152,6 @@ public static IEnumerable InvalidISO8601Tests() // Invalid fractions. yield return new object[] { "\"1997-07-16T19.45\"" }; yield return new object[] { "\"1997-07-16T19:20.45\"" }; - yield return new object[] { "\"1997-07-16T19:20:30a\"" }; yield return new object[] { "\"1997-07-16T19:20:30,45\"" }; yield return new object[] { "\"1997-07-16T19:20:30.\"" }; yield return new object[] { "\"1997-07-16T19:20:30.a\"" }; @@ -168,7 +166,6 @@ public static IEnumerable InvalidISO8601Tests() yield return new object[] { "\"1997-07-16T19:20:30.4555555+01Z\"" }; yield return new object[] { "\"1997-07-16T19:20:30.4555555+01:\"" }; yield return new object[] { "\"1997-07-16T19:20:30.4555555 +01:00\"" }; - yield return new object[] { "\"1997-07-16T19:20:30.4555555+01:\"" }; yield return new object[] { "\"1997-07-16T19:20:30.4555555- 01:00\"" }; yield return new object[] { "\"1997-07-16T19:20:30.4555555+04 :30\"" }; yield return new object[] { "\"1997-07-16T19:20:30.4555555-04: 30\"" }; diff --git a/src/libraries/System.Text.Json/tests/JsonGuidTestData.cs b/src/libraries/System.Text.Json/tests/JsonGuidTestData.cs index 26fd675487085..bb74e59511b34 100644 --- a/src/libraries/System.Text.Json/tests/JsonGuidTestData.cs +++ b/src/libraries/System.Text.Json/tests/JsonGuidTestData.cs @@ -35,16 +35,40 @@ public static IEnumerable ValidHexGuidTests() public static IEnumerable InvalidGuidTests() { + // Invalid formats + Guid testGuid = new Guid(s_guidStr); + yield return new object[] { testGuid.ToString("B", CultureInfo.InvariantCulture) }; + yield return new object[] { testGuid.ToString("P", CultureInfo.InvariantCulture) }; + yield return new object[] { testGuid.ToString("N", CultureInfo.InvariantCulture) }; + + yield return new object[] { new string('$', 1) }; + yield return new object[] { new string(' ', 1) }; + yield return new object[] { new string('$', s_guidStr.Length) }; + yield return new object[] { new string(' ', s_guidStr.Length) }; + + for (int truncationPoint = 1; truncationPoint < s_guidStr.Length - 1; truncationPoint++) + { + string truncatedText = s_guidStr.Substring(0, truncationPoint); + + // Stop short + yield return new object[] { truncatedText }; + + // Append junk + yield return new object[] { truncatedText.PadRight(s_guidStr.Length, '$') }; + yield return new object[] { truncatedText.PadRight(s_guidStr.Length, ' ') }; + yield return new object[] { truncatedText.PadRight(truncatedText.Length + 1, '$') }; + yield return new object[] { truncatedText.PadRight(truncatedText.Length + 1, ' ') }; + // Prepend junk + yield return new object[] { truncatedText.PadLeft(s_guidStr.Length, '$') }; + yield return new object[] { truncatedText.PadLeft(s_guidStr.Length, ' ') }; + yield return new object[] { truncatedText.PadLeft(truncatedText.Length + 1, '$') }; + yield return new object[] { truncatedText.PadLeft(truncatedText.Length + 1, ' ') }; + } + foreach (object[] guid in ValidGuidTests()) { string guidStr = (string)guid[0]; - // Invalid formats - Guid testGuid = new Guid(guidStr); - yield return new object[] { testGuid.ToString("B", CultureInfo.InvariantCulture) }; - yield return new object[] { testGuid.ToString("P", CultureInfo.InvariantCulture) }; - yield return new object[] { testGuid.ToString("N", CultureInfo.InvariantCulture) }; - for (int i = 0; i < guidStr.Length; i++) { // Corrupt one character @@ -72,25 +96,6 @@ public static IEnumerable InvalidGuidTests() } } - for (int truncationPoint = 0; truncationPoint < guidStr.Length; truncationPoint++) - { - string truncatedText = guidStr.Substring(0, truncationPoint); - - // Stop short - yield return new object[] { truncatedText }; - - // Append junk - yield return new object[] { truncatedText.PadRight(guidStr.Length, '$') }; - yield return new object[] { truncatedText.PadRight(guidStr.Length, ' ') }; - yield return new object[] { truncatedText.PadRight(truncatedText.Length + 1, '$') }; - yield return new object[] { truncatedText.PadRight(truncatedText.Length + 1, ' ') }; - // Prepend junk - yield return new object[] { truncatedText.PadLeft(guidStr.Length, '$') }; - yield return new object[] { truncatedText.PadLeft(guidStr.Length, ' ') }; - yield return new object[] { truncatedText.PadLeft(truncatedText.Length + 1, '$') }; - yield return new object[] { truncatedText.PadLeft(truncatedText.Length + 1, ' ') }; - } - // Too long yield return new object[] { $"{guidStr} " }; yield return new object[] { $"{guidStr}$" }; diff --git a/src/libraries/System.Text.Json/tests/Utf8JsonReaderTests.cs b/src/libraries/System.Text.Json/tests/Utf8JsonReaderTests.cs index 392eeb1cc9dd1..3b80897e1ed94 100644 --- a/src/libraries/System.Text.Json/tests/Utf8JsonReaderTests.cs +++ b/src/libraries/System.Text.Json/tests/Utf8JsonReaderTests.cs @@ -4380,7 +4380,6 @@ public static IEnumerable InvalidJsonStrings new object[] {"+0", 0, 0}, new object[] {"+1", 0, 0}, new object[] {"0e", 0, 2}, - new object[] {"0.", 0, 2}, new object[] {"0.1e", 0, 4}, new object[] {"01", 0, 1}, new object[] {"1a", 0, 1},