go-whisper-api/punctuation/heuristic_test.go
admin b5c083e06f
Some checks failed
CodeQL / Analyze (go) (push) Successful in 6m28s
Docker Image / build-docker (push) Failing after 13m26s
Lint and Testing / lint (push) Successful in 11m17s
Lint and Testing / test (push) Successful in 11m17s
Lint and Testing / golangci (push) Successful in 2m40s
first commit
2026-06-04 18:10:52 +07:00

33 lines
744 B
Go

package punctuation
import (
"context"
"testing"
)
func TestHeuristicRU_question(t *testing.T) {
h := Heuristic{}
out, err := h.Restore(context.Background(), "как дела", "ru")
if err != nil {
t.Fatal(err)
}
if !stringsHasSuffix(out, "?") {
t.Fatalf("expected question mark, got %q", out)
}
}
func TestHeuristicEN_period(t *testing.T) {
h := Heuristic{}
out, err := h.Restore(context.Background(), "hello world", "en")
if err != nil {
t.Fatal(err)
}
if !stringsHasSuffix(out, ".") {
t.Fatalf("expected period, got %q", out)
}
}
func stringsHasSuffix(s, suffix string) bool {
return len(s) >= len(suffix) && s[len(s)-len(suffix):] == suffix
}