public void TestToInt64() { Assert.AreEqual(0L, ConvertExt.ToInt64("0", 13)); Assert.AreEqual(1L, ConvertExt.ToInt64("1", 3)); Assert.AreEqual(14720L, ConvertExt.ToInt64("1Gg0", 20)); Assert.AreEqual(9223372036854775807L, ConvertExt.ToInt64("10B269549075433C37", 13)); Assert.AreEqual(-1L, ConvertExt.ToInt64("4Eo8hfam6fllmo", 27)); Assert.AreEqual(-2L, ConvertExt.ToInt64("4Eo8hfam6fllmn", 27)); Assert.AreEqual(-8071017880399937603L, ConvertExt.ToInt64("26tvjyybszf7h", 36)); Assert.AreEqual(-9223372036854775808L, ConvertExt.ToInt64("q1se8f0m04isc", 29)); AssertExt.ThrowsException(() => ConvertExt.ToInt64("4Eo8hfam6fllmp", 27), typeof(OverflowException)); }
public void TestToInt64() { Assert.AreEqual(0L, ConvertExt.ToInt64("0", 13)); Assert.AreEqual(1L, ConvertExt.ToInt64("1", 3)); Assert.AreEqual(14720L, ConvertExt.ToInt64("1Gg0", 20)); Assert.AreEqual(9223372036854775807L, ConvertExt.ToInt64("10B269549075433C37", 13)); Assert.AreEqual(-1L, ConvertExt.ToInt64("4Eo8hfam6fllmo", 27)); Assert.AreEqual(-2L, ConvertExt.ToInt64("4Eo8hfam6fllmn", 27)); Assert.AreEqual(-8071017880399937603L, ConvertExt.ToInt64("26tvjyybszf7h", 36)); Assert.AreEqual(-9223372036854775808L, ConvertExt.ToInt64("q1se8f0m04isc", 29)); bool hasException = false; try { ConvertExt.ToInt64("4Eo8hfam6fllmp", 27); } catch (OverflowException) { hasException = true; } Assert.IsTrue(hasException, "没有正确引发 OverflowException。"); }