added new maze (15x15) for testing purposes

This commit is contained in:
Karma Riuk
2023-08-10 19:08:16 +02:00
parent d1d3ed1c73
commit 3ef61967a5
5 changed files with 311 additions and 2 deletions

75
io/writer/image_test.go Normal file
View File

@ -0,0 +1,75 @@
package writer
import (
"image/color"
"maze-solver/maze"
"testing"
"github.com/mazznoer/colorgrad"
)
func TestImageWriter(t *testing.T) {
pathGradient, err := colorgrad.NewGradient().Colors(color.White).Build()
if err != nil {
panic(err)
}
tests := []struct {
name string
filename string
m *maze.SolvedMaze
CellWidth, cellHeight int
pathColor, wallColor color.Color
gradient colorgrad.Gradient
}{
{
"Trivial",
"../../out/trivial_sol.png",
trivial(),
40, 40,
color.White, color.Black,
colorgrad.Warm(),
},
{
"Bigger",
"../../out/bigger_sol.png",
bigger(),
40, 40,
color.White, color.Black,
colorgrad.Warm(),
},
{
"Bigger Staggered",
"../../out/bigger_staggered_sol.png",
bigger_staggered(),
40, 40,
color.White, color.Black,
pathGradient,
},
{
"Normal",
"../../out/normal_sol.png",
normal(),
40, 40,
color.White, color.Black,
colorgrad.Warm(),
},
}
for _, test := range tests {
writer := ImageWriter{
Filename: test.filename,
Maze: test.m,
CellWidth: test.CellWidth,
CellHeight: test.cellHeight,
WallColor: test.wallColor,
PathColor: test.pathColor,
SolutionGradient: test.gradient,
}
err := writer.Write()
if err != nil {
t.Fatalf("%s: couldn't write solution, got following error\n%v", test.name, err)
}
}
}