def test_aabaaac(self): temp = Solution() self.heystack = "aabaaabaaac" self.needle = "aabaaac" self.assertEqual(temp.strStr(self.heystack,self.needle), 4)
def test_needle_euqal_last_letter(self): temp = Solution() self.heystack = "abcdefg" self.needle = "gigeo" self.assertEqual(temp.strStr(self.heystack,self.needle), -1)
def test_mississippi2(self): temp = Solution() self.heystack = "mississippi" self.needle = "pi" self.assertEqual(temp.strStr(self.heystack,self.needle), 9)
def test_needle_larger_than_haystack(self): temp = Solution() self.heystack = "aaa" self.needle = "aaaa" self.assertEqual(temp.strStr(self.heystack,self.needle), -1)
def test_basic_function(self): temp = Solution() self.heystack = "hello" self.needle = "ll" self.assertEqual(temp.strStr(self.heystack,self.needle), 2)
def test_needle_in_the_end(self): temp = Solution() self.heystack = "aabbccdd" self.needle = "dd" self.assertEqual(temp.strStr(self.heystack,self.needle), 6)
def test_needle_in_the_middle(self): temp = Solution() self.heystack = "aabbccddee" self.needle = "cc" self.assertEqual(temp.strStr(self.heystack,self.needle), 4)
def test_haystack_is_needle(self): temp = Solution() self.heystack = "needle" self.needle = "needle" self.assertEqual(temp.strStr(self.heystack,self.needle), 0)
def test_empty_needle(self): temp = Solution() self.heystack = "aword" self.needle = "" self.assertEqual(temp.strStr(self.heystack,self.needle), 0)
def test_no_needle_found(self): temp = Solution() self.heystack = "HelloWorld" self.needle = "aa" self.assertEqual(temp.strStr(self.heystack,self.needle), -1)
def test_basic_function(self): temp = Solution() self.needle = "abcdefg" self.assertEqual(temp.FailureFunction(self.needle), [0, 0, 0, 0, 0, 0, 0])
def test_basic_issip(self): temp = Solution() self.needle = "issip" self.assertEqual(temp.FailureFunction( self.needle), [0, 0, 0, 1, 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])
def test_basic_function3(self): temp = Solution() self.needle = "abababac" self.assertEqual(temp.FailureFunction( self.needle), [0, 0, 1, 2, 3, 4, 5, 0])