-
Notifications
You must be signed in to change notification settings - Fork 0
/
rgssadv3_test.go
60 lines (48 loc) · 1.84 KB
/
rgssadv3_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
package rpgo
import (
"errors"
"os"
"testing"
)
func TestRGSSADv3_VXAce(t *testing.T) {
var goat *RGSSADv3
testArchive := "./test-rsrc/Game.rgss3a"
if _, err := os.Stat(testArchive); errors.Is(err, os.ErrNotExist) {
t.Error("test/RGSSADv3_VXAce: test config fail, archive doesn't exist")
t.FailNow()
}
goat, err := NewRGSSADv3(testArchive)
if err != nil {
t.Errorf("test/RGSSADv3_VXAce: err not nil:\n%s", err.Error())
t.FailNow()
}
if len(goat.ArchivedFiles) != 16 {
t.Errorf("test/RGSSADv3_VXAce: archived files length not expected; wanted 16, got %d", len(goat.ArchivedFiles))
t.Fail()
}
expectedNames := []string{"Data\\Actors.rvdata2", "Data\\Animations.rvdata2", "Data\\Armors.rvdata2"}
expectedOffsets := []int64{605, 3637, 222096}
expectedSizes := []int{3032, 218459, 11472}
expectedKeys := []uint{0x00000029, 0x00004823, 0x000018BE}
for idx := range expectedNames {
if goat.ArchivedFiles[idx].Name != expectedNames[idx] {
t.Errorf("test/RGSSADv3_VXAce: archived files name not expected for index %d; wanted %s, got %s", idx, expectedNames[idx], goat.ArchivedFiles[idx].Name)
t.Fail()
}
if goat.ArchivedFiles[idx].Offset != expectedOffsets[idx] {
t.Errorf("test/RGSSADv3_VXAce: archived files offset not expected for index %d; wanted %d, got %d", idx, expectedOffsets[idx], goat.ArchivedFiles[idx].Offset)
t.Fail()
}
if goat.ArchivedFiles[idx].Size != expectedSizes[idx] {
t.Errorf("test/RGSSADv3_VXAce: archived files size not expected for index %d; wanted %d, got %d", idx, expectedSizes[idx], goat.ArchivedFiles[idx].Size)
t.Fail()
}
if goat.ArchivedFiles[idx].Key != expectedKeys[idx] {
t.Errorf("test/RGSSADv3_VXAce: archived files key not expected for index %d; wanted %X, got %X", idx, expectedKeys[idx], goat.ArchivedFiles[idx].Key)
t.Fail()
}
if t.Failed() {
t.FailNow()
}
}
}