-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 修复不支持交叉编译错误
- Loading branch information
Showing
4 changed files
with
94 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Package ai | ||
// @Author Clover | ||
// @Data 2024/8/30 下午9:39:00 | ||
// @Desc | ||
package ai | ||
|
||
import ( | ||
"github.com/go-ego/gse" | ||
"testing" | ||
) | ||
|
||
func TestFilter_filter(t *testing.T) { | ||
type fields struct { | ||
seg gse.Segmenter | ||
} | ||
type args struct { | ||
input string | ||
handle func(content string) (string, error) | ||
} | ||
tests := []struct { | ||
name string | ||
fields fields | ||
args args | ||
wantRes string | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "test1", | ||
fields: fields{ | ||
seg: seg, | ||
}, | ||
args: args{ | ||
input: "共产党", | ||
handle: func(content string) (string, error) { return content, nil }, | ||
}, | ||
wantRes: "filtered", | ||
}, | ||
{ | ||
name: "test2", | ||
fields: fields{ | ||
seg: seg, | ||
}, | ||
args: args{ | ||
input: "rikka", | ||
handle: func(content string) (string, error) { return content, nil }, | ||
}, | ||
wantRes: "rikka", | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
f := &Filter{ | ||
seg: tt.fields.seg, | ||
} | ||
gotRes, err := f.filter(tt.args.input, tt.args.handle) | ||
if (err != nil) != tt.wantErr { | ||
t.Errorf("filter() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
if gotRes != tt.wantRes { | ||
t.Errorf("filter() gotRes = %v, want %v", gotRes, tt.wantRes) | ||
} | ||
}) | ||
} | ||
} |