public void LengthOfLongestSubstring_Case3()
        {
            // Arrange
            var    obj      = new LongestSubstringWithoutRepeatingCharactersProblem();
            string s        = "pwwkew";
            int    expected = 3; // "wke"

            // Act
            int actual = obj.LengthOfLongestSubstring(s);

            // Assert
            Assert.Equal(expected, actual);
        }
        public void LengthOfLongestSubstring_Case5()
        {
            // Arrange
            var    obj      = new LongestSubstringWithoutRepeatingCharactersProblem();
            string s        = "abcdeafbdgcbb";
            int    expected = 7; // "eafbdgc"

            // Act
            int actual = obj.LengthOfLongestSubstring(s);

            // Assert
            Assert.Equal(expected, actual);
        }
コード例 #3
0
        public void LongestSubstringWithoutRepeatingCharactersProblemTest()
        {
            var solution = new LongestSubstringWithoutRepeatingCharactersProblem();
            var result   = solution.LengthOfLongestSubstring("abcabcbb");

            Assert.Equal(3, result);
            Assert.Equal(1, solution.LengthOfLongestSubstring("bbbbb"));
            Assert.Equal(3, solution.LengthOfLongestSubstring("pwwkew"));
            Assert.Equal(1, solution.LengthOfLongestSubstring("b"));
            Assert.Equal(0, solution.LengthOfLongestSubstring(""));
            Assert.Equal(2, solution.LengthOfLongestSubstring("au"));
            Assert.Equal(5, solution.LengthOfLongestSubstring("tmmzuxt"));
        }