Skip to content
Snippets Groups Projects
Verified Commit 3780c619 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

chore: code optimization

parent 2b47ee4c
No related branches found
No related tags found
No related merge requests found
......@@ -33,7 +33,7 @@ func FindPaths(v reflect.Value, targetType reflect.Type, path []string, paths *[
FindPaths(v.Index(i), targetType, newPath, paths)
}
case reflect.Bool, reflect.Int64, reflect.Int32, reflect.Int16, reflect.Int8, reflect.Int, reflect.Uint64, reflect.Uint32, reflect.Uint16, reflect.Uint8, reflect.Uint:
case reflect.String, reflect.Bool, reflect.Int64, reflect.Int32, reflect.Int16, reflect.Int8, reflect.Int, reflect.Uint64, reflect.Uint32, reflect.Uint16, reflect.Uint8, reflect.Uint:
if vType != targetType {
return
}
......
package pathfinder
package pathfinder
import (
"testing"
)
func TestPathFindSetValueFrom14(t *testing.T) {
}
......@@ -3,7 +3,10 @@
package pathfinder
import "testing"
import (
"github.com/stretchr/testify/assert"
"testing"
)
type PathfindTestStruct1 struct {
A bool
......@@ -198,10 +201,14 @@ func TestPathFindGetValueFrom(t *testing.T) {
func TestPathFindSetValueFrom(t *testing.T) {
s := &PathfindTestStruct1{}
SetValue[*PathfindTestStruct1](s, "Sub1.B", "true")
SetValue[*PathfindTestStruct1](s, "Sub1.Bi", "2")
SetValue[*PathfindTestStruct1](s, "Sub1.Bs", "3")
SetValue[*PathfindTestStruct1](s, "Sub1.Bf", "4.0")
err := SetValue[*PathfindTestStruct1](s, "Sub1.B", "true")
assert.Nil(t, err)
err = SetValue[*PathfindTestStruct1](s, "Sub1.Bi", "2")
assert.Nil(t, err)
err = SetValue[*PathfindTestStruct1](s, "Sub1.Bs", "3")
assert.Nil(t, err)
err = SetValue[*PathfindTestStruct1](s, "Sub1.Bf", "4.0")
assert.Nil(t, err)
if s.Sub1.B != true {
t.Error("s.Sub1.B != true")
......@@ -220,10 +227,14 @@ func TestPathFindSetValueFrom(t *testing.T) {
t.Error("s.Sub1.Bf != 4.0")
}
SetValue[*PathfindTestStruct1](s, "Sub1.Sub2.C", "true")
SetValue[*PathfindTestStruct1](s, "Sub1.Sub2.Ci", "2")
SetValue[*PathfindTestStruct1](s, "Sub1.Sub2.Cs", "3")
SetValue[*PathfindTestStruct1](s, "Sub1.Sub2.Cf", "4.0")
err = SetValue[*PathfindTestStruct1](s, "Sub1.Sub2.C", "true")
assert.Nil(t, err)
err = SetValue[*PathfindTestStruct1](s, "Sub1.Sub2.Ci", "2")
assert.Nil(t, err)
err = SetValue[*PathfindTestStruct1](s, "Sub1.Sub2.Cs", "3")
assert.Nil(t, err)
err = SetValue[*PathfindTestStruct1](s, "Sub1.Sub2.Cf", "4.0")
assert.Nil(t, err)
if s.Sub1.Sub2.C != true {
t.Error("s.Sub1.Sub2.C != true")
......@@ -250,10 +261,14 @@ func TestPathFindSetValueFrom(t *testing.T) {
}
SetValue[*PathfindTestStruct1](s, "Sub1.Sub2.Sub3.D", "true")
SetValue[*PathfindTestStruct1](s, "Sub1.Sub2.Sub3.Di", "2")
SetValue[*PathfindTestStruct1](s, "Sub1.Sub2.Sub3.Ds", "3")
SetValue[*PathfindTestStruct1](s, "Sub1.Sub2.Sub3.Df", "4.0")
err = SetValue[*PathfindTestStruct1](s, "Sub1.Sub2.Sub3.D", "true")
assert.Nil(t, err)
err = SetValue[*PathfindTestStruct1](s, "Sub1.Sub2.Sub3.Di", "2")
assert.Nil(t, err)
err = SetValue[*PathfindTestStruct1](s, "Sub1.Sub2.Sub3.Ds", "3")
assert.Nil(t, err)
err = SetValue[*PathfindTestStruct1](s, "Sub1.Sub2.Sub3.Df", "4.0")
assert.Nil(t, err)
if s.Sub1.Sub2.Sub3.D != true {
t.Error("s.Sub1.Sub2.Sub3.D != true")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment