Пример #1
0
        public void RandomInvBigNumbersTest()
        {
            Random r = new Random();

            for (int i = 0; i < 20; i++)
            {
                long n = (long)(r.NextDouble() * 999999999999999L);
                Assert.AreEqual(MysteryInv(n), MysteryFunction.MysteryInv(n), $"mysteryInv({n})");
            }
        }
Пример #2
0
        public void MysteryInvTest()
        {
            Assert.AreEqual(6, MysteryFunction.MysteryInv(5), "mysteryInv(5)");
            Assert.AreEqual(9, MysteryFunction.MysteryInv(13), "mysteryInv(13)");
            Assert.AreEqual(19, MysteryFunction.MysteryInv(26), "mysteryInv(26)");
            int x = 10;

            Assert.AreEqual((int)Math.Pow(2, x + 1) - 1, MysteryFunction.MysteryInv((int)Math.Pow(2, x)), string.Format("mysteryInv({0}) ", (int)Math.Pow(2, x)));
            Assert.AreEqual(50320920207254, MysteryFunction.MysteryInv(65036019806301), "mysteryInv(65036019806301)");
        }
Пример #3
0
        public void RandomInvSmallNumbersTest()
        {
            Random r = new Random();

            for (int i = 0; i < 20; i++)
            {
                long n = r.Next(1000);
                Assert.AreEqual(MysteryInv(n), MysteryFunction.MysteryInv(n), $"mysteryInv({n})");
            }
        }
Пример #4
0
        public void MysteryTest()
        {
            Assert.AreEqual(5, MysteryFunction.Mystery(6), "mystery(6) ");
            Assert.AreEqual(13, MysteryFunction.Mystery(9), "mystery(9) ");
            Assert.AreEqual(26, MysteryFunction.Mystery(19), "mystery(19) ");
            int x = 10;

            Assert.AreEqual((int)Math.Pow(2, x), MysteryFunction.Mystery((int)Math.Pow(2, x + 1) - 1), string.Format("mystery({0}) ", (int)Math.Pow(2, x + 1) - 1));
            Assert.AreEqual(41058636170415, MysteryFunction.Mystery(63337240397621), "mystery(63337240397621) ");
        }
Пример #5
0
        public void FunctionNameTest()
        {
            Random r = new Random();

            for (int i = 0; i < 5; i++)
            {
                long n = r.Next(1000);
                Assert.AreEqual((n ^ (n >> 1)), MysteryFunction.Mystery(n), "No,no,no! Find the function before you can see it in the tests ;)");
            }
            Assert.AreEqual("gray code", MysteryFunction.NameOfMystery().ToLower());
        }