Пример #1
0
            public static string TestPow()
            {
                object[,] testeComparari = new object[, ] {
                    { "0", "9", "0,0" },
                    { "1", "0", "1,0" },
                    { "1", "1", "1,0" },
                    { "2", "1", "2,0" },
                    { "2", "3", "8,0" },
                    { "2", "10", "1024,0" },
                    { "20", "9", "512000000000,0" },
                    { "4", "0,5", "2" },
                    { "256", "0,25", "4" },
                    { "4", "0,5", "2" },
                    { "256", "0,4", "4" },
                    { "2", "0,5", "1" }
                };

                string str = "";

                for (int i = 0; i < testeComparari.GetLength(0); i++)
                {
                    Floatz a = new Floatz((string)testeComparari[i, 0]);
                    Floatz b = new Floatz((string)testeComparari[i, 1]);
                    //Console.WriteLine("{0}->{1}",b.ToString(),b.isOne());
                    string resultCorrect = (string)testeComparari[i, 2];
                    Floatz c             = Floatz.Pow(a, b);
                    if (c.ToString() != resultCorrect)
                    {
                        str += String.Format(
                            "\n Test failed:Putere #{0} nereusita.\n \n Pow({1};{2})={3} |corect e: {4}\n\n",
                            i, a.ToString(), b.ToString(), c.ToString(), resultCorrect
                            );
                    }
                }
                if (str == "")
                {
                    return("Nu exista probleme la putere.");
                }
                return(str);
            }