Пример #1
0
        public void ExistsTest()
        {
            var million = Enumerable.Range(0, 1_000_000).ToArray();
            var r       = new Revise2();

            Assert.IsTrue(r.Exists(million, 999_000));
            Assert.IsFalse(r.Exists(million, 1_000_000));
        }
Пример #2
0
        public void CyclicRotationTest()
        {
            var input1 = new[] { 3, 8, 9, 7, 6 };
            var input2 = new[] { 0, 0, 0 };
            var input3 = new[] { 1, 2, 3, 4 };
            var input4 = new[] { 1, 1, 2, 3, 5 };

            var r = new Revise2();

            CollectionAssert.AreEqual(new[] { 9, 7, 6, 3, 8 }, r.CyclicRotation(input1, 3));
            CollectionAssert.AreEqual(new[] { 0, 0, 0 }, r.CyclicRotation(input2, 1));
            CollectionAssert.AreEqual(new[] { 1, 2, 3, 4 }, r.CyclicRotation(input3, 4));
            CollectionAssert.AreEqual(new[] { 4, 1, 2, 3 }, r.CyclicRotation(input3, 1));
            CollectionAssert.AreEqual(new[] { 3, 4, 1, 2 }, r.CyclicRotation(input3, 2));
            CollectionAssert.AreEqual(new[] { 2, 3, 4, 1 }, r.CyclicRotation(input3, 3));
            CollectionAssert.AreEqual(new[] { 3, 5, 1, 1, 2 }, r.CyclicRotation(input4, 42));
            CollectionAssert.AreEqual(new int[] { }, r.CyclicRotation(new int[] { }, 1));
        }