예제 #1
0
        public void Powers_PowersOfTwo_RandomTests()
        {
            var rand = new Random();

            Func <int, BigInteger[]> myPowersOfTwo = delegate(int n)
            {
                return(Enumerable.Range(0, n + 1).Select(a => BigInteger.Pow(2, a)).ToArray());
            };

            var shuffle = Enumerable.Range(0, 201).OrderBy(a => rand.Next(-1, 2));

            shuffle.ToList().ForEach(n =>
            {
                Assert.AreEqual(myPowersOfTwo(n), Powers.PowersOfTwo(n));
            });
        }
예제 #2
0
 public void Powers_PowersOfTwo_BasicTests()
 {
     Assert.AreEqual(new BigInteger[] { 1 }, Powers.PowersOfTwo(0));
     Assert.AreEqual(new BigInteger[] { 1, 2 }, Powers.PowersOfTwo(1));
     Assert.AreEqual(new BigInteger[] { 1, 2, 4, 8, 16 }, Powers.PowersOfTwo(4));
 }