fix(generator): drop incorrect distinctness assert in TestPlanetRandomName #19
@@ -18,14 +18,21 @@ func TestPlanetRandomName(t *testing.T) {
|
|||||||
for _, pc := range []g.PlanetClass{g.PlanetClassHW, g.PlanetClassDW, g.PlanetClassGiant, g.PlanetClassBig, g.PlanetClassNormal, g.PlanetClassRich, g.PlanetClassAsterioid} {
|
for _, pc := range []g.PlanetClass{g.PlanetClassHW, g.PlanetClassDW, g.PlanetClassGiant, g.PlanetClassBig, g.PlanetClassNormal, g.PlanetClassRich, g.PlanetClassAsterioid} {
|
||||||
t.Run(string(pc), func(t *testing.T) {
|
t.Run(string(pc), func(t *testing.T) {
|
||||||
name := g.NewPlanet(pc, g.Coordinate{0, 0}, 0, 0).RandomName()
|
name := g.NewPlanet(pc, g.Coordinate{0, 0}, 0, 0).RandomName()
|
||||||
g := re.FindStringSubmatch(name)
|
// `RandomName` formats `<class>-<4-digit>-<4-digit>`,
|
||||||
assert.NotNilf(t, g, "cannot parse: %q", name)
|
// where each suffix is an independent `rand.Intn(1000)`.
|
||||||
if g == nil {
|
// We assert the wire format and the class prefix; an
|
||||||
|
// earlier revision also asserted `g[2] != g[3]`, which
|
||||||
|
// flaked on the legitimate ~0.1% collision (a property
|
||||||
|
// the function does not — and need not — guarantee:
|
||||||
|
// `generate_game.go` already tolerates duplicate names
|
||||||
|
// across planets).
|
||||||
|
groups := re.FindStringSubmatch(name)
|
||||||
|
assert.NotNilf(t, groups, "cannot parse: %q", name)
|
||||||
|
if groups == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
assert.Equalf(t, 4, len(g), "regexp groups")
|
assert.Equalf(t, 4, len(groups), "regexp groups")
|
||||||
assert.Equal(t, string(pc), g[1])
|
assert.Equal(t, string(pc), groups[1])
|
||||||
assert.NotEqual(t, g[2], g[3])
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user