Files
Go-http_framework/util/stringMatch/HorspoolMatch_test.go
T

27 lines
940 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* @Author : huangzj
* @Time : 2020/8/21 16:07
* @Description
*/
package stringMatch
import (
"fmt"
"testing"
)
func TestHorspool(t *testing.T) {
fmt.Println("该子串的位置为:", Horspool("abcdefghijk", "abcd")) //输出0
fmt.Println("该子串的位置为:", Horspool("abcdefghijk", "bcd")) //输出1
fmt.Println("该子串的位置为:", Horspool("abcdefghijk", "fgh")) //输出6
fmt.Println("该子串的位置为:", Horspool("abcdefghijk", "hijk")) //输出8
fmt.Println("该子串的位置为:", Horspool("abcdefghijk", "jk")) //输出10
fmt.Println("该子串的位置为:", Horspool("abcdefghijk", "k")) //输出11
fmt.Println("该子串的位置为:", Horspool("abcdefghijk", "kbz")) //输出-1
fmt.Println("该子串的位置为:", Horspool("abcdefghijk", "kdasdsad")) //输出-1
fmt.Println("该子串的位置为:", Horspool("abcdefghijk", "dsadsa")) //输出-1
}