Debian Codegraph @

internal/sys/ptr_test.go

raw symbols SCIP
1 package sys
2
3 import (
4 "fmt"
5 "reflect"
6 "testing"
7 "unsafe"
8
9 "github.com/go-quicktest/qt"
10 )
11
12 func TestTypedPointer(t *testing.T) {
13 ptrs := []any{
14 TypedPointer[uint32]{},
15 TypedPointer[complex128]{},
16 StringPointer{},
17 StringSlicePointer{},
18 }
19
20 for i, a := range ptrs {
21 qt.Assert(t, qt.Equals(unsafe.Alignof(a), unsafe.Alignof(unsafe.Pointer(nil))))
22
23 for _, b := range ptrs[i+1:] {
24 t.Run(fmt.Sprintf("%T %T", a, b), func(t *testing.T) {
25 typeOfA := reflect.TypeOf(a)
26 typeOfB := reflect.TypeOf(b)
27 qt.Assert(t, qt.IsFalse(typeOfA.ConvertibleTo(typeOfB)))
28 })
29 }
30 }
31 }