-
Notifications
You must be signed in to change notification settings - Fork 2
/
nbt_test.go
72 lines (64 loc) · 1.91 KB
/
nbt_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
package nbt
import (
"bytes"
"io/ioutil"
"testing"
)
/*
TAG_Compound('Level'): 11 entries
TAG_Compound('nested compound test'): 2 entries
TAG_Compound('egg'): 2 entries
TAG_String('name'): 'Eggbert'
TAG_Float('value'): 0.5
TAG_Compound('ham'): 2 entries
TAG_String('name'): 'Hampus'
TAG_Float('value'): 0.75
TAG_Int('intTest'): 2147483647
TAG_Byte('byteTest'): 127
TAG_String('stringTest'): 'HELLO WORLD THIS IS A TEST STRING \xc3\x85\xc3\x84\xc3\x96!'
TAG_List('listTest (long)'): 5 entires
TAG_Long(None): 11
TAG_Long(None): 12
TAG_Long(None): 13
TAG_Long(None): 14
TAG_Long(None): 15
TAG_Double('doubleTest'): 0.49312871321823148
TAG_Float('floatTest'): 0.49823147058486938
TAG_Long('longTest'): 9223372036854775807L
TAG_List('listTest (compound)'): 2 entires
TAG_Compound(None): 2 entries
TAG_Long('created-on'): 1264099775885L
TAG_String('name'): 'Compound tag #0'
TAG_Compound(None): 2 entries
TAG_Long('created-on'): 1264099775885L
TAG_String('name'): 'Compound tag #1'
TAG_Byte_Array('byteArrayTest (the first 1000 values of (n*n*255+n*7)%100, starting with n=0 (0, 62, 34, 16, 8, ...))'): [1000 bytes]
TAG_Short('shortTest'): 32767
*/
func TestDecodeGzip(t *testing.T) {
file, err := ioutil.ReadFile("bigtest.nbt")
if err != nil {
t.Fatal("Couldn't open bigtest.nbt:", err)
}
data, err := DecodeGzip(bytes.NewReader(file))
if err != nil {
t.Fatal(err)
}
name := data.Name()
if name != "Level" {
t.Errorf("in (*Compound).Name(): expected 'Level', got %s", name)
t.FailNow()
}
ham := data.Compound("nested compound test").Compound("ham").String("name")
if ham != "Hampus" {
t.Errorf("in /nested compound test/ham/name: expected 'Hampus', got %s", ham)
t.FailNow()
}
list := data.List("listTest (long)")
longs := list.Longs()
if n := longs[3]; n != 14 {
t.Errorf("in /listTest (long)[3]: expected 14, got %d", n)
t.FailNow()
}
data.PrettyPrint()
}