internal/common: add function to get a pointer to string literal
Add a new helper function to get a pointer to a string literal. Add unit test for the new function. Signed-off-by: Tomas Hozza <thozza@redhat.com>
This commit is contained in:
parent
52ccf1d6ef
commit
6c32ff048a
2 changed files with 16 additions and 0 deletions
|
|
@ -11,3 +11,7 @@ func Uint64ToPtr(x uint64) *uint64 {
|
||||||
func BoolToPtr(x bool) *bool {
|
func BoolToPtr(x bool) *bool {
|
||||||
return &x
|
return &x
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func StringToPtr(x string) *string {
|
||||||
|
return &x
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,3 +17,15 @@ func TestBoolToPtr(t *testing.T) {
|
||||||
got := BoolToPtr(value)
|
got := BoolToPtr(value)
|
||||||
assert.Equal(t, value, *got)
|
assert.Equal(t, value, *got)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestUint64ToPtr(t *testing.T) {
|
||||||
|
var value uint64 = 1
|
||||||
|
got := Uint64ToPtr(value)
|
||||||
|
assert.Equal(t, value, *got)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestStringToPtr(t *testing.T) {
|
||||||
|
var value string = "the-greatest-test-value"
|
||||||
|
got := StringToPtr(value)
|
||||||
|
assert.Equal(t, value, *got)
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue