Add two new helper functions `IntToPtr()` and `BoolToPtr()` to the `internal/common` package, which can be used to conveniently set basic type literals in a struct literal, in which pointer to the basic type is expected. Signed-off-by: Tomas Hozza <thozza@redhat.com>
19 lines
304 B
Go
19 lines
304 B
Go
package common
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestIntToPtr(t *testing.T) {
|
|
var value int = 42
|
|
got := IntToPtr(value)
|
|
assert.Equal(t, value, *got)
|
|
}
|
|
|
|
func TestBoolToPtr(t *testing.T) {
|
|
var value bool = true
|
|
got := BoolToPtr(value)
|
|
assert.Equal(t, value, *got)
|
|
}
|