-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvol_header_test.go
47 lines (44 loc) · 983 Bytes
/
vol_header_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
package bakemono
import (
"reflect"
"testing"
)
func TestVolHeaderFooterMarshal(t *testing.T) {
v := VolHeaderFooter{
Magic: 0x12345678,
CreateUnixTime: 0x1ab27df24eaf0924,
WritePos: 0xdf241ab27e924af0,
SyncSerial: 0xab2df2eaf0924417,
//WriteSerial: 0x78934ab01256cdef,
}
b, err := v.MarshalBinary()
if err != nil {
t.Fatal(err)
}
t.Log(string(b))
}
func TestVolHeaderFooterUnmarshal(t *testing.T) {
v := VolHeaderFooter{
Magic: 0x12345678,
CreateUnixTime: 0x1ab27df24eaf0924,
WritePos: 0xdf241ab27e924af0,
SyncSerial: 0xab2df2eaf0924417,
//WriteSerial: 0x78934ab01256cdef,
}
b, err := v.MarshalBinary()
if err != nil {
t.Fatal(err)
}
t.Log(string(b))
var v2 VolHeaderFooter
err = v2.UnmarshalBinary(b)
if err != nil {
t.Fatal(err)
}
t.Log(v2)
// check if v2 is equal using reflect.DeepEqual
if !reflect.DeepEqual(v, v2) {
t.Fatal("v2 is not equal to v")
}
t.Log("v2 is equal to v")
}