Exemplo n.º 1
0
        public void TestFrom10Unsigned()
        {
            int[] bases = { 2, 8, 10, 16 };

            foreach (var b in bases)
            {
                for (int j = 0; j < 100; j++)
                {
                    string s = Convert.ToString(j, b);

                    string myConversion = BaseConvert.From10Unsigned(j, b);
                    Assert.AreEqual(myConversion, s);
                }
            }
            Assert.ThrowsException <ArgumentException>(() => BaseConvert.From10Unsigned(-1000, 2));
            Assert.ThrowsException <ArgumentException>(() => BaseConvert.From10Unsigned(-1000, -2));
            Assert.ThrowsException <ArgumentException>(() => BaseConvert.From10Unsigned(1000, -2));
            Assert.ThrowsException <ArgumentException>(() => BaseConvert.From10Unsigned(1000, 1));
            Assert.ThrowsException <ArgumentException>(() => BaseConvert.From10Unsigned(0, 1));
            Assert.ThrowsException <ArgumentException>(() => BaseConvert.From10Unsigned(1, 0));
        }