package generator_test

import (
	"regexp"
	"testing"

	g "galaxy/game/internal/generator"

	"github.com/stretchr/testify/assert"
)

func TestPlanetRandomName(t *testing.T) {
	re, err := regexp.Compile(`^([a-zA-Z]+)-(\d{4})-(\d{4})$`)
	assert.NoError(t, err)
	if err != nil {
		return
	}
	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) {
			name := g.NewPlanet(pc, g.Coordinate{0, 0}, 0, 0).RandomName()
			g := re.FindStringSubmatch(name)
			assert.NotNilf(t, g, "cannot parse: %q", name)
			if g == nil {
				return
			}
			assert.Equalf(t, 4, len(g), "regexp groups")
			assert.Equal(t, string(pc), g[1])
			assert.NotEqual(t, g[2], g[3])
		})
	}
}
