From: Stephen Toub Date: Mon, 4 Nov 2019 17:58:22 +0000 (-0500) Subject: Reduce System.Text.Json test count from ~150K to ~11K (dotnet/corefx#42365) X-Git-Tag: submit/tizen/20210909.063632~11031^2~96 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=48afd364c6937d88b97ce90feb931ec68e214325;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Reduce System.Text.Json test count from ~150K to ~11K (dotnet/corefx#42365) One theory was added with ~140K inputs and is causing our infrastructure to go haywire. Commit migrated from https://github.com/dotnet/corefx/commit/9862cf5e1d1a73a5e62beef8edc2fc1f0f7e5d60 --- diff --git a/src/libraries/System.Text.Json/tests/Serialization/DictionaryTests.cs b/src/libraries/System.Text.Json/tests/Serialization/DictionaryTests.cs index a5175a6d29f..c1163c4b117 100644 --- a/src/libraries/System.Text.Json/tests/Serialization/DictionaryTests.cs +++ b/src/libraries/System.Text.Json/tests/Serialization/DictionaryTests.cs @@ -512,84 +512,89 @@ namespace System.Text.Json.Serialization.Tests yield return new object[] { type, invalidJson }; } } + + yield return new object[] { typeof(int[]), @"""test""" }; + yield return new object[] { typeof(int[]), @"1" }; + yield return new object[] { typeof(int[]), @"false" }; + yield return new object[] { typeof(int[]), @"{}" }; + yield return new object[] { typeof(int[]), @"{""test"": 1}" }; + yield return new object[] { typeof(int[]), @"[""test""" }; + yield return new object[] { typeof(int[]), @"[""test""]" }; + yield return new object[] { typeof(int[]), @"[true]" }; + yield return new object[] { typeof(int[]), @"[{}]" }; + yield return new object[] { typeof(int[]), @"[[]]" }; + yield return new object[] { typeof(int[]), @"[{""test"": 1}]" }; + yield return new object[] { typeof(int[]), @"[[true]]" }; + yield return new object[] { typeof(Dictionary), @"{""test"": {}}" }; + yield return new object[] { typeof(Dictionary), @"{""test"": {""test"": 1}}" }; + yield return new object[] { typeof(Dictionary), @"{""test"": ""test""}" }; + yield return new object[] { typeof(Dictionary), @"{""test"": 1}" }; + yield return new object[] { typeof(Dictionary), @"{""test"": true}" }; + yield return new object[] { typeof(Dictionary), @"{""test"": [""test""}" }; + yield return new object[] { typeof(Dictionary), @"{""test"": [""test""]}" }; + yield return new object[] { typeof(Dictionary), @"{""test"": [[]]}" }; + yield return new object[] { typeof(Dictionary), @"{""test"": [true]}" }; + yield return new object[] { typeof(Dictionary), @"{""test"": [{}]}" }; + yield return new object[] { typeof(ClassWithIntArray), @"{""Obj"": ""test""}" }; + yield return new object[] { typeof(ClassWithIntArray), @"{""Obj"": 1}" }; + yield return new object[] { typeof(ClassWithIntArray), @"{""Obj"": false}" }; + yield return new object[] { typeof(ClassWithIntArray), @"{""Obj"": {}}" }; + yield return new object[] { typeof(ClassWithIntArray), @"{""Obj"": {""test"": 1}}" }; + yield return new object[] { typeof(ClassWithIntArray), @"{""Obj"": [""test""}" }; + yield return new object[] { typeof(ClassWithIntArray), @"{""Obj"": [""test""]}" }; + yield return new object[] { typeof(ClassWithIntArray), @"{""Obj"": [true]}" }; + yield return new object[] { typeof(ClassWithIntArray), @"{""Obj"": [{}]}" }; + yield return new object[] { typeof(ClassWithIntArray), @"{""Obj"": [[]]}" }; + yield return new object[] { typeof(ClassWithIntArray), @"{""Obj"": [{""test"": 1}]}" }; + yield return new object[] { typeof(ClassWithIntArray), @"{""Obj"": [[true]]}" }; + yield return new object[] { typeof(Dictionary), @"""test""" }; + yield return new object[] { typeof(Dictionary), @"1" }; + yield return new object[] { typeof(Dictionary), @"false" }; + yield return new object[] { typeof(Dictionary), @"{"""": 1}" }; + yield return new object[] { typeof(Dictionary), @"{"""": {}}" }; + yield return new object[] { typeof(Dictionary), @"{"""": {"""":""""}}" }; + yield return new object[] { typeof(Dictionary), @"[""test""" }; + yield return new object[] { typeof(Dictionary), @"[""test""]" }; + yield return new object[] { typeof(Dictionary), @"[true]" }; + yield return new object[] { typeof(Dictionary), @"[{}]" }; + yield return new object[] { typeof(Dictionary), @"[[]]" }; + yield return new object[] { typeof(Dictionary), @"[{""test"": 1}]" }; + yield return new object[] { typeof(Dictionary), @"[[true]]" }; + yield return new object[] { typeof(ClassWithDictionaryOfIntArray), @"{""Obj"":""test""}" }; + yield return new object[] { typeof(ClassWithDictionaryOfIntArray), @"{""Obj"":1}" }; + yield return new object[] { typeof(ClassWithDictionaryOfIntArray), @"{""Obj"":false}" }; + yield return new object[] { typeof(ClassWithDictionaryOfIntArray), @"{""Obj"":{"""": 1}}" }; + yield return new object[] { typeof(ClassWithDictionaryOfIntArray), @"{""Obj"":{"""": {}}}" }; + yield return new object[] { typeof(ClassWithDictionaryOfIntArray), @"{""Obj"":{"""": {"""":""""}}}" }; + yield return new object[] { typeof(ClassWithDictionaryOfIntArray), @"{""Obj"":[""test""}" }; + yield return new object[] { typeof(ClassWithDictionaryOfIntArray), @"{""Obj"":[""test""]}" }; + yield return new object[] { typeof(ClassWithDictionaryOfIntArray), @"{""Obj"":[true]}" }; + yield return new object[] { typeof(ClassWithDictionaryOfIntArray), @"{""Obj"":[{}]}" }; + yield return new object[] { typeof(ClassWithDictionaryOfIntArray), @"{""Obj"":[[]]}" }; + yield return new object[] { typeof(ClassWithDictionaryOfIntArray), @"{""Obj"":[{""test"": 1}]}" }; + yield return new object[] { typeof(ClassWithDictionaryOfIntArray), @"{""Obj"":[[true]]}" }; + yield return new object[] { typeof(Dictionary), @"{""key"":[{""Id"":3}]}" }; + yield return new object[] { typeof(Dictionary), @"{""key"":[""test""]}" }; + yield return new object[] { typeof(Dictionary), @"{""key"":[1]}" }; + yield return new object[] { typeof(Dictionary), @"{""key"":[false]}" }; + yield return new object[] { typeof(Dictionary), @"{""key"":[]}" }; + yield return new object[] { typeof(Dictionary), @"{""key"":1}" }; + yield return new object[] { typeof(Dictionary>), @"{""key"":{""Id"":3}}" }; + yield return new object[] { typeof(Dictionary>), @"{""key"":{}}" }; + yield return new object[] { typeof(Dictionary>), @"{""key"":[[]]}" }; + yield return new object[] { typeof(Dictionary>), @"{""key"":[]}" }; + yield return new object[] { typeof(Dictionary>), @"{""key"":1}" }; } - [Theory] - [MemberData(nameof(DataForInvalidJsonForTypeTests))] - [InlineData(typeof(int[]), @"""test""")] - [InlineData(typeof(int[]), @"1")] - [InlineData(typeof(int[]), @"false")] - [InlineData(typeof(int[]), @"{}")] - [InlineData(typeof(int[]), @"{""test"": 1}")] - [InlineData(typeof(int[]), @"[""test""")] - [InlineData(typeof(int[]), @"[""test""]")] - [InlineData(typeof(int[]), @"[true]")] - [InlineData(typeof(int[]), @"[{}]")] - [InlineData(typeof(int[]), @"[[]]")] - [InlineData(typeof(int[]), @"[{""test"": 1}]")] - [InlineData(typeof(int[]), @"[[true]]")] - [InlineData(typeof(Dictionary), @"{""test"": {}}")] - [InlineData(typeof(Dictionary), @"{""test"": {""test"": 1}}")] - [InlineData(typeof(Dictionary), @"{""test"": ""test""}")] - [InlineData(typeof(Dictionary), @"{""test"": 1}")] - [InlineData(typeof(Dictionary), @"{""test"": true}")] - [InlineData(typeof(Dictionary), @"{""test"": [""test""}")] - [InlineData(typeof(Dictionary), @"{""test"": [""test""]}")] - [InlineData(typeof(Dictionary), @"{""test"": [[]]}")] - [InlineData(typeof(Dictionary), @"{""test"": [true]}")] - [InlineData(typeof(Dictionary), @"{""test"": [{}]}")] - [InlineData(typeof(ClassWithIntArray), @"{""Obj"": ""test""}")] - [InlineData(typeof(ClassWithIntArray), @"{""Obj"": 1}")] - [InlineData(typeof(ClassWithIntArray), @"{""Obj"": false}")] - [InlineData(typeof(ClassWithIntArray), @"{""Obj"": {}}")] - [InlineData(typeof(ClassWithIntArray), @"{""Obj"": {""test"": 1}}")] - [InlineData(typeof(ClassWithIntArray), @"{""Obj"": [""test""}")] - [InlineData(typeof(ClassWithIntArray), @"{""Obj"": [""test""]}")] - [InlineData(typeof(ClassWithIntArray), @"{""Obj"": [true]}")] - [InlineData(typeof(ClassWithIntArray), @"{""Obj"": [{}]}")] - [InlineData(typeof(ClassWithIntArray), @"{""Obj"": [[]]}")] - [InlineData(typeof(ClassWithIntArray), @"{""Obj"": [{""test"": 1}]}")] - [InlineData(typeof(ClassWithIntArray), @"{""Obj"": [[true]]}")] - [InlineData(typeof(Dictionary), @"""test""")] - [InlineData(typeof(Dictionary), @"1")] - [InlineData(typeof(Dictionary), @"false")] - [InlineData(typeof(Dictionary), @"{"""": 1}")] - [InlineData(typeof(Dictionary), @"{"""": {}}")] - [InlineData(typeof(Dictionary), @"{"""": {"""":""""}}")] - [InlineData(typeof(Dictionary), @"[""test""")] - [InlineData(typeof(Dictionary), @"[""test""]")] - [InlineData(typeof(Dictionary), @"[true]")] - [InlineData(typeof(Dictionary), @"[{}]")] - [InlineData(typeof(Dictionary), @"[[]]")] - [InlineData(typeof(Dictionary), @"[{""test"": 1}]")] - [InlineData(typeof(Dictionary), @"[[true]]")] - [InlineData(typeof(ClassWithDictionaryOfIntArray), @"{""Obj"":""test""}")] - [InlineData(typeof(ClassWithDictionaryOfIntArray), @"{""Obj"":1}")] - [InlineData(typeof(ClassWithDictionaryOfIntArray), @"{""Obj"":false}")] - [InlineData(typeof(ClassWithDictionaryOfIntArray), @"{""Obj"":{"""": 1}}")] - [InlineData(typeof(ClassWithDictionaryOfIntArray), @"{""Obj"":{"""": {}}}")] - [InlineData(typeof(ClassWithDictionaryOfIntArray), @"{""Obj"":{"""": {"""":""""}}}")] - [InlineData(typeof(ClassWithDictionaryOfIntArray), @"{""Obj"":[""test""}")] - [InlineData(typeof(ClassWithDictionaryOfIntArray), @"{""Obj"":[""test""]}")] - [InlineData(typeof(ClassWithDictionaryOfIntArray), @"{""Obj"":[true]}")] - [InlineData(typeof(ClassWithDictionaryOfIntArray), @"{""Obj"":[{}]}")] - [InlineData(typeof(ClassWithDictionaryOfIntArray), @"{""Obj"":[[]]}")] - [InlineData(typeof(ClassWithDictionaryOfIntArray), @"{""Obj"":[{""test"": 1}]}")] - [InlineData(typeof(ClassWithDictionaryOfIntArray), @"{""Obj"":[[true]]}")] - [InlineData(typeof(Dictionary), @"{""key"":[{""Id"":3}]}")] - [InlineData(typeof(Dictionary), @"{""key"":[""test""]}")] - [InlineData(typeof(Dictionary), @"{""key"":[1]}")] - [InlineData(typeof(Dictionary), @"{""key"":[false]}")] - [InlineData(typeof(Dictionary), @"{""key"":[]}")] - [InlineData(typeof(Dictionary), @"{""key"":1}")] - [InlineData(typeof(Dictionary>), @"{""key"":{""Id"":3}}")] - [InlineData(typeof(Dictionary>), @"{""key"":{}}")] - [InlineData(typeof(Dictionary>), @"{""key"":[[]]}")] - [InlineData(typeof(Dictionary>), @"{""key"":[]}")] - [InlineData(typeof(Dictionary>), @"{""key"":1}")] - public static void InvalidJsonForTypeShouldFail(Type type, string invalidJson) - { - Assert.Throws(() => JsonSerializer.Deserialize(invalidJson, type)); + [Fact] + public static void InvalidJsonForTypeShouldFail() + { + foreach (object[] args in DataForInvalidJsonForTypeTests()) // ~140K tests, too many for theory to handle well with our infrastructure + { + var type = (Type)args[0]; + var invalidJson = (string)args[1]; + Assert.Throws(() => JsonSerializer.Deserialize(invalidJson, type)); + } } [Fact]