43 lines
689 B
Go
43 lines
689 B
Go
package handler
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestStringPtr(t *testing.T) {
|
|
testCases := []struct {
|
|
name string
|
|
input *string
|
|
expected string
|
|
}{
|
|
{
|
|
name: "nil pointer",
|
|
input: nil,
|
|
expected: "",
|
|
},
|
|
{
|
|
name: "empty string",
|
|
input: strPtr(""),
|
|
expected: "",
|
|
},
|
|
{
|
|
name: "non-empty string",
|
|
input: strPtr("test"),
|
|
expected: "test",
|
|
},
|
|
}
|
|
|
|
for _, tc := range testCases {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
result := stringPtr(tc.input)
|
|
assert.Equal(t, tc.expected, result)
|
|
})
|
|
}
|
|
}
|
|
|
|
// Helper function to create string pointer
|
|
func strPtr(s string) *string {
|
|
return &s
|
|
}
|