Beispiel #1
0
        public void test_solution_givenNonEmptyArray_returnsStartingPosition(int[] given, int expected)
        {
            var target = new MinAvgTwoSlice();
            var actual = target.solution(given);

            Assert.AreEqual(expected, actual);
        }
        public void TestOne()
        {
            int[]          testArray = new int[] { 4, 2, 2, 5, 1, 5, 8 };
            MinAvgTwoSlice sut       = new MinAvgTwoSlice();
            var            result    = sut.solution(testArray);

            result.Should().Be(1);
        }
        public void MinAvgTwoSlice_Should_Process_Simple_Array()
        {
            MinAvgTwoSlice subject = new MinAvgTwoSlice();

            int expectedResult = 1;

            int[] array = { 4, 2, 2, 5, 1, 5, 8 };

            int result = subject.solution(array);

            Assert.Equal(expectedResult, result);
        }
Beispiel #4
0
        public void MinAvgTwoSliceTest()
        {
            Random rnd = new Random((int)DateTime.Now.Ticks);
            int    min = -10000;
            int    max = 10000;

            for (int i = 0; i < 10000; i++)
            {
                int[] at = Enumerable.Repeat(0, rnd.Next(2, 101)).Select(i2 => rnd.Next(min, max + 1)).ToArray();
                int   t1 = MinAvgTwoSlice.solution(at);
                int   t2 = MinAvgTwoSlice.solution1(at);
                Assert.AreEqual(t1, t2, 0, $"Result: [ex:{t2} ,go: {t1}]");
            }
        }
        public void TestTwo()
        {
            Random rand = new Random();
            int    min  = -10000;
            int    max  = 10000;

            int[] testArray = new int[1000];
            for (int i = 0; i < testArray.Length; i++)
            {
                testArray[i] = rand.Next(min, max);
            }
            MinAvgTwoSlice sut    = new MinAvgTwoSlice();
            var            result = sut.solution(testArray);

            result.Should().Be(1);
        }
Beispiel #6
0
        public void MinAvgTwoSliceTest()
        {
            var solution = ma.solution(new int[] { 4, 2, 2, 5, 1, 5, 8 });

            Assert.AreEqual(1, solution);
        }
Beispiel #7
0
        private void Test(int[] A, int expectedResult)
        {
            var result = _minAvgTwoSlice.solution(A);

            Assert.AreEqual(expectedResult, result);
        }