Remove duplicated tests from System.Text.Json.Tests (#36483)
authorDavid Cantu <dacantu@microsoft.com>
Tue, 19 May 2020 22:54:13 +0000 (15:54 -0700)
committerGitHub <noreply@github.com>
Tue, 19 May 2020 22:54:13 +0000 (15:54 -0700)
src/libraries/System.Text.Json/tests/JsonDateTimeTestData.cs
src/libraries/System.Text.Json/tests/JsonGuidTestData.cs
src/libraries/System.Text.Json/tests/Utf8JsonReaderTests.cs

index 7ff20c7..d172726 100644 (file)
@@ -42,7 +42,6 @@ namespace System.Text.Json.Tests
             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 @@ namespace System.Text.Json.Tests
             // 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 @@ namespace System.Text.Json.Tests
             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\"" };
index 26fd675..bb74e59 100644 (file)
@@ -35,16 +35,40 @@ namespace System.Text.Json.Tests
 
         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
@@ -72,25 +96,6 @@ namespace System.Text.Json.Tests
                     }
                 }
 
-                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}$" };
index 392eeb1..3b80897 100644 (file)
@@ -4380,7 +4380,6 @@ namespace System.Text.Json.Tests
                     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},