1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-06-20 14:15:23 +00:00

removed globals, added nolint to tests that used globals (#843)

This commit is contained in:
gravestench 2020-10-26 04:06:00 +00:00 committed by GitHub
parent 359bcd6ef8
commit 060abdc3bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 15 deletions

View File

@ -13,6 +13,7 @@ import (
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2records"
)
// nolint:gochecknoglobals // just a test
var itemStatCosts = map[string]*d2records.ItemStatCostRecord{
"strength": {
Name: "strength",
@ -275,6 +276,7 @@ var itemStatCosts = map[string]*d2records.ItemStatCostRecord{
},
}
// nolint:gochecknoglobals // just a test
var charStats = map[d2enum.Hero]*d2records.CharStatsRecord{
d2enum.HeroPaladin: {
Class: d2enum.HeroPaladin,
@ -288,15 +290,18 @@ var charStats = map[d2enum.Hero]*d2records.CharStatsRecord{
},
}
// nolint:gochecknoglobals // just a test
var skillDetails = map[int]*d2records.SkillRecord{
37: {Skill: "Warmth"},
64: {Skill: "Frozen Orb"},
}
// nolint:gochecknoglobals // just a test
var monStats = map[string]*d2records.MonStatsRecord{
"Specter": {NameString: "Specter", ID: 40},
}
// nolint:gochecknoglobals // just a test
var properties = map[string]*d2records.PropertyRecord{
"allstats": {
Code: "allstats",
@ -407,8 +412,10 @@ var properties = map[string]*d2records.PropertyRecord{
},
}
// nolint:gochecknoglobals // just a test
var testAssetManager *d2asset.AssetManager
// nolint:gochecknoglobals // just a test
var testItemFactory *ItemFactory
func TestSetup(t *testing.T) {

View File

@ -7,21 +7,14 @@ import (
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2math/d2vector"
)
var stepEntity mapEntity
const (
normalTickTime float64 = 0.05
)
func TestMain(m *testing.M) {
setup()
os.Exit(m.Run())
}
func setup() {
setupBenchmarkMapEntityStep()
}
func entity() mapEntity {
return newMapEntity(10, 10)
}
@ -79,11 +72,9 @@ func TestMapEntity_Step(t *testing.T) {
}
}
func setupBenchmarkMapEntityStep() {
stepEntity = movingEntity()
}
func BenchmarkMapEntity_Step(b *testing.B) {
stepEntity := movingEntity()
for n := 0; n < b.N; n++ {
stepEntity.Step(normalTickTime)
}

View File

@ -4,11 +4,9 @@ import (
"fmt"
"testing"
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2asset"
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2records"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2asset"
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2records"
)
const (
@ -16,6 +14,7 @@ const (
errFmt string = "%v:\n\tDescFnID: %v\n\tKey: %v\n\tVal: %+v\n\texpected: %v\n\tgot: %v\n\n"
)
// nolint:gochecknoglobals // just a test
var itemStatCosts = map[string]*d2records.ItemStatCostRecord{
"strength": {
Name: "strength",
@ -232,15 +231,18 @@ var itemStatCosts = map[string]*d2records.ItemStatCostRecord{
},
}
// nolint:gochecknoglobals // just a test
var skillDetails = map[int]*d2records.SkillRecord{
37: {Skill: "Warmth"},
64: {Skill: "Frozen Orb"},
}
// nolint:gochecknoglobals // just a test
var monStats = map[string]*d2records.MonStatsRecord{
"Specter": {NameString: "Specter", ID: 40},
}
// nolint:gochecknoglobals // just a test
var charStats = map[d2enum.Hero]*d2records.CharStatsRecord{
d2enum.HeroPaladin: {
Class: d2enum.HeroPaladin,
@ -253,8 +255,11 @@ var charStats = map[d2enum.Hero]*d2records.CharStatsRecord{
},
},
}
// nolint:gochecknoglobals // just a test
var testAssetManager2 *d2asset.AssetManager
// nolint:gochecknoglobals // just a test
var testStatFactory2 *StatFactory
func TestSetup_Stat(t *testing.T) {

View File

@ -9,8 +9,10 @@ import (
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2stats"
)
// nolint:gochecknoglobals // just a test
var testAssetManager *d2asset.AssetManager
// nolint:gochecknoglobals // just a test
var testStatFactory *StatFactory
func TestSetup_StatList(t *testing.T) {