public void RandomSmallNumbersTest() { Random r = new Random(); for (int i = 0; i < 20; i++) { long n = r.Next(1000); Assert.AreEqual(n ^ (n >> 1), MysteryFunction.Mystery(n), $"mystery({n})"); } }
public void RandomBigNumbersTest() { Random r = new Random(); for (int i = 0; i < 20; i++) { long n = (long)(r.NextDouble() * 999999999999999L); Assert.AreEqual(n ^ (n >> 1), MysteryFunction.Mystery(n), $"mystery({n})"); } }
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) "); }
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()); }