@@ -48,34 +48,38 @@ type object6 struct {
4848func TestGoDefine (t * testing.T ) {
4949 a := assert .New (t , false )
5050
51+ c := func (f * reflect.StructField ) string {
52+ return f .Name
53+ }
54+
5155 wont := "type object1 struct {\n \t Int\t int\t `json:\" int\" yaml:\" int\" `\n \t Array\t [5]int\n \t Slice\t []string\n \t Byte\t uint8\n }"
52- a .Equal (GoDefine (reflect .TypeFor [object1 ](), nil , false ), wont )
56+ a .Equal (GoDefine (reflect .TypeFor [object1 ](), nil , nil , false ), wont )
5357
5458 wont = "type object2 struct {\n \t Int\t int\t `json:\" int\" yaml:\" int\" `\n \t Object\t *struct {\n \t \t Int\t int\t `json:\" int\" yaml:\" int\" `\n \t \t Array\t [5]int\n \t \t Slice\t []string\n \t \t Byte\t uint8\n \t }\t `json:\" object\" `\n }"
55- a .Equal (GoDefine (reflect .TypeFor [* object2 ](), nil , false ), wont )
59+ a .Equal (GoDefine (reflect .TypeFor [* object2 ](), nil , nil , false ), wont )
5660
57- a .Equal (GoDefine (reflect .TypeFor [int ](), nil , false ), "int" )
61+ a .Equal (GoDefine (reflect .TypeFor [int ](), nil , nil , false ), "int" )
5862
59- a .Equal (GoDefine (reflect .TypeFor [string ](), nil , false ), "string" )
63+ a .Equal (GoDefine (reflect .TypeFor [string ](), nil , nil , false ), "string" )
6064
61- a .Equal (GoDefine (reflect .TypeFor [func ()](), nil , false ), "" )
65+ a .Equal (GoDefine (reflect .TypeFor [func ()](), nil , nil , false ), "" )
6266
6367 m := map [reflect.Type ]string {reflect .TypeFor [time.Time ](): "string" }
6468
65- a .Equal (GoDefine (reflect .TypeFor [time.Time ](), m , false ), "string" )
66- a .Equal (GoDefine (reflect .TypeFor [* time.Time ](), m , false ), "string" )
69+ a .Equal (GoDefine (reflect .TypeFor [time.Time ](), m , nil , false ), "string" )
70+ a .Equal (GoDefine (reflect .TypeFor [* time.Time ](), m , nil , false ), "string" )
6771
68- a .Equal (GoDefine (reflect .TypeFor [* object3 ](), m , false ), "type object3 struct {\n \t T\t string\t `json:\" t\" `\n }" )
69- a .Equal (GoDefine (reflect .TypeFor [* object3 ](), m , true ), "type object3 struct {\n \t int\t int\n \t T\t string\t `json:\" t\" `\n }" )
72+ a .Equal (GoDefine (reflect .TypeFor [* object3 ](), m , nil , false ), "type object3 struct {\n \t T\t string\t `json:\" t\" `\n }" )
73+ a .Equal (GoDefine (reflect .TypeFor [* object3 ](), m , nil , true ), "type object3 struct {\n \t int\t int\n \t T\t string\t `json:\" t\" `\n }" )
7074
71- a .Equal (GoDefine (reflect .TypeFor [* object4 ](), m , true ), "type object4 struct {\n \t int\t int\n \t T\t string\t `json:\" t\" `\n \t Int\t int\n }" )
72- a .Equal (GoDefine (reflect .TypeFor [* object4 ](), m , false ), "type object4 struct {\n \t T\t string\t `json:\" t\" `\n \t Int\t int\n }" )
75+ a .Equal (GoDefine (reflect .TypeFor [* object4 ](), m , nil , true ), "type object4 struct {\n \t int\t int\n \t T\t string\t `json:\" t\" `\n \t Int\t int\n }" )
76+ a .Equal (GoDefine (reflect .TypeFor [* object4 ](), m , nil , false ), "type object4 struct {\n \t T\t string\t `json:\" t\" `\n \t Int\t int\n }" )
7377
74- a .Equal (GoDefine (reflect .TypeFor [* object5 ](), m , true ), "type object5 struct {\n \t int\t int\n \t T\t string\t `json:\" t\" `\n \t Int\t int\n \t Str\t string\n }" )
75- a .Equal (GoDefine (reflect .TypeFor [* object5 ](), m , false ), "type object5 struct {\n \t T\t string\t `json:\" t\" `\n \t Int\t int\n \t Str\t string\n }" )
78+ a .Equal (GoDefine (reflect .TypeFor [* object5 ](), m , nil , true ), "type object5 struct {\n \t int\t int\n \t T\t string\t `json:\" t\" `\n \t Int\t int\n \t Str\t string\n }" )
79+ a .Equal (GoDefine (reflect .TypeFor [* object5 ](), m , c , false ), "type object5 struct {\n \t T\t string\t `json:\" t\" `\t // T \ n\t Int\t int\t // Int \ n\t Str\t string\t // Str \n }" )
7680
77- a .Equal (GoDefine (reflect .TypeFor [time.Time ](), m , false ), "string" )
78- a .Equal (GoDefine (reflect .TypeFor [time.Time ](), nil , false ), "type Time struct {\n }" )
81+ a .Equal (GoDefine (reflect .TypeFor [time.Time ](), m , nil , false ), "string" )
82+ a .Equal (GoDefine (reflect .TypeFor [time.Time ](), nil , nil , false ), "type Time struct {\n }" )
7983
80- a .Equal (GoDefine (reflect .TypeFor [object6 ](), m , false ), "type object6 struct {\n \t XMLName\t struct {}\t `json:\" root\" `\n \t Str\t []*struct {\n \t \t T\t string\t `json:\" t\" `\n \t }\n }" )
84+ a .Equal (GoDefine (reflect .TypeFor [object6 ](), m , nil , false ), "type object6 struct {\n \t XMLName\t struct {}\t `json:\" root\" `\n \t Str\t []*struct {\n \t \t T\t string\t `json:\" t\" `\n \t }\n }" )
8185}
0 commit comments