2019-10-09 19:05:12 +00:00
|
|
|
package trans_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"."
|
|
|
|
"reflect"
|
2019-10-11 20:40:02 +00:00
|
|
|
"os"
|
2019-10-09 19:05:12 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
type testData struct {
|
|
|
|
job []string
|
2019-10-11 20:08:06 +00:00
|
|
|
transOutput string
|
2019-10-09 19:05:12 +00:00
|
|
|
expectedResults []string
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestTranslation(t *testing.T) {
|
|
|
|
cases := []testData{
|
|
|
|
testData{
|
2019-10-09 19:58:25 +00:00
|
|
|
[]string{"actuator", "en", "hu"},
|
2019-10-11 20:08:06 +00:00
|
|
|
`működtető
|
2019-10-09 19:58:25 +00:00
|
|
|
|
|
|
|
noun
|
|
|
|
indítókar
|
|
|
|
actuator, starting lever
|
2019-10-09 19:05:12 +00:00
|
|
|
|
|
|
|
actuator
|
2019-10-09 19:58:25 +00:00
|
|
|
működtető, beavatkozó, hajtómű, aktuátor, hajtás
|
2019-10-11 20:08:06 +00:00
|
|
|
`,
|
2019-10-09 19:58:25 +00:00
|
|
|
[]string{"működtető", "indítókar", "beavatkozó", "hajtómű", "aktuátor", "hajtás"},
|
|
|
|
},
|
|
|
|
testData{
|
|
|
|
[]string{"szaxofon", "hu", "en"},
|
2019-10-11 20:08:06 +00:00
|
|
|
`saxophone
|
2019-10-09 19:58:25 +00:00
|
|
|
|
|
|
|
szaxofon
|
|
|
|
saxophone
|
2019-10-11 20:08:06 +00:00
|
|
|
`,
|
2019-10-09 19:58:25 +00:00
|
|
|
[]string{"saxophone"},
|
|
|
|
},
|
|
|
|
testData{
|
|
|
|
[]string{"cat", "en", "hu"},
|
2019-10-11 20:08:06 +00:00
|
|
|
`macska
|
2019-10-09 19:58:25 +00:00
|
|
|
|
|
|
|
noun
|
|
|
|
macska
|
|
|
|
cat, pussy
|
|
|
|
pletykás nő
|
|
|
|
cat
|
|
|
|
|
|
|
|
verb
|
|
|
|
felvon
|
|
|
|
hoist, cat
|
|
|
|
|
|
|
|
cat
|
|
|
|
macska, cica
|
2019-10-11 20:08:06 +00:00
|
|
|
`,
|
2019-10-09 19:58:25 +00:00
|
|
|
[]string{"macska", "pletykás nő", "felvon", "cica"},
|
|
|
|
},
|
|
|
|
testData{
|
|
|
|
[]string{"méltányosság", "hu", "en"},
|
2019-10-11 20:08:06 +00:00
|
|
|
`equity
|
2019-10-09 19:58:25 +00:00
|
|
|
|
|
|
|
noun
|
|
|
|
equity
|
|
|
|
méltányosság, jogosság
|
|
|
|
fairness
|
|
|
|
méltányosság, szőkeség
|
|
|
|
justness
|
|
|
|
jogosság, méltányosság
|
|
|
|
|
|
|
|
méltányosság
|
|
|
|
equity, fairness
|
2019-10-11 20:08:06 +00:00
|
|
|
`,
|
2019-10-09 19:58:25 +00:00
|
|
|
[]string{"equity", "fairness", "justness"},
|
2019-10-09 19:05:12 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, data := range cases {
|
|
|
|
j := trans.New(data.job[0], data.job[1], data.job[2])
|
2019-10-11 20:40:02 +00:00
|
|
|
if _, ok := os.LookupEnv("NOMOCK"); !ok {
|
|
|
|
j.Translator = func(t *trans.Translation) (string, error) {
|
|
|
|
return data.transOutput, nil
|
|
|
|
}
|
2019-10-09 19:05:12 +00:00
|
|
|
}
|
|
|
|
r := j.Translate()
|
|
|
|
if (!reflect.DeepEqual(r, data.expectedResults)) {
|
2019-10-09 19:58:25 +00:00
|
|
|
t.Errorf("\nExpected: '%v'\nActual: '%v'", data.expectedResults, r)
|
2019-10-09 19:05:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|