From 3780c619a4d5a5afd56876d9afe105e548bcccee Mon Sep 17 00:00:00 2001
From: Volker Schukai <volker.schukai@schukai.com>
Date: Sat, 16 Sep 2023 16:18:19 +0200
Subject: [PATCH] chore: code optimization

---
 find.go          |  2 +-
 issue_13_test.go |  1 -
 issue_14_test.go |  9 +++++++++
 set_test.go      | 41 ++++++++++++++++++++++++++++-------------
 4 files changed, 38 insertions(+), 15 deletions(-)
 delete mode 100644 issue_13_test.go
 create mode 100644 issue_14_test.go

diff --git a/find.go b/find.go
index 39955d3..cbf1973 100644
--- a/find.go
+++ b/find.go
@@ -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
 		}
diff --git a/issue_13_test.go b/issue_13_test.go
deleted file mode 100644
index b4c2bbf..0000000
--- a/issue_13_test.go
+++ /dev/null
@@ -1 +0,0 @@
-package pathfinder
diff --git a/issue_14_test.go b/issue_14_test.go
new file mode 100644
index 0000000..66bab07
--- /dev/null
+++ b/issue_14_test.go
@@ -0,0 +1,9 @@
+package pathfinder
+
+import (
+	"testing"
+)
+
+func TestPathFindSetValueFrom14(t *testing.T) {
+	
+}
diff --git a/set_test.go b/set_test.go
index 37adcb7..76dde97 100644
--- a/set_test.go
+++ b/set_test.go
@@ -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")
-- 
GitLab