added new maze (15x15) for testing purposes
This commit is contained in:
@ -78,6 +78,30 @@ func TestImageReader(t *testing.T) {
|
||||
{0b_00000100, 0b000_00000},
|
||||
},
|
||||
},
|
||||
{
|
||||
"Normal2",
|
||||
15, 15,
|
||||
20, 20,
|
||||
white, black,
|
||||
"../../assets/normal2.png",
|
||||
[][]byte{
|
||||
{0b00000001, 0b0000000_0},
|
||||
{0b01110111, 0b1111010_0},
|
||||
{0b00010100, 0b0001010_0},
|
||||
{0b01110111, 0b1101110_0},
|
||||
{0b01000000, 0b0000010_0},
|
||||
{0b01111101, 0b1111010_0},
|
||||
{0b00010101, 0b0000010_0},
|
||||
{0b01110111, 0b0111010_0},
|
||||
{0b01000100, 0b0101010_0},
|
||||
{0b01011101, 0b1101110_0},
|
||||
{0b01000101, 0b0000000_0},
|
||||
{0b01110101, 0b0111110_0},
|
||||
{0b01010001, 0b0001010_0},
|
||||
{0b01011111, 0b1111010_0},
|
||||
{0b00000001, 0b0000000_0},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
75
io/writer/image_test.go
Normal file
75
io/writer/image_test.go
Normal 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)
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user