Exemplo n.º 1
0
        public void NumberRegressionTest()
        {
            // regression test - the value 0.00085647800000000004 was being incorrectly rejected
            string numberValueString = "0.00085647800000000004";

            JsonNavigatorTests.VerifyNavigator(numberValueString);
        }
Exemplo n.º 2
0
 public void Int64Test()
 {
     long[] values = new long[] { long.MinValue, long.MinValue + 1, -1, 0, 1, long.MaxValue, long.MaxValue - 1 };
     foreach (long value in values)
     {
         string input = $"LL{value}";
         JsonNavigatorTests.VerifyNavigator(input);
     }
 }
Exemplo n.º 3
0
 public void Int16Test()
 {
     short[] values = new short[] { short.MinValue, short.MinValue + 1, -1, 0, 1, short.MaxValue, short.MaxValue - 1 };
     foreach (short value in values)
     {
         string input = $"H{value}";
         JsonNavigatorTests.VerifyNavigator(input);
     }
 }
Exemplo n.º 4
0
 public void Float32Test()
 {
     float[] values = new float[] { float.MinValue, float.MinValue + 1, 0, 1, float.MaxValue, float.MaxValue - 1 };
     foreach (float value in values)
     {
         string input = $"S{value.ToString("G9", CultureInfo.InvariantCulture)}";
         JsonNavigatorTests.VerifyNavigator(input);
     }
 }
Exemplo n.º 5
0
 public void Int32Test()
 {
     int[] values = new int[] { int.MinValue, int.MinValue + 1, -1, 0, 1, int.MaxValue, int.MaxValue - 1 };
     foreach (int value in values)
     {
         string input = $"L{value}";
         JsonNavigatorTests.VerifyNavigator(input);
     }
 }
Exemplo n.º 6
0
 public void Float64Test()
 {
     double[] values = new double[] { double.MinValue, double.MinValue + 1, 0, 1, double.MaxValue, double.MaxValue - 1 };
     foreach (double value in values)
     {
         string input = $"D{value.ToString("G17", CultureInfo.InvariantCulture)}";
         JsonNavigatorTests.VerifyNavigator(input);
     }
 }
Exemplo n.º 7
0
 public void GuidTest()
 {
     Guid[] values = new Guid[] { Guid.Empty, Guid.NewGuid() };
     foreach (Guid value in values)
     {
         string input = $"G{value.ToString()}";
         JsonNavigatorTests.VerifyNavigator(input);
     }
 }
Exemplo n.º 8
0
 public void Int8Test()
 {
     sbyte[] values = new sbyte[] { sbyte.MinValue, sbyte.MinValue + 1, -1, 0, 1, sbyte.MaxValue, sbyte.MaxValue - 1 };
     foreach (sbyte value in values)
     {
         string input = $"I{value}";
         JsonNavigatorTests.VerifyNavigator(input);
     }
 }
Exemplo n.º 9
0
 public void UInt32Test()
 {
     uint[] values = new uint[] { uint.MinValue, uint.MinValue + 1, 0, 1, uint.MaxValue, uint.MaxValue - 1 };
     foreach (uint value in values)
     {
         string input = $"UL{value}";
         JsonNavigatorTests.VerifyNavigator(input);
     }
 }
Exemplo n.º 10
0
        public void StrangeNumberArrayTest()
        {
            string input = @"[
                1111111110111111111011111111101111111110,
                1111111110111111111011111111101111111110111111111011111111101111111110,
               11111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110,
                1111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110
                    ]";

            JsonNavigatorTests.VerifyNavigator(input);
        }
Exemplo n.º 11
0
        private static void VerifyNavigatorWithCurratedDoc(string path, bool performExtraChecks = true)
        {
            path = string.Format("TestJsons/{0}", path);
            string json = TextFileConcatenation.ReadMultipartFile(path);

#if true
            json = JsonTestUtils.RandomSampleJson(json, maxNumberOfItems: 1);
#endif

            JsonNavigatorTests.VerifyNavigator(json, performExtraChecks);
        }
Exemplo n.º 12
0
        public void BinaryTest()
        {
            {
                // Empty Binary
                string input = $"B";
                JsonNavigatorTests.VerifyNavigator(input);
            }

            {
                // Binary 1 Byte Length
                IReadOnlyList <byte> binary = Enumerable.Range(0, 25).Select(x => (byte)x).ToList();
                string input = $"B{Convert.ToBase64String(binary.ToArray())}";
                JsonNavigatorTests.VerifyNavigator(input);
            }
        }
Exemplo n.º 13
0
        public void StrangeNumberArrayTest()
        {
            string input = @"[
                1111111110111111111011111111101111111110,
                1111111110111111111011111111101111111110111111111011111111101111111110,
                11111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110,
                1111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110
            ]";

            try
            {
                JsonNavigatorTests.VerifyNavigator(input);
            }
            catch (MaterilizationFailedToMatchException)
            {
                // Newtonsoft does not use IEEE double precision for these long integers.
            }
        }
Exemplo n.º 14
0
        public void AllPrimitivesObjectTest()
        {
            string input = @"{
                        ""id"": ""7029d079-4016-4436-b7da-36c0bae54ff6"",
                        ""double"": 0.18963001816981939,
                        ""int"": -1330192615,
                        ""string"": ""XCPCFXPHHF"",
                        ""boolean"": true,
                        ""null"": null,
                        ""datetime"": ""2526-07-11T18:18:16.4520716"",
                        ""spatialPoint"": {
                            ""type"": ""Point"",
                            ""coordinates"": [
                                118.9897,
                                -46.6781
                            ]
                        },
                        ""text"": ""tiger diamond newbrunswick snowleopard chocolate dog snowleopard turtle cat sapphire peach sapphire vancouver white chocolate horse diamond lion superlongcolourname ruby""
                    }";

            JsonNavigatorTests.VerifyNavigator(input);
        }
Exemplo n.º 15
0
        public void NegativeNumberTest()
        {
            string input = "-1337.0";

            JsonNavigatorTests.VerifyNavigator(input);
        }
Exemplo n.º 16
0
        public void DoubleTest()
        {
            string input = "1337.0";

            JsonNavigatorTests.VerifyNavigator(input);
        }
Exemplo n.º 17
0
        public void IntegerTest()
        {
            string input = "1337";

            JsonNavigatorTests.VerifyNavigator(input);
        }
Exemplo n.º 18
0
        public void NullTest()
        {
            string input = "null";

            JsonNavigatorTests.VerifyNavigator(input);
        }
Exemplo n.º 19
0
        public void NullArrayTest()
        {
            string input = "[ null, null, null]  ";

            JsonNavigatorTests.VerifyNavigator(input);
        }
Exemplo n.º 20
0
        public void FalseTest()
        {
            string input = "false";

            JsonNavigatorTests.VerifyNavigator(input);
        }
Exemplo n.º 21
0
        public void SimpleObjectTest()
        {
            string input = "{\"GlossDiv\":10,\"title\": \"example glossary\" }";

            JsonNavigatorTests.VerifyNavigator(input);
        }
Exemplo n.º 22
0
        public void TrueTest()
        {
            string input = "true";

            JsonNavigatorTests.VerifyNavigator(input);
        }
Exemplo n.º 23
0
        public void AllPrimitiveArrayTest()
        {
            string input = "[0, 0.0, -1, -1.0, 1, 2, \"hello\", null, true, false]  ";

            JsonNavigatorTests.VerifyNavigator(input);
        }
Exemplo n.º 24
0
        public void NestedArrayTest()
        {
            string input = "[[], []]  ";

            JsonNavigatorTests.VerifyNavigator(input);
        }
Exemplo n.º 25
0
        public void EmptyObjectTest()
        {
            string input = "{}";

            JsonNavigatorTests.VerifyNavigator(input);
        }
Exemplo n.º 26
0
        public void BooleanArrayTest()
        {
            string input = "[ true, false]  ";

            JsonNavigatorTests.VerifyNavigator(input);
        }
Exemplo n.º 27
0
        public void IntArrayTest()
        {
            string input = "[ -2, -1, 0, 1, 2]  ";

            JsonNavigatorTests.VerifyNavigator(input);
        }
Exemplo n.º 28
0
        public void NumberWithScientificNotationTest()
        {
            string input = "6.02252e23";

            JsonNavigatorTests.VerifyNavigator(input);
        }
Exemplo n.º 29
0
        public void NumberArrayTest()
        {
            string input = "[15,  22, 0.1, -7.3e-2, 77.0001e90 ]  ";

            JsonNavigatorTests.VerifyNavigator(input);
        }
Exemplo n.º 30
0
        public void ObjectArrayTest()
        {
            string input = "[{}, {}]  ";

            JsonNavigatorTests.VerifyNavigator(input);
        }