Esempio n. 1
0
        private static void TryNumberConversions(string value)
        {
            String8 value8 = value.TestConvert();

            // .NET Parses "-0" successfully as int and long, but not ulong.
            // I don't want "-0" to be considered valid on any parse.
            if (value == "-0")
            {
                value = "Invalid";
            }

            int expectedInt, actualInt;

            Assert.AreEqual(int.TryParse(value, out expectedInt), value8.TryToInteger(out actualInt));
            Assert.AreEqual(expectedInt, actualInt);

            long expectedLong, actualLong;

            Assert.AreEqual(long.TryParse(value, out expectedLong), value8.TryToLong(out actualLong));
            Assert.AreEqual(expectedLong, actualLong);

            ulong expectedULong, actualULong;

            Assert.AreEqual(ulong.TryParse(value, out expectedULong), value8.TryToULong(out actualULong));
            Assert.AreEqual(expectedULong, actualULong);
        }