private static void ParseNumber_ParseFloat_Fail(string expected) { var actual = JSNumberValue.ParseNumber(expected); Assert.IsNotNull(actual); Assert.IsTrue(actual.Type == JSValueType.Float && double.IsNaN(actual.CastToFloat())); }
private static void ParseNumber_Integer_Fail(string value) { var actual = JSNumberValue.ParseNumber(value); Assert.IsNotNull(actual); Assert.IsTrue(actual.Type == JSValueType.Float && double.IsNaN(actual.CastToFloat())); }
private static void ParseNumber_ParseFloat_Ok(string prefix, string expected, string suffix) { var actual = JSNumberValue.ParseNumber(prefix + expected + suffix); Assert.IsNotNull(actual); Assert.IsTrue(actual.Type == JSValueType.Float && Math.Abs(actual.CastToFloat() - double.Parse(expected, CultureInfo.InvariantCulture)) < 1e-9); }
private static void ParseNumber_Integer_ReturnFloat_Ok(string prefix, string format, string suffix) { const long expected = (long)int.MaxValue + 1L; var actual = JSNumberValue.ParseNumber(prefix + expected.ToString(format, CultureInfo.InvariantCulture) + suffix); Assert.IsNotNull(actual); Assert.IsTrue(actual.Type == JSValueType.Float && Math.Abs(actual.CastToFloat() - expected) < 1e-9); }
private static void ParseNumber_Integer_Ok(string prefix, string format, string suffix) { const int expected = 1000; var actual = JSNumberValue.ParseNumber(prefix + expected.ToString(format, CultureInfo.InvariantCulture) + suffix); Assert.IsNotNull(actual); Assert.IsTrue(actual.Type == JSValueType.Integer && actual.CastToInteger() == expected); }
public void ParseNumber_Infinity_Exact_Ok() { var actual = JSNumberValue.ParseNumber("Infinity"); Assert.IsTrue(actual.Type == JSValueType.Float && double.IsPositiveInfinity(actual.CastToFloat())); }
public void ParseNumber_Infinity_FollowingNotOnlySpaces_Fail() { var actual = JSNumberValue.ParseNumber(" Infinity 1"); Assert.IsTrue(actual.Type == JSValueType.Float && double.IsNaN(actual.CastToFloat())); }
public void ParseNumber_Infinity_Simple_Fail() { var actual = JSNumberValue.ParseNumber(" Infiniti "); Assert.IsTrue(actual.Type == JSValueType.Float && double.IsNaN(actual.CastToFloat())); }
public void ParseNumber_Infinity_LeadingSpaces_And_FollowingSpaces_Ok() { var actual = JSNumberValue.ParseNumber(" Infinity "); Assert.IsTrue(actual.Type == JSValueType.Float && double.IsPositiveInfinity(actual.CastToFloat())); }