|
@@ -739,15 +739,18 @@ type AssignTagFromSlice struct {
|
|
|
MapSliceField []map[string]string `assign:"toField:MapSliceField"`
|
|
|
ChanSliceField []chan any `assign:"toField:ChanSliceField"`
|
|
|
FuncSliceField []func() string `assign:"toField:FuncSliceField"`
|
|
|
+ FromStringSliceToStringField []string `assign:"toField:FromStringSliceToStringField"`
|
|
|
+ FromTimeToStringField []time.Time `assign:"toField:FromTimeToStringField"`
|
|
|
+ FromStringToTimeField []string `assign:"toField:FromStringToTimeField"`
|
|
|
BasicPointerSliceField []*string `assign:"toField:BasicPointerSliceField"`
|
|
|
TimePointerSliceField []*time.Time `assign:"toField:TimePointerSliceField"`
|
|
|
StructPointerSliceField []*AssignTagFrom `assign:"toField:StructPointerSliceField"`
|
|
|
MapPointerSliceField []*map[string]string `assign:"toField:MapPointerSliceField"`
|
|
|
ChanPointerSliceField []*chan any `assign:"toField:ChanPointerSliceField"`
|
|
|
FuncPointerSliceField []*func() string `assign:"toField:FuncPointerSliceField"`
|
|
|
- FromStringSliceToStringField []string `assign:"toField:FromStringSliceToStringField"`
|
|
|
- FromTimeToStringField []time.Time `assign:"toField:FromTimeToStringField"`
|
|
|
- FromStringToTimeField []string `assign:"toField:FromStringToTimeField"`
|
|
|
+ //FromStringSliceToStringPointerField []*string `assign:"toField:FromStringSliceToStringPointerField"`
|
|
|
+ //FromTimeToStringPointerField []*time.Time `assign:"toField:FromTimeToStringPointerField"`
|
|
|
+ //FromStringToTimePointerField []*string `assign:"toField:FromStringToTimePointerField"`
|
|
|
}
|
|
|
|
|
|
type AssignTagFromSlicePointerField struct {
|
|
@@ -758,15 +761,18 @@ type AssignTagFromSlicePointerField struct {
|
|
|
MapSliceField *[]map[string]string `assign:"toField:MapSliceField"`
|
|
|
ChanSliceField *[]chan any `assign:"toField:ChanSliceField"`
|
|
|
FuncSliceField *[]func() string `assign:"toField:FuncSliceField"`
|
|
|
+ FromStringSliceToStringField *[]string `assign:"toField:FromStringSliceToStringField"`
|
|
|
+ FromTimeToStringField *[]time.Time `assign:"toField:FromTimeToStringField"`
|
|
|
+ FromStringToTimeField *[]string `assign:"toField:FromStringToTimeField"`
|
|
|
BasicPointerSliceField *[]*string `assign:"toField:BasicPointerSliceField"`
|
|
|
TimePointerSliceField *[]*time.Time `assign:"toField:TimePointerSliceField"`
|
|
|
StructPointerSliceField *[]*AssignTagFrom `assign:"toField:StructPointerSliceField"`
|
|
|
MapPointerSliceField *[]*map[string]string `assign:"toField:MapPointerSliceField"`
|
|
|
ChanPointerSliceField *[]*chan any `assign:"toField:ChanPointerSliceField"`
|
|
|
FuncPointerSliceField *[]*func() string `assign:"toField:FuncPointerSliceField"`
|
|
|
- FromStringSliceToStringField *[]string `assign:"toField:FromStringSliceToStringField"`
|
|
|
- FromTimeToStringField *[]time.Time `assign:"toField:FromTimeToStringField"`
|
|
|
- FromStringToTimeField *[]string `assign:"toField:FromStringToTimeField"`
|
|
|
+ //FromStringSliceToStringPointerField *[]*string `assign:"toField:FromStringSliceToStringPointerField"`
|
|
|
+ //FromTimeToStringPointerField *[]*time.Time `assign:"toField:FromTimeToStringPointerField"`
|
|
|
+ //FromStringToTimePointerField *[]*string `assign:"toField:FromStringToTimePointerField"`
|
|
|
}
|
|
|
|
|
|
type AssignTagToSlice struct {
|
|
@@ -777,15 +783,18 @@ type AssignTagToSlice struct {
|
|
|
MapSliceField []map[string]string
|
|
|
ChanSliceField []chan any
|
|
|
FuncSliceField []func() string
|
|
|
+ FromStringSliceToStringField string
|
|
|
+ FromTimeToStringField []string
|
|
|
+ FromStringToTimeField []time.Time
|
|
|
BasicPointerSliceField []*string
|
|
|
TimePointerSliceField []*time.Time
|
|
|
StructPointerSliceField []*AssignTagTo
|
|
|
MapPointerSliceField []*map[string]string
|
|
|
ChanPointerSliceField []*chan any
|
|
|
FuncPointerSliceField []*func() string
|
|
|
- FromStringSliceToStringField string
|
|
|
- FromTimeToStringField []string
|
|
|
- FromStringToTimeField []time.Time
|
|
|
+ //FromStringSliceToStringPointerField string
|
|
|
+ //FromTimeToStringPointerField []*string
|
|
|
+ //FromStringToTimePointerField []*time.Time
|
|
|
}
|
|
|
|
|
|
func (to AssignTagToSlice) checkFields(t *testing.T, from AssignTagFromSlice) {
|
|
@@ -835,6 +844,25 @@ func (to AssignTagToSlice) checkFields(t *testing.T, from AssignTagFromSlice) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if strings.Join(from.FromStringSliceToStringField, "::") != to.FromStringSliceToStringField {
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("FromStringSliceToStringField not equal: from %v, to %v",
|
|
|
+ strings.Join(from.FromStringSliceToStringField, "::"), to.FromStringSliceToStringField))
|
|
|
+ }
|
|
|
+
|
|
|
+ for i, value := range from.FromTimeToStringField {
|
|
|
+ if value.Format(time.DateTime) != to.FromTimeToStringField[i] {
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("FromTimeToStringField not equal: from %v, to %v",
|
|
|
+ value.Format(time.DateTime), to.FromTimeToStringField[i]))
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for i, value := range from.FromStringToTimeField {
|
|
|
+ if value != to.FromStringToTimeField[i].Format(time.DateTime) {
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("FromStringToTimeField not equal: from %v, to %v",
|
|
|
+ value, to.FromStringToTimeField[i].Format(time.DateTime)))
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
for i, value := range from.BasicPointerSliceField {
|
|
|
if *value != *to.BasicPointerSliceField[i] {
|
|
|
t.Fatalf("%+v\n", errors.Errorf("BasicPointerSliceField not equal: from %v, to %v",
|
|
@@ -875,18 +903,6 @@ func (to AssignTagToSlice) checkFields(t *testing.T, from AssignTagFromSlice) {
|
|
|
(*value)(), (*to.FuncPointerSliceField[i])()))
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- if strings.Join(from.FromStringSliceToStringField, "::") != to.FromStringSliceToStringField {
|
|
|
- t.Fatalf("%+v\n", errors.Errorf("FromStringSliceToStringField not equal: from %v, to %v",
|
|
|
- strings.Join(from.FromStringSliceToStringField, "::"), to.FromStringSliceToStringField))
|
|
|
- }
|
|
|
-
|
|
|
- for i, value := range from.FromTimeToStringField {
|
|
|
- if value.Format(time.DateTime) != to.FromTimeToStringField[i] {
|
|
|
- t.Fatalf("%+v\n", errors.Errorf("FromTimeToStringField not equal: from %v, to %v",
|
|
|
- value.Format(time.DateTime), to.FromTimeToStringField))
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
func (to AssignTagToSlice) checkNil(t *testing.T) {
|
|
@@ -918,6 +934,18 @@ func (to AssignTagToSlice) checkNil(t *testing.T) {
|
|
|
t.Fatalf("%+v\n", errors.Errorf("FuncSliceField not nil"))
|
|
|
}
|
|
|
|
|
|
+ if to.FromStringSliceToStringField != "" {
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("FromStringSliceToStringField not zero"))
|
|
|
+ }
|
|
|
+
|
|
|
+ if to.FromTimeToStringField != nil {
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("FromTimeToStringField not nil"))
|
|
|
+ }
|
|
|
+
|
|
|
+ if to.FromStringToTimeField != nil {
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("FromStringToTimeField not nil"))
|
|
|
+ }
|
|
|
+
|
|
|
if to.BasicPointerSliceField != nil {
|
|
|
t.Fatalf("%+v\n", errors.Errorf("BasicPointerSliceField not nil"))
|
|
|
}
|
|
@@ -941,14 +969,6 @@ func (to AssignTagToSlice) checkNil(t *testing.T) {
|
|
|
if to.FuncPointerSliceField != nil {
|
|
|
t.Fatalf("%+v\n", errors.Errorf("FuncPointerSliceField not nil"))
|
|
|
}
|
|
|
-
|
|
|
- if to.FromStringSliceToStringField != "" {
|
|
|
- t.Fatalf("%+v\n", errors.Errorf("FromStringSliceToStringField not zero"))
|
|
|
- }
|
|
|
-
|
|
|
- if to.FromTimeToStringField != nil {
|
|
|
- t.Fatalf("%+v\n", errors.Errorf("FromTimeToStringField not nil"))
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
type AssignTagToSlicePointerField struct {
|
|
@@ -959,15 +979,18 @@ type AssignTagToSlicePointerField struct {
|
|
|
MapSliceField *[]map[string]string
|
|
|
ChanSliceField *[]chan any
|
|
|
FuncSliceField *[]func() string
|
|
|
+ FromStringSliceToStringField *string
|
|
|
+ FromTimeToStringField *[]string
|
|
|
+ FromStringToTimeField *[]time.Time
|
|
|
BasicPointerSliceField *[]*string
|
|
|
TimePointerSliceField *[]*time.Time
|
|
|
StructPointerSliceField *[]*AssignTagTo
|
|
|
MapPointerSliceField *[]*map[string]string
|
|
|
ChanPointerSliceField *[]*chan any
|
|
|
FuncPointerSliceField *[]*func() string
|
|
|
- FromStringSliceToStringField *string
|
|
|
- FromTimeToStringField *[]string
|
|
|
- FromStringToTimeField []time.Time
|
|
|
+ //FromStringSliceToStringPointerField *string
|
|
|
+ //FromTimeToStringPointerField *[]*string
|
|
|
+ //FromStringToTimePointerField *[]*time.Time
|
|
|
}
|
|
|
|
|
|
func (to AssignTagToSlicePointerField) checkFields(t *testing.T, from AssignTagFromSlice) {
|
|
@@ -1017,6 +1040,25 @@ func (to AssignTagToSlicePointerField) checkFields(t *testing.T, from AssignTagF
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if strings.Join(from.FromStringSliceToStringField, "::") != *to.FromStringSliceToStringField {
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("FromStringSliceToStringField not equal: from %v, to %v",
|
|
|
+ strings.Join(from.FromStringSliceToStringField, "::"), *to.FromStringSliceToStringField))
|
|
|
+ }
|
|
|
+
|
|
|
+ for i, value := range from.FromTimeToStringField {
|
|
|
+ if value.Format(time.DateTime) != (*to.FromTimeToStringField)[i] {
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("FromTimeToStringField not equal: from %v, to %v",
|
|
|
+ value.Format(time.DateTime), (*to.FromTimeToStringField)[i]))
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for i, value := range from.FromStringToTimeField {
|
|
|
+ if value != (*to.FromStringToTimeField)[i].Format(time.DateTime) {
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("FromStringToTimeField not equal: from %v, to %v",
|
|
|
+ value, (*to.FromStringToTimeField)[i].Format(time.DateTime)))
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
for i, value := range from.BasicPointerSliceField {
|
|
|
if *value != *(*to.BasicPointerSliceField)[i] {
|
|
|
t.Fatalf("%+v\n", errors.Errorf("BasicPointerSliceField not equal: from %v, to %v",
|
|
@@ -1057,18 +1099,6 @@ func (to AssignTagToSlicePointerField) checkFields(t *testing.T, from AssignTagF
|
|
|
(*value)(), (*(*to.FuncPointerSliceField)[i])()))
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- if strings.Join(from.FromStringSliceToStringField, "::") != *to.FromStringSliceToStringField {
|
|
|
- t.Fatalf("%+v\n", errors.Errorf("FromStringSliceToStringField not equal: from %v, to %v",
|
|
|
- strings.Join(from.FromStringSliceToStringField, "::"), *to.FromStringSliceToStringField))
|
|
|
- }
|
|
|
-
|
|
|
- for i, value := range from.FromTimeToStringField {
|
|
|
- if value.Format(time.DateTime) != (*to.FromTimeToStringField)[i] {
|
|
|
- t.Fatalf("%+v\n", errors.Errorf("FromTimeToStringField not equal: from %v, to %v",
|
|
|
- value.Format(time.DateTime), to.FromTimeToStringField))
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
func (to AssignTagToSlicePointerField) checkNil(t *testing.T) {
|
|
@@ -1100,6 +1130,18 @@ func (to AssignTagToSlicePointerField) checkNil(t *testing.T) {
|
|
|
t.Fatalf("%+v\n", errors.Errorf("FuncSliceField not nil"))
|
|
|
}
|
|
|
|
|
|
+ if to.FromStringSliceToStringField != nil {
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("FromStringSliceToStringField not nil"))
|
|
|
+ }
|
|
|
+
|
|
|
+ if to.FromTimeToStringField != nil {
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("FromTimeToStringField not nil"))
|
|
|
+ }
|
|
|
+
|
|
|
+ if to.FromStringToTimeField != nil {
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("FromStringToTimeField not nil"))
|
|
|
+ }
|
|
|
+
|
|
|
if to.BasicPointerSliceField != nil {
|
|
|
t.Fatalf("%+v\n", errors.Errorf("BasicPointerSliceField not nil"))
|
|
|
}
|
|
@@ -1123,14 +1165,6 @@ func (to AssignTagToSlicePointerField) checkNil(t *testing.T) {
|
|
|
if to.FuncPointerSliceField != nil {
|
|
|
t.Fatalf("%+v\n", errors.Errorf("FuncPointerSliceField not nil"))
|
|
|
}
|
|
|
-
|
|
|
- if to.FromStringSliceToStringField != nil {
|
|
|
- t.Fatalf("%+v\n", errors.Errorf("FromStringSliceToStringField not nil"))
|
|
|
- }
|
|
|
-
|
|
|
- if to.FromTimeToStringField != nil {
|
|
|
- t.Fatalf("%+v\n", errors.Errorf("FromTimeToStringField not nil"))
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
func TestAssignTagDefaultUsageSlice(t *testing.T) {
|