예제 #1
0
 def test_aabaaac(self):
     temp = Solution()
     self.heystack = "aabaaabaaac"
     self.needle = "aabaaac"
     self.assertEqual(temp.strStr(self.heystack,self.needle), 4)
예제 #2
0
 def test_needle_euqal_last_letter(self):
     temp = Solution()
     self.heystack = "abcdefg"
     self.needle = "gigeo"
     self.assertEqual(temp.strStr(self.heystack,self.needle), -1)
예제 #3
0
 def test_mississippi2(self):
     temp = Solution()
     self.heystack = "mississippi"
     self.needle = "pi"
     self.assertEqual(temp.strStr(self.heystack,self.needle), 9)
예제 #4
0
 def test_needle_larger_than_haystack(self):
     temp = Solution()
     self.heystack = "aaa"
     self.needle = "aaaa"
     self.assertEqual(temp.strStr(self.heystack,self.needle), -1)
예제 #5
0
 def test_basic_function(self):
     temp = Solution()
     self.heystack = "hello"
     self.needle = "ll"
     self.assertEqual(temp.strStr(self.heystack,self.needle), 2)
예제 #6
0
 def test_needle_in_the_end(self):
     temp = Solution()
     self.heystack = "aabbccdd"
     self.needle = "dd"
     self.assertEqual(temp.strStr(self.heystack,self.needle), 6)
예제 #7
0
 def test_needle_in_the_middle(self):
     temp = Solution()
     self.heystack = "aabbccddee"
     self.needle = "cc"
     self.assertEqual(temp.strStr(self.heystack,self.needle), 4)
예제 #8
0
 def test_haystack_is_needle(self):
     temp = Solution()
     self.heystack = "needle"
     self.needle = "needle"
     self.assertEqual(temp.strStr(self.heystack,self.needle), 0)
예제 #9
0
 def test_empty_needle(self):
     temp = Solution()
     self.heystack = "aword"
     self.needle = ""
     self.assertEqual(temp.strStr(self.heystack,self.needle), 0)
예제 #10
0
 def test_no_needle_found(self):
     temp = Solution()
     self.heystack = "HelloWorld"
     self.needle = "aa"
     self.assertEqual(temp.strStr(self.heystack,self.needle), -1)
예제 #11
0
 def test_basic_function(self):
     temp = Solution()
     self.needle = "abcdefg"
     self.assertEqual(temp.FailureFunction(self.needle),
                      [0, 0, 0, 0, 0, 0, 0])
예제 #12
0
 def test_basic_issip(self):
     temp = Solution()
     self.needle = "issip"
     self.assertEqual(temp.FailureFunction(
         self.needle), [0, 0, 0, 1, 0])
예제 #13
0
 def test_basic_function4(self):
     temp = Solution()
     self.needle = "AABAACAABAA"
     self.assertEqual(temp.FailureFunction(
         self.needle), [0, 1, 0, 1, 2, 0, 1, 2, 3, 4, 5])
예제 #14
0
 def test_basic_function3(self):
     temp = Solution()
     self.needle = "abababac"
     self.assertEqual(temp.FailureFunction(
         self.needle), [0, 0, 1, 2, 3, 4, 5, 0])