forked from daeuniverse/softwind
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common_test.go
42 lines (39 loc) · 893 Bytes
/
common_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
package common
import (
"bytes"
"testing"
)
func TestBytesAddBigEndian(t *testing.T) {
tt := [][2][]byte{
{{0, 0, 0}, {0, 0, 1}},
{{0, 0, 255}, {0, 1, 0}},
{{0, 255, 255}, {1, 0, 0}},
{{255, 255, 255}, {0, 0, 0}},
{{55, 255, 255}, {56, 0, 0}},
{{56, 23, 255}, {56, 24, 0}},
{{56, 24, 22}, {56, 24, 23}},
}
for i, test := range tt {
BytesIncBigEndian(test[0])
if !bytes.Equal(test[0], test[1]) {
t.Fatal(i, test[0], "!=", test[1])
}
}
}
func TestBytesAddLittleEndian(t *testing.T) {
tt := [][2][]byte{
{{0, 0, 0}, {1, 0, 0}},
{{255, 0, 0}, {0, 1, 0}},
{{255, 255, 0}, {0, 0, 1}},
{{255, 255, 255}, {0, 0, 0}},
{{255, 255, 55}, {0, 0, 56}},
{{255, 23, 56}, {0, 24, 56}},
{{22, 24, 56}, {23, 24, 56}},
}
for i, test := range tt {
BytesIncLittleEndian(test[0])
if !bytes.Equal(test[0], test[1]) {
t.Fatal(i, test[0], "!=", test[1])
}
}
}