xx/mem/mem_test.go

26 lines
357 B
Go

package mem_test
import (
"testing"
"git.brut.systems/judah/xx/mem"
)
func TestBitCast(t *testing.T) {
a := uint32(0xFFFF_FFFF)
b := mem.BitCast[float32](&a)
c := mem.BitCast[uint32](&b)
if a != c {
t.Fail()
}
v := uint8(0xFF)
d := mem.BitCast[int8](&v)
if d != -1 {
t.Fail()
}
e := mem.BitCast[uint8](&d)
if e != 255 {
t.Fail()
}
}