Repository navigation
Expand file tree
/
Copy pathcapability_test.go
More file actions
73 lines (67 loc) · 1.61 KB
/
Copy pathcapability_test.go
File metadata and controls
73 lines (67 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package argus
import (
"reflect"
"testing"
)
func TestCapability_Has(t *testing.T) {
caps := ModalityTextIn | ModalityTextOut | CapFunctionCall
if !caps.Has(ModalityTextIn) {
t.Error("Expected to have ModalityTextIn")
}
if !caps.Has(CapFunctionCall) {
t.Error("Expected to have CapFunctionCall")
}
if caps.Has(ModalityImageIn) {
t.Error("Expected NOT to have ModalityImageIn")
}
// Test multiple at once
if !caps.Has(ModalityTextIn | ModalityTextOut) {
t.Error("Expected to have both text in and out")
}
}
func TestCapability_All(t *testing.T) {
tests := []struct {
name string
input Capability
wantStr string
wantList []string
}{
{
name: "空值测试",
input: 0,
wantStr: "None",
wantList: []string{},
},
{
name: "单项测试",
input: ModalityTextIn,
wantStr: "TextIn",
wantList: []string{"TextIn"},
},
{
name: "组合测试",
input: ModalityTextIn | CapFunctionCall,
wantStr: "TextIn|FunctionCall",
wantList: []string{"TextIn", "FunctionCall"},
},
{
name: "未知位测试",
input: 1 << 62, // 一个未定义的位
wantStr: "Unknown(0x4000000000000000)",
wantList: []string{"Unknown(0x4000000000000000)"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// 测试 String()
if got := tt.input.String(); got != tt.wantStr {
t.Errorf("String() = %v, want %v", got, tt.wantStr)
}
// 测试 ToStrings()
gotList := tt.input.ToStrings()
if !reflect.DeepEqual(gotList, tt.wantList) {
t.Errorf("ToStrings() = %v, want %v", gotList, tt.wantList)
}
})
}
}