Exemple #1
0
 public void TheElderIsExcited()
 {
     Console.WriteLine(
         "<p><font color=\"yellow\">300 test cases\\nm,n: 2^8 - 2^20\\nl: 0 - 9999\\nt: 2^10 - 2^20</font></p>");
     Console.WriteLine("You're too young and too simple!");
     for (int i = 0; i < 300; i++)
     {
         long m = (long)Math.Floor(Math.Pow(2, _random.NextDouble() * 12 + 8)),
              n = (long)Math.Floor(Math.Pow(2, _random.NextDouble() * 12 + 8)),
              l = (long)(_random.NextDouble() * 10000),
              t = (long)Math.Floor(Math.Pow(2, _random.NextDouble() * 10 + 10));
         long expected = Immortal2.ElderAge(m, n, l, t), actual = Immortal.ElderAge(m, n, l, t);
         if (expected != actual)
         {
             _good = false;
             if (Immortal.Debug)
             {
                 Console.WriteLine("The Elder says: \\n<p><font color=\"yellow\">m=" + m + ", n=" + n + ", l=" + l + ", t=" + t +
                                   "</font></p>");
             }
         }
         else
         {
             _passed++;
         }
         Assert.AreEqual(expected, actual);
     }
 }
Exemple #2
0
 public void TheElderIsAngry()
 {
     Console.WriteLine(
         "<p><font color=\"red\">500 test cases\\nm,n: 2^32 - 2^48\\nl: 0 - 9999999\\nt: 2^16 - 2^26</font></p>");
     Console.WriteLine("And sometimes naive!");
     for (int i = 0; i < 500; i++)
     {
         long m = (long)Math.Floor(Math.Pow(2, _random.NextDouble() * 16 + 32)),
              n = (long)Math.Floor(Math.Pow(2, _random.NextDouble() * 16 + 32)),
              l = (long)(_random.NextDouble() * 1e7),
              t = (long)Math.Floor(Math.Pow(2, _random.NextDouble() * 10 + 16));
         long expected = Immortal2.ElderAge(m, n, l, t), actual = Immortal.ElderAge(m, n, l, t);
         if (expected != actual)
         {
             _good = false;
             if (Immortal.Debug)
             {
                 Console.WriteLine("The Elder says: \\n<p><font color=\"yellow\">m=" + m + ", n=" + n + ", l=" + l + ", t=" + t +
                                   "</font></p>");
             }
         }
         else
         {
             _passed++;
         }
         Assert.AreEqual(expected, actual);
     }
 }
Exemple #3
0
 public void TheElderIsInterested()
 {
     Console.WriteLine(
         "<p><font color=\"green\">100 test cases\\nm,n: 2^5 - 2^10\\nl: 0 - 19\\nt: 2^5 - 2^15</font></p>");
     Console.WriteLine("Young man, you should learn a thing or two...");
     for (var i = 0; i < 100; i++)
     {
         long m = (long)Math.Floor(Math.Pow(2, _random.NextDouble() * 5 + 5)),
              n = (long)Math.Floor(Math.Pow(2, _random.NextDouble() * 5 + 5)),
              l = (long)(_random.NextDouble() * 20),
              t = (long)Math.Floor(Math.Pow(2, _random.NextDouble() * 10 + 5));
         long expected = Immortal2.ElderAge(m, n, l, t), actual = Immortal.ElderAge(m, n, l, t);
         if (expected != actual)
         {
             _good = false;
             if (Immortal.Debug)
             {
                 Console.WriteLine("The Elder says: \\n<p><font color=\"yellow\">m=" + m + ", n=" + n + ", l=" + l + ", t=" + t +
                                   "</font></p>");
             }
         }
         else
         {
             _passed++;
         }
         Assert.AreEqual(expected, actual);
     }
 }