public void NumberRegressionTest() { // regression test - the value 0.00085647800000000004 was being incorrectly rejected string numberValueString = "0.00085647800000000004"; JsonNavigatorTests.VerifyNavigator(numberValueString); }
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); } }
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); } }
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); } }
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); } }
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); } }
public void GuidTest() { Guid[] values = new Guid[] { Guid.Empty, Guid.NewGuid() }; foreach (Guid value in values) { string input = $"G{value.ToString()}"; JsonNavigatorTests.VerifyNavigator(input); } }
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); } }
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); } }
public void StrangeNumberArrayTest() { string input = @"[ 1111111110111111111011111111101111111110, 1111111110111111111011111111101111111110111111111011111111101111111110, 11111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110, 1111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111101111111110 ]"; JsonNavigatorTests.VerifyNavigator(input); }
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); }
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); } }
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. } }
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); }
public void NegativeNumberTest() { string input = "-1337.0"; JsonNavigatorTests.VerifyNavigator(input); }
public void DoubleTest() { string input = "1337.0"; JsonNavigatorTests.VerifyNavigator(input); }
public void IntegerTest() { string input = "1337"; JsonNavigatorTests.VerifyNavigator(input); }
public void NullTest() { string input = "null"; JsonNavigatorTests.VerifyNavigator(input); }
public void NullArrayTest() { string input = "[ null, null, null] "; JsonNavigatorTests.VerifyNavigator(input); }
public void FalseTest() { string input = "false"; JsonNavigatorTests.VerifyNavigator(input); }
public void SimpleObjectTest() { string input = "{\"GlossDiv\":10,\"title\": \"example glossary\" }"; JsonNavigatorTests.VerifyNavigator(input); }
public void TrueTest() { string input = "true"; JsonNavigatorTests.VerifyNavigator(input); }
public void AllPrimitiveArrayTest() { string input = "[0, 0.0, -1, -1.0, 1, 2, \"hello\", null, true, false] "; JsonNavigatorTests.VerifyNavigator(input); }
public void NestedArrayTest() { string input = "[[], []] "; JsonNavigatorTests.VerifyNavigator(input); }
public void EmptyObjectTest() { string input = "{}"; JsonNavigatorTests.VerifyNavigator(input); }
public void BooleanArrayTest() { string input = "[ true, false] "; JsonNavigatorTests.VerifyNavigator(input); }
public void IntArrayTest() { string input = "[ -2, -1, 0, 1, 2] "; JsonNavigatorTests.VerifyNavigator(input); }
public void NumberWithScientificNotationTest() { string input = "6.02252e23"; JsonNavigatorTests.VerifyNavigator(input); }
public void NumberArrayTest() { string input = "[15, 22, 0.1, -7.3e-2, 77.0001e90 ] "; JsonNavigatorTests.VerifyNavigator(input); }
public void ObjectArrayTest() { string input = "[{}, {}] "; JsonNavigatorTests.VerifyNavigator(input); }