-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkw_test.go
72 lines (64 loc) · 1.36 KB
/
kw_test.go
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
package gp
import (
"reflect"
"testing"
)
func TestSplitArgs(t *testing.T) {
setupTest(t)
tests := []struct {
name string
args []any
wantTup Tuple
wantKw KwArgs
}{
{
name: "empty args",
args: []any{},
wantTup: MakeTuple(),
wantKw: nil,
},
{
name: "only positional args",
args: []any{1, "two", 3.0},
wantTup: MakeTuple(1, "two", 3.0),
wantKw: nil,
},
{
name: "with kwargs",
args: []any{1, "two", KwArgs{"a": 1, "b": "test"}},
wantTup: MakeTuple(1, "two"),
wantKw: KwArgs{"a": 1, "b": "test"},
},
{
name: "only kwargs",
args: []any{KwArgs{"x": 10, "y": 20}},
wantTup: MakeTuple(),
wantKw: KwArgs{"x": 10, "y": 20},
},
}
for _, tt := range tests {
gotTup, gotKw := splitArgs(tt.args...)
if !reflect.DeepEqual(gotTup, tt.wantTup) {
t.Errorf("splitArgs() tuple = %v, want %v", gotTup, tt.wantTup)
}
if !reflect.DeepEqual(gotKw, tt.wantKw) {
t.Errorf("splitArgs() kwargs = %v, want %v", gotKw, tt.wantKw)
}
}
}
func TestKwArgs(t *testing.T) {
setupTest(t)
kw := KwArgs{
"name": "test",
"age": 42,
}
// Test type assertion
if _, ok := interface{}(kw).(KwArgs); !ok {
t.Error("KwArgs failed type assertion")
}
// Test map operations
kw["new"] = "value"
if v, ok := kw["new"]; !ok || v != "value" {
t.Error("KwArgs map operations failed")
}
}