Skip to content

Commit

Permalink
Merge pull request #3 from cage1016/fix/test-fail
Browse files Browse the repository at this point in the history
fix test fail
  • Loading branch information
cage1016 committed Nov 22, 2022
2 parents 1481584 + cda517a commit 18b724f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 24 deletions.
9 changes: 1 addition & 8 deletions occ/occ.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package occ

import (
"log"

"github.com/cage1016/opencc"
)

Expand Down Expand Up @@ -45,16 +43,11 @@ type Config struct {

func New(cfg Config) map[string]ConvertMap {
var fn = func(l Language) *opencc.OpenCC {
o, err := opencc.New(string(l))
if err != nil {
log.Printf("%s", err)
return nil
}
o, _ := opencc.New(string(l))
return o
}

m := make(map[string]ConvertMap)

m["簡體到繁體"] = ConvertMap{fn(S2t), "簡體到繁體", "TraditionalChinese.png", S2t, cfg.S2t_Enabled, 0}
m["繁體到簡體"] = ConvertMap{fn(T2s), "繁體到簡體", "SimplifiedChinese.png", T2s, cfg.T2s_Enabled, 1}
m["簡體到臺灣正體"] = ConvertMap{fn(S2tw), "簡體到臺灣正體", "TW_taiwan.png", S2tw, cfg.S2tw_Enabled, 2}
Expand Down
24 changes: 8 additions & 16 deletions occ/occ_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ func TestNew(t *testing.T) {
{
name: "s2t",
prepare: func(f *fields) {
oc := occ.New(occ.Config{S2t_Enabled: true})
f.occ = oc[occ.Item{occ.S2t, 0}]
f.occ = occ.New(occ.Config{true, true, true, true, true, true, true, true})["簡體到繁體"]
},
args: args{
input: map[string]string{
Expand All @@ -41,8 +40,7 @@ func TestNew(t *testing.T) {
{
name: "t2s",
prepare: func(f *fields) {
oc := occ.New(occ.Config{T2s_Enabled: true})
f.occ = oc[occ.Item{occ.T2s, 1}]
f.occ = occ.New(occ.Config{true, true, true, true, true, true, true, true})["繁體到簡體"]
},
args: args{
input: map[string]string{
Expand All @@ -53,8 +51,7 @@ func TestNew(t *testing.T) {
{
name: "s2tw",
prepare: func(f *fields) {
oc := occ.New(occ.Config{S2tw_Enabled: true})
f.occ = oc[occ.Item{occ.S2tw, 2}]
f.occ = occ.New(occ.Config{true, true, true, true, true, true, true, true})["簡體到臺灣正體"]
},
args: args{
input: map[string]string{
Expand All @@ -66,8 +63,7 @@ func TestNew(t *testing.T) {
{
name: "tw2s",
prepare: func(f *fields) {
oc := occ.New(occ.Config{Tw2s_Enabled: true})
f.occ = oc[occ.Item{occ.Tw2s, 3}]
f.occ = occ.New(occ.Config{true, true, true, true, true, true, true, true})["臺灣正體到簡體"]
},
args: args{
input: map[string]string{
Expand All @@ -78,8 +74,7 @@ func TestNew(t *testing.T) {
{
name: "s2hk",
prepare: func(f *fields) {
oc := occ.New(occ.Config{S2hk_Enabled: true})
f.occ = oc[occ.Item{occ.S2hk, 4}]
f.occ = occ.New(occ.Config{true, true, true, true, true, true, true, true})["簡體到香港繁體"]
},
args: args{
input: map[string]string{
Expand All @@ -93,8 +88,7 @@ func TestNew(t *testing.T) {
{
name: "hk2s",
prepare: func(f *fields) {
oc := occ.New(occ.Config{Hk2s_Enabled: true})
f.occ = oc[occ.Item{occ.Hk2s, 5}]
f.occ = occ.New(occ.Config{true, true, true, true, true, true, true, true})["香港繁體到簡體"]
},
args: args{
input: map[string]string{
Expand All @@ -107,8 +101,7 @@ func TestNew(t *testing.T) {
{
name: "s2twp",
prepare: func(f *fields) {
oc := occ.New(occ.Config{S2twp_Enabled: true})
f.occ = oc[occ.Item{occ.S2twp, 6}]
f.occ = occ.New(occ.Config{true, true, true, true, true, true, true, true})["簡體到繁體(臺灣正體標準)並轉換爲臺灣常用詞彙"]
},
args: args{
input: map[string]string{
Expand All @@ -122,8 +115,7 @@ func TestNew(t *testing.T) {
{
name: "tw2sp",
prepare: func(f *fields) {
oc := occ.New(occ.Config{Tw2sp_Enabled: true})
f.occ = oc[occ.Item{occ.Tw2sp, 7}]
f.occ = occ.New(occ.Config{true, true, true, true, true, true, true, true})["繁體(臺灣正體標準)到簡體並轉換爲中國大陸常用詞彙"]
},
args: args{
input: map[string]string{
Expand Down

0 comments on commit 18b724f

Please sign in to comment.