-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwriter_test.go
81 lines (74 loc) · 1.75 KB
/
writer_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
79
80
81
package polar
import (
"bytes"
"embed"
"fmt"
"testing"
)
//go:embed test_data/*
var testData embed.FS
func TestWriteSimple(t *testing.T) {
// PolarChunk chunk1, chunk2;
// {
// var sections = new PolarSection[5];
// Arrays.fill(sections, new PolarSection());
// chunk1 = new PolarChunk(
// 0, 0,
// sections,
// List.of(),
// null,
// new byte[0]
// );
// }
// {
// var sections = new PolarSection[5];
// Arrays.fill(sections, new PolarSection());
// chunk2 = new PolarChunk(
// -1, -1,
// sections,
// List.of(),
// null,
// new byte[0]
// );
// }
world := &World{
Version: LatestVersion,
Compression: CompressionNone,
MinSection: 0,
MaxSection: 4,
chunks: map[ChunkIndex]*Chunk{
ChunkIndexFromXZ(0, 0): {
X: 0,
Z: 0,
Sections: []*Section{},
BlockEntities: []*BlockEntity{{
ChunkPos: ChunkPosFromXYZ(3, 4, 5),
ID: "minecraft:chest",
Data: map[string]interface{}{
"x": int32(3),
},
}},
},
ChunkIndexFromXZ(-1, -1): {
X: -1,
Z: -1,
Sections: []*Section{},
BlockEntities: nil,
},
},
}
data, err := Write(world)
if err != nil {
t.Fatal(err)
}
javaData, err := testData.ReadFile("test_data/simple_java.polar")
if err != nil {
t.Fatal(err)
}
// print hex of data and javadata
fmt.Printf("%x\n", data)
fmt.Printf("%x\n", javaData)
if !bytes.Equal(data, javaData) {
t.Fatal("data mismatch")
}
}