mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-06-27 06:42:04 -03:00
test: refactor and simplify TestLinguistSamples
test plan - go test -run '^Test_EnryOnLinguistCorpus$' github.com/go-enry/go-enry/v2
This commit is contained in:
@ -8,7 +8,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/go-enry/go-enry/v2/data"
|
"github.com/go-enry/go-enry/v2/data"
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,25 +44,23 @@ func (s *linguistCorpusSuite) TestLinguistSamples() {
|
|||||||
content, _ := ioutil.ReadFile(path)
|
content, _ := ioutil.ReadFile(path)
|
||||||
|
|
||||||
total++
|
total++
|
||||||
obtained := GetLanguage(filename, content)
|
got := GetLanguage(filename, content)
|
||||||
if obtained == OtherLanguage {
|
if got == OtherLanguage {
|
||||||
obtained = "Other"
|
got = "Other"
|
||||||
other++
|
other++
|
||||||
}
|
}
|
||||||
|
|
||||||
var status string
|
if expected == got {
|
||||||
if expected == obtained {
|
|
||||||
status = "ok"
|
|
||||||
ok++
|
ok++
|
||||||
} else {
|
} else {
|
||||||
status = "failed"
|
|
||||||
failed++
|
failed++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
errMsg := fmt.Sprintf("file: %q\texpected: %q\tgot: %q\n", path, expected, got)
|
||||||
if _, ok := cornerCases[filename]; ok {
|
if _, ok := cornerCases[filename]; ok {
|
||||||
s.T().Logf("\t\t[considered corner case] %s\texpected: %s\tobtained: %s\tstatus: %s\n", filename, expected, obtained, status)
|
s.T().Logf(fmt.Sprintf("\t\t[corner case] %s", errMsg))
|
||||||
} else {
|
} else {
|
||||||
assert.Equal(s.T(), expected, obtained, fmt.Sprintf("%s\texpected: %s\tobtained: %s\tstatus: %s\n", filename, expected, obtained, status))
|
s.Equal(expected, got, errMsg)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user