예제 #1
0
    def test_large_string(self):

        solution = Solution()

        with open('longest_substring_without_repeating_characters_example_six.txt', 'r') as file:

            data = file.read()

            self.assertEqual(solution.lengthOfLongestSubstring(data), 95)
 def test_longest_substring_without_repeating_characters(self):
     solution = Solution()
     self.assertEqual(solution.lengthOfLongestSubstring("abcabcbb"), 3)
     self.assertEqual(solution.lengthOfLongestSubstring("bbbbb"), 1)
     self.assertEqual(solution.lengthOfLongestSubstring("pwwkew"), 3)
     self.assertEqual(solution.lengthOfLongestSubstring("dvdf"), 3)
     self.assertEqual(solution.lengthOfLongestSubstring("abba"), 2)
예제 #3
0
 def test_Calculate_Solution(self):
     sol = Solution()
     self.assertEqual(1, sol.lengthOfLongestSubstring(' '))
     self.assertEqual(3, sol.lengthOfLongestSubstring('abcabcbb'))
     self.assertEqual(1, sol.lengthOfLongestSubstring('bbbbbb'))
     self.assertEqual(3, sol.lengthOfLongestSubstring('pwwkew'))
 def test_lengthOfLongestSubstring_abcabcbb(self):
     sol = Solution()
     assert sol.length_of_longest_substring("abcabcbb") == 3
 def test_lengthOfLongestSubstrin_pwwkew(self):
     sol = Solution()
     assert sol.length_of_longest_substring("pwwkew") == 3
def test_longest_unrepeat_substring():
    strs = ["abcabcbb", "bbbbb", "pwwkew", ""]
    assert [Solution().lengthOfLongestSubstring(s)
            for s in strs] == [3, 1, 3, 0], "Find unrepeated substring failed"
예제 #7
0
    def test_example_one(self):

        solution = Solution()

        self.assertEqual(solution.lengthOfLongestSubstring("abcabcbb"), 3)
예제 #8
0
    def test_example_five(self):

        solution = Solution()

        self.assertEqual(solution.lengthOfLongestSubstring(" "), 1)
예제 #9
0
    def test_example_three(self):

        solution = Solution()

        self.assertEqual(solution.lengthOfLongestSubstring("pwwkew"), 3)