Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove duplicated tests from System.Text.Json.Tests #36483

Merged
merged 1 commit into from
May 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/libraries/System.Text.Json/tests/JsonDateTimeTestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public static IEnumerable<object[]> 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" };
Expand Down Expand Up @@ -153,7 +152,6 @@ public static IEnumerable<object[]> 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\"" };
Expand All @@ -168,7 +166,6 @@ public static IEnumerable<object[]> 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\"" };
Expand Down
55 changes: 30 additions & 25 deletions src/libraries/System.Text.Json/tests/JsonGuidTestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,40 @@ public static IEnumerable<object[]> ValidHexGuidTests()

public static IEnumerable<object[]> 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
Expand Down Expand Up @@ -72,25 +96,6 @@ public static IEnumerable<object[]> 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}$" };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4380,7 +4380,6 @@ public static IEnumerable<object[]> 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},
Expand Down