mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-06-27 01:25:35 +00:00
removed globals, added nolint to tests that used globals (#843)
This commit is contained in:
parent
359bcd6ef8
commit
060abdc3bd
|
@ -13,6 +13,7 @@ import (
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2records"
|
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2records"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// nolint:gochecknoglobals // just a test
|
||||||
var itemStatCosts = map[string]*d2records.ItemStatCostRecord{
|
var itemStatCosts = map[string]*d2records.ItemStatCostRecord{
|
||||||
"strength": {
|
"strength": {
|
||||||
Name: "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{
|
var charStats = map[d2enum.Hero]*d2records.CharStatsRecord{
|
||||||
d2enum.HeroPaladin: {
|
d2enum.HeroPaladin: {
|
||||||
Class: 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{
|
var skillDetails = map[int]*d2records.SkillRecord{
|
||||||
37: {Skill: "Warmth"},
|
37: {Skill: "Warmth"},
|
||||||
64: {Skill: "Frozen Orb"},
|
64: {Skill: "Frozen Orb"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// nolint:gochecknoglobals // just a test
|
||||||
var monStats = map[string]*d2records.MonStatsRecord{
|
var monStats = map[string]*d2records.MonStatsRecord{
|
||||||
"Specter": {NameString: "Specter", ID: 40},
|
"Specter": {NameString: "Specter", ID: 40},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// nolint:gochecknoglobals // just a test
|
||||||
var properties = map[string]*d2records.PropertyRecord{
|
var properties = map[string]*d2records.PropertyRecord{
|
||||||
"allstats": {
|
"allstats": {
|
||||||
Code: "allstats",
|
Code: "allstats",
|
||||||
|
@ -407,8 +412,10 @@ var properties = map[string]*d2records.PropertyRecord{
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// nolint:gochecknoglobals // just a test
|
||||||
var testAssetManager *d2asset.AssetManager
|
var testAssetManager *d2asset.AssetManager
|
||||||
|
|
||||||
|
// nolint:gochecknoglobals // just a test
|
||||||
var testItemFactory *ItemFactory
|
var testItemFactory *ItemFactory
|
||||||
|
|
||||||
func TestSetup(t *testing.T) {
|
func TestSetup(t *testing.T) {
|
||||||
|
|
|
@ -7,21 +7,14 @@ import (
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2math/d2vector"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2math/d2vector"
|
||||||
)
|
)
|
||||||
|
|
||||||
var stepEntity mapEntity
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
normalTickTime float64 = 0.05
|
normalTickTime float64 = 0.05
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
setup()
|
|
||||||
os.Exit(m.Run())
|
os.Exit(m.Run())
|
||||||
}
|
}
|
||||||
|
|
||||||
func setup() {
|
|
||||||
setupBenchmarkMapEntityStep()
|
|
||||||
}
|
|
||||||
|
|
||||||
func entity() mapEntity {
|
func entity() mapEntity {
|
||||||
return newMapEntity(10, 10)
|
return newMapEntity(10, 10)
|
||||||
}
|
}
|
||||||
|
@ -79,11 +72,9 @@ func TestMapEntity_Step(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupBenchmarkMapEntityStep() {
|
|
||||||
stepEntity = movingEntity()
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkMapEntity_Step(b *testing.B) {
|
func BenchmarkMapEntity_Step(b *testing.B) {
|
||||||
|
stepEntity := movingEntity()
|
||||||
|
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
stepEntity.Step(normalTickTime)
|
stepEntity.Step(normalTickTime)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,9 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2asset"
|
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2records"
|
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2asset"
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2records"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
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"
|
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{
|
var itemStatCosts = map[string]*d2records.ItemStatCostRecord{
|
||||||
"strength": {
|
"strength": {
|
||||||
Name: "strength",
|
Name: "strength",
|
||||||
|
@ -232,15 +231,18 @@ var itemStatCosts = map[string]*d2records.ItemStatCostRecord{
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// nolint:gochecknoglobals // just a test
|
||||||
var skillDetails = map[int]*d2records.SkillRecord{
|
var skillDetails = map[int]*d2records.SkillRecord{
|
||||||
37: {Skill: "Warmth"},
|
37: {Skill: "Warmth"},
|
||||||
64: {Skill: "Frozen Orb"},
|
64: {Skill: "Frozen Orb"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// nolint:gochecknoglobals // just a test
|
||||||
var monStats = map[string]*d2records.MonStatsRecord{
|
var monStats = map[string]*d2records.MonStatsRecord{
|
||||||
"Specter": {NameString: "Specter", ID: 40},
|
"Specter": {NameString: "Specter", ID: 40},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// nolint:gochecknoglobals // just a test
|
||||||
var charStats = map[d2enum.Hero]*d2records.CharStatsRecord{
|
var charStats = map[d2enum.Hero]*d2records.CharStatsRecord{
|
||||||
d2enum.HeroPaladin: {
|
d2enum.HeroPaladin: {
|
||||||
Class: 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
|
var testAssetManager2 *d2asset.AssetManager
|
||||||
|
|
||||||
|
// nolint:gochecknoglobals // just a test
|
||||||
var testStatFactory2 *StatFactory
|
var testStatFactory2 *StatFactory
|
||||||
|
|
||||||
func TestSetup_Stat(t *testing.T) {
|
func TestSetup_Stat(t *testing.T) {
|
||||||
|
|
|
@ -9,8 +9,10 @@ import (
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2stats"
|
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2stats"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// nolint:gochecknoglobals // just a test
|
||||||
var testAssetManager *d2asset.AssetManager
|
var testAssetManager *d2asset.AssetManager
|
||||||
|
|
||||||
|
// nolint:gochecknoglobals // just a test
|
||||||
var testStatFactory *StatFactory
|
var testStatFactory *StatFactory
|
||||||
|
|
||||||
func TestSetup_StatList(t *testing.T) {
|
func TestSetup_StatList(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user