Use testify.

This commit is contained in:
Gea-Suan Lin
2024-02-16 20:49:00 +08:00
parent 6247ed36cd
commit 8c3985c386
2 changed files with 13 additions and 6 deletions

7
go.mod
View File

@@ -1,3 +1,10 @@
module github.com/gslin/go-ir-playground module github.com/gslin/go-ir-playground
go 1.21.6 go 1.21.6
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/testify v1.8.4 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

View File

@@ -2,18 +2,18 @@ package ngram_test
import ( import (
"testing" "testing"
"github.com/stretchr/testify/assert"
"github.com/gslin/go-ir-playground/internal/ngram" "github.com/gslin/go-ir-playground/internal/ngram"
) )
func TestUnigram(t *testing.T) { func TestUnigram(t *testing.T) {
a := ngram.Unigram("test") a := ngram.Unigram("test")
if len(a) != 1 || a[0] != "test" { assert.Equal(t, len(a), 1)
t.Error() assert.Equal(t, a[0], "test")
}
a = ngram.Unigram("測試") a = ngram.Unigram("測試")
if len(a) != 2 || a[0] != "測" || a[1] != "試" { assert.Equal(t, len(a), 2)
t.Error() assert.Equal(t, a[0], "測")
} assert.Equal(t, a[1], "試")
} }