Example #1
0
 public void TestToUInt64()
 {
     Assert.AreEqual(0UL, ConvertExt.ToUInt64("0", 13));
     Assert.AreEqual(1UL, ConvertExt.ToUInt64("1", 3));
     Assert.AreEqual(14720UL, ConvertExt.ToUInt64("1Gg0", 20));
     Assert.AreEqual(9223372036854775807UL, ConvertExt.ToUInt64("10B269549075433C37", 13));
     Assert.AreEqual(9223372036854775808UL, ConvertExt.ToUInt64("q1se8f0m04isc", 29));
     Assert.AreEqual(10375726193309614013UL, ConvertExt.ToUInt64("26tvjyybszf7h", 36));
     Assert.AreEqual(18446744073709551614UL, ConvertExt.ToUInt64("4Eo8hfam6fllmn", 27));
     Assert.AreEqual(18446744073709551615UL, ConvertExt.ToUInt64("4Eo8hfam6fllmo", 27));
     AssertExt.ThrowsException(() => ConvertExt.ToUInt64("4Eo8hfam6fllmp", 27), typeof(OverflowException));
 }
Example #2
0
        public void TestToUInt64()
        {
            Assert.AreEqual(0UL, ConvertExt.ToUInt64("0", 13));
            Assert.AreEqual(1UL, ConvertExt.ToUInt64("1", 3));
            Assert.AreEqual(14720UL, ConvertExt.ToUInt64("1Gg0", 20));
            Assert.AreEqual(9223372036854775807UL, ConvertExt.ToUInt64("10B269549075433C37", 13));
            Assert.AreEqual(9223372036854775808UL, ConvertExt.ToUInt64("q1se8f0m04isc", 29));
            Assert.AreEqual(10375726193309614013UL, ConvertExt.ToUInt64("26tvjyybszf7h", 36));
            Assert.AreEqual(18446744073709551614UL, ConvertExt.ToUInt64("4Eo8hfam6fllmn", 27));
            Assert.AreEqual(18446744073709551615UL, ConvertExt.ToUInt64("4Eo8hfam6fllmo", 27));
            bool hasException = false;

            try
            {
                ConvertExt.ToUInt64("4Eo8hfam6fllmp", 27);
            }
            catch (OverflowException)
            {
                hasException = true;
            }
            Assert.IsTrue(hasException, "没有正确引发 OverflowException。");
        }