-
Notifications
You must be signed in to change notification settings - Fork 22
/
struct_test.go
78 lines (65 loc) · 1.96 KB
/
struct_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package sploit
import (
"bytes"
"testing"
)
func TestPackUint64LE(t *testing.T) {
if bytes.Compare(PackUint64LE(0xf00bdeadbeeff00b), []byte{0x0b, 0xf0, 0xef, 0xbe, 0xad, 0xde, 0x0b, 0xf0}) != 0 {
t.Fatal("Return bytes != expected")
}
}
func TestPackUint32LE(t *testing.T) {
if bytes.Compare(PackUint32LE(0xf00bdead), []byte{0xad, 0xde, 0x0b, 0xf0}) != 0 {
t.Fatal("Return bytes != expected")
}
}
func TestPackUint16LE(t *testing.T) {
if bytes.Compare(PackUint16LE(0xf00b), []byte{0x0b, 0xf0}) != 0 {
t.Fatal("Return bytes != expected")
}
}
func TestPackUint64BE(t *testing.T) {
if bytes.Compare(PackUint64BE(0xf00bdeadbeeff00b), []byte{0xf0, 0x0b, 0xde, 0xad, 0xbe, 0xef, 0xf0, 0x0b}) != 0 {
t.Fatal("Return bytes != expected")
}
}
func TestPackUint32BE(t *testing.T) {
if bytes.Compare(PackUint32BE(0xf00bdead), []byte{0xf0, 0x0b, 0xde, 0xad}) != 0 {
t.Fatal("Return bytes != expected")
}
}
func TestPackUint16BE(t *testing.T) {
if bytes.Compare(PackUint16BE(0xf00b), []byte{0xf0, 0x0b}) != 0 {
t.Fatal("Return bytes != expected")
}
}
func TestUnpackUint64LE(t *testing.T) {
if UnpackUint64LE([]byte{0x0b, 0xf0, 0xef, 0xbe, 0xad, 0xde, 0x0b, 0xf0}) != 0xf00bdeadbeeff00b {
t.Fatal("Return value != expected")
}
}
func TestUnpackUint32LE(t *testing.T) {
if UnpackUint32LE([]byte{0x0b, 0xf0, 0xef, 0xbe}) != 0xbeeff00b {
t.Fatal("Return value != expected")
}
}
func TestUnpackUint16LE(t *testing.T) {
if UnpackUint16LE([]byte{0x0b, 0xf0}) != 0xf00b {
t.Fatal("Return value != expected")
}
}
func TestUnpackUint64BE(t *testing.T) {
if UnpackUint64BE([]byte{0xf0, 0x0b, 0xde, 0xad, 0xbe, 0xef, 0xf0, 0x0b}) != 0xf00bdeadbeeff00b {
t.Fatal("Return value != expected")
}
}
func TestUnpackUint32BE(t *testing.T) {
if UnpackUint32BE([]byte{0xf0, 0x0b, 0xde, 0xad}) != 0xf00bdead {
t.Fatal("Return value != expected")
}
}
func TestUnpackUint16BE(t *testing.T) {
if UnpackUint16BE([]byte{0xf0, 0x0b}) != 0xf00b {
t.Fatal("Return value != expected")
}
}