debian-forge-composer/internal/common/pointers_test.go
Tomas Hozza 6c32ff048a 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>
2021-08-02 19:05:09 +02:00

31 lines
566 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)
}
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)
}