Пример #1
0
        public void GetShortestToChar1(string s, char c, int[] expected)
        {
            var shortestDistanceToACharacter = new ShortestDistanceToACharacter();
            var actual = shortestDistanceToACharacter.ShortestToChar(s, c);

            Assert.That(actual, Is.EqualTo(expected));
        }
        public void ShortestToChar(string input, char character, int[] expected)
        {
            var sut    = new ShortestDistanceToACharacter();
            var actual = sut.ShortestToChar(input, character);

            Assert.AreEqual(expected, actual);
        }
        public void ShortestToCharTests()
        {
            ShortestDistanceToACharacter obj = new ShortestDistanceToACharacter();

            var x = obj.ShortestToChar("loveleetcode", 'e');

            x = obj.ShortestToChar("aaba", 'b');
        }
Пример #4
0
        public void ShortestDistanceToACharacterTestMethod()
        {
            ShortestDistanceToACharacter shortestDistanceToACharacter = new ShortestDistanceToACharacter();

            //int[] expected = new int[] { 3, 2, 1, 0, 1, 0, 0, 1, 2, 2, 1, 0 };
            //int[] actual = shortestDistanceToACharacter.ShrtestToChar("loveleetcode", 'e');
            //for (int i = 0; i < expected.Length; i++)
            //{
            //    Assert.AreEqual(expected[i], actual[i]);
            //}

            int[] expected2 = new int[] { 1, 0, 1, 2 };
            int[] actual2   = shortestDistanceToACharacter.ShrtestToChar("abaa", 'b');
            for (int i = 0; i < expected2.Length; i++)
            {
                Assert.AreEqual(expected2[i], actual2[i]);
            }
        }