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
33 lines
744 B
Go
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
|
|
}
|