v0.1 - initial commit
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user