Files
go_pwner/packing_test.go
2026-07-18 21:37:15 +03:00

28 lines
622 B
Go

package winpwn
import (
"bytes"
"testing"
)
func TestPackLittleEndian(t *testing.T) {
if !bytes.Equal(P16(0x1234), []byte{0x34, 0x12}) {
t.Error("P16(0x1234) is not little-endian")
}
if !bytes.Equal(P32(0xDEADBEEF), []byte{0xEF, 0xBE, 0xAD, 0xDE}) {
t.Error("P32(0xDEADBEEF) is not little-endian")
}
}
func TestPackUnpackRoundTrip(t *testing.T) {
if U16(P16(0xBEEF)) != 0xBEEF {
t.Error("U16(P16) round trip failed")
}
if U32(P32(0xDEADBEEF)) != 0xDEADBEEF {
t.Error("U32(P32) round trip failed")
}
if U64(P64(0x0102030405060708)) != 0x0102030405060708 {
t.Error("U64(P64) round trip failed")
}
}