-
Notifications
You must be signed in to change notification settings - Fork 0
/
hbxml_test.go
63 lines (55 loc) · 1.78 KB
/
hbxml_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
package hbxml
import (
"fmt"
"os"
"strings"
"testing"
)
func TestBeatmapDecoding(t *testing.T) {
exampleFiles, err := os.ReadDir("examples")
if err != nil {
t.Error(err)
}
for _, file := range exampleFiles {
if !strings.HasSuffix(file.Name(), ".hbxml") {
continue
}
_, err = ParseFromFile(fmt.Sprintf("examples/%s", file.Name()))
if err != nil {
t.Error(err)
return
}
}
}
func TestCombo(t *testing.T) {
comboMap := map[string]int{
"LeaF - NANO DEATH!!!!! (NerdNerdTewt) [Death].hbxml": 87,
"Drop - Granat (TheHowl) [Pro].hbxml": 214,
"RhythmHolic - GLP Dubstep Intro (ProPlayer08) [Pro].hbxml": 163,
"RhythmHolic - GLP Dubstep Intro (ProPlayer08) [EZ].hbxml": 132,
"NJK Record - Dirty Sexy Girl (Nicholas) [BASIC].hbxml": 702,
"NJK Record - Dirty Sexy Girl (Nicholas) [NO HOLDS].hbxml": 548,
"Hige Driver join. SELEN - Dadadadadadadadadada (Nicholas) [EXPERT].hbxml": 470,
"Kuroma - Feelings beloved overheat (Takuya) [Expert].hbxml": 1378,
"shisotex - Final Fantasy III Sailing Enterprise ~ The Invincible (Takuya) [Pro].hbxml": 1198,
}
for file, combo := range comboMap {
b, err := ParseFromFile("examples/" + file)
if err != nil {
t.Error(err)
return
}
caclulatedCombo := b.ComputeMaxCombo()
difference := caclulatedCombo - combo
if difference != 0 {
t.Errorf(
"Expected %d, got %d (%d): %s\n",
combo, caclulatedCombo, difference, b.FormatName(),
)
}
}
}
func contains(s string, substr string) bool {
before, after, found := strings.Cut(s, substr)
return found && before != after
}