Пример #1
0
        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()));
        }
Пример #2
0
        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()));
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        public void ParseNumber_Infinity_Exact_Ok()
        {
            var actual = JSNumberValue.ParseNumber("Infinity");

            Assert.IsTrue(actual.Type == JSValueType.Float && double.IsPositiveInfinity(actual.CastToFloat()));
        }
Пример #7
0
        public void ParseNumber_Infinity_FollowingNotOnlySpaces_Fail()
        {
            var actual = JSNumberValue.ParseNumber("  Infinity  1");

            Assert.IsTrue(actual.Type == JSValueType.Float && double.IsNaN(actual.CastToFloat()));
        }
Пример #8
0
        public void ParseNumber_Infinity_Simple_Fail()
        {
            var actual = JSNumberValue.ParseNumber("  Infiniti  ");

            Assert.IsTrue(actual.Type == JSValueType.Float && double.IsNaN(actual.CastToFloat()));
        }
Пример #9
0
        public void ParseNumber_Infinity_LeadingSpaces_And_FollowingSpaces_Ok()
        {
            var actual = JSNumberValue.ParseNumber("  Infinity  ");

            Assert.IsTrue(actual.Type == JSValueType.Float && double.IsPositiveInfinity(actual.CastToFloat()));
        }