v0.0.480
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m20s

This commit is contained in:
Mike Schwörer 2024-07-02 11:32:22 +02:00
parent b464afae01
commit 19d943361b
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
2 changed files with 26 additions and 2 deletions

View File

@ -1,5 +1,5 @@
package goext package goext
const GoextVersion = "0.0.479" const GoextVersion = "0.0.480"
const GoextVersionTimestamp = "2024-07-02T11:29:47+0200" const GoextVersionTimestamp = "2024-07-02T11:32:22+0200"

View File

@ -233,3 +233,27 @@ func TestAccessStructByArrayPath_UsedTagForKeysInvalid(t *testing.T) {
t.Errorf("Expected error, got nil") t.Errorf("Expected error, got nil")
} }
} }
type DifferentTypeStruct struct {
Name string
Age int
}
func TestAccessStructByArrayPath_DifferentType(t *testing.T) {
testStruct := DifferentTypeStruct{Name: "John", Age: 30}
result, err := AccessStructByArrayPath[any](testStruct, []string{"Age"})
if err != nil {
t.Errorf("Unexpected error: %v", err)
}
if result != 30 {
t.Errorf("Expected '30', got '%v'", result)
}
}
func TestAccessStructByArrayPath_DifferentTypeInvalid(t *testing.T) {
testStruct := DifferentTypeStruct{Name: "John", Age: 30}
_, err := AccessStructByArrayPath[any](testStruct, []string{"Invalid"})
if err == nil {
t.Errorf("Expected error, got nil")
}
}