-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patha5er_test.go
83 lines (80 loc) · 1.87 KB
/
a5er_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
73
74
75
76
77
78
79
80
81
82
83
package a5er
import (
"reflect"
"testing"
)
func TestField_String(t *testing.T) {
type fields struct {
logicalName string
convertedPhysicalName string
physicalName string
other string
}
tests := []struct {
name string
fields fields
want string
}{
{
name: "not converted",
fields: fields{
logicalName: `"あい"`,
physicalName: `"a_i"`,
other: `"*数値","NOT NULL",0,"","",$00FF0000,""`,
},
want: `"あい","a_i","*数値","NOT NULL",0,"","",$00FF0000,""`,
},
{
name: "converted",
fields: fields{
logicalName: `"あい"`,
convertedPhysicalName: "love",
physicalName: `"a_i"`,
other: `"*数値","NOT NULL",0,"","",$00FF0000,""`,
},
want: `"あい","love","*数値","NOT NULL",0,"","",$00FF0000,""`,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
f := Field{
logicalName: tt.fields.logicalName,
convertedPhysicalName: tt.fields.convertedPhysicalName,
physicalName: tt.fields.physicalName,
other: tt.fields.other,
}
if got := f.String(); got != tt.want {
t.Errorf("String() = %v, want %v", got, tt.want)
}
})
}
}
func TestEntity_extractFields(t *testing.T) {
tests := []struct {
name string
fields []string
want []Field
}{
{
name: "",
fields: []string{
`"あい","a_i","*数値","NOT NULL",0,"","",$00FF0000,""`,
},
want: []Field{
{
logicalName: `"あい"`,
physicalName: `"a_i"`,
other: `"*数値","NOT NULL",0,"","",$00FF0000,""`,
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
e := &Entity{fields: tt.fields}
if got := e.extractFields(); !reflect.DeepEqual(got, tt.want) {
t.Errorf("extractFields() = %v, want %v", got, tt.want)
}
})
}
}