Beispiel #1
0
        public void BaseConversionTest()
        {
            Func <string, int, int, string>[] functions = new Func <string, int, int, string>[]
            {
                BaseConversion.Convert
            };

            for (int n = 0; n < 50; n++)
            {
                for (int b1 = 2; b1 < 16; b1++)
                {
                    for (int b2 = 2; b2 < 16; b2++)
                    {
                        string s = BaseConversion.ToString(n, b1);
                        Assert.AreEqual(BaseConversion.ToInt(s, b1), n);

                        string s2 = BaseConversion.Convert(s, b1, b2);
                        Assert.AreEqual(BaseConversion.Convert(s2, b2, b1), s);

                        int n2 = BaseConversion.ToInt(s2, b2);
                        Assert.AreEqual(BaseConversion.ToString(n2, b2), s2);
                    }
                }
            }
        }
Beispiel #2
0
 private static string Convert(string s, int b1, int b2)
 {
     return(BaseConversion.ToString(BaseConversion.ToInt(s, b1), b2));
 }