Skip to content

Commit

Permalink
Create conversion_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
ShocOne authored Jul 29, 2024
1 parent e7750e2 commit 847cdb0
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions internal/conversion_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package helpers

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestStringPtrToString(t *testing.T) {
t.Run("NilPointer", func(t *testing.T) {
var strPtr *string
result := StringPtrToString(strPtr)
assert.Equal(t, "", result, "Expected empty string when input is nil pointer")
})

t.Run("NonNilPointer", func(t *testing.T) {
str := "test string"
strPtr := &str
result := StringPtrToString(strPtr)
assert.Equal(t, "test string", result, "Expected 'test string' when input is non-nil pointer")
})

t.Run("EmptyStringPointer", func(t *testing.T) {
str := ""
strPtr := &str
result := StringPtrToString(strPtr)
assert.Equal(t, "", result, "Expected empty string when input is pointer to an empty string")
})
}

0 comments on commit 847cdb0

Please sign in to comment.