debian-forge-composer/internal/common/pointers_test.go
Ondřej Budai b997142db0 common: merge all *ToPtr methods to one generic ToPtr
After introducing Go 1.18 to a project, it's required by law to convert at
least one method to a generic one.

Everyone hates IntToPtr, StringToPtr, BoolToPtr and Uint64ToPtr, so let's
convert them to the ultimate generic ToPtr one.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2023-01-09 14:03:18 +01:00

26 lines
510 B
Go

package common
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestToPtr(t *testing.T) {
var valueInt int = 42
gotInt := ToPtr(valueInt)
assert.Equal(t, valueInt, *gotInt)
var valueBool bool = true
gotBool := ToPtr(valueBool)
assert.Equal(t, valueBool, *gotBool)
var valueUint64 uint64 = 1
gotUint64 := ToPtr(valueUint64)
assert.Equal(t, valueUint64, *gotUint64)
var valueStr string = "the-greatest-test-value"
gotStr := ToPtr(valueStr)
assert.Equal(t, valueStr, *gotStr)
}