Use testify.
This commit is contained in:
7
go.mod
7
go.mod
@@ -1,3 +1,10 @@
|
||||
module github.com/gslin/go-ir-playground
|
||||
|
||||
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
|
||||
)
|
||||
|
||||
@@ -2,18 +2,18 @@ package ngram_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/gslin/go-ir-playground/internal/ngram"
|
||||
)
|
||||
|
||||
func TestUnigram(t *testing.T) {
|
||||
a := ngram.Unigram("test")
|
||||
if len(a) != 1 || a[0] != "test" {
|
||||
t.Error()
|
||||
}
|
||||
assert.Equal(t, len(a), 1)
|
||||
assert.Equal(t, a[0], "test")
|
||||
|
||||
a = ngram.Unigram("測試")
|
||||
if len(a) != 2 || a[0] != "測" || a[1] != "試" {
|
||||
t.Error()
|
||||
}
|
||||
assert.Equal(t, len(a), 2)
|
||||
assert.Equal(t, a[0], "測")
|
||||
assert.Equal(t, a[1], "試")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user