34 lines
866 B
Go
34 lines
866 B
Go
package bastion_init
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
func TestNewTrie(t *testing.T) {
|
|
|
|
words := []string{"apple", "apricot", "apprentice", "application"}
|
|
tcc := NewTrie()
|
|
tcc.InsertAll(words)
|
|
|
|
prefix := "ap"
|
|
closest, err := FindClosestWord(tcc, prefix)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
} else {
|
|
fmt.Printf("The closest word to '%s' is '%s'\n", prefix, closest)
|
|
}
|
|
}
|
|
|
|
func TestDp(t *testing.T) {
|
|
words := []string{"Apple", "Apricot", "Apprentice", "Application", "Docker-Compose", "Docker-Compose-File", "Docker-Compose-File-V2", "Docker-Compose-File-V3", "Docker-Compose-File-V4", "Docker-Compose-File-V5", "Docker-Compose-File-V6", "Docker-Co", "Install-Docker"}
|
|
prefix := "Install"
|
|
|
|
closest, err := FindClosestWordDp(words, prefix)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
} else {
|
|
fmt.Printf("The closest word to '%s' is '%s'\n", prefix, closest)
|
|
}
|
|
}
|