Re-enabled text_test.go

This commit is contained in:
Karma Riuk 2023-08-07 18:09:58 +02:00
parent b6dff509f9
commit 3d4a2b9bfb

View File

@ -1,108 +1,105 @@
package reader
import (
// "maze-solver/maze"
// "maze-solver/utils"
// "reflect"
"maze-solver/utils"
"reflect"
"testing"
)
func TestTextReadTrivial(t *testing.T) {
/*
tests := []struct {
name string
filename string
pathChar byte
wallChar byte
expected *maze.RawMaze
}{
{
"Trivial",
"../../assets/trivial.txt",
' ',
'#',
&maze.RawMaze{
PathChar: ' ',
WallChar: '#',
Data: []string{
"## ##",
"# #",
"### #",
},
tests := []struct {
name string
filename string
pathChar byte
wallChar byte
expected *RawMaze
}{
{
"Trivial",
"../../assets/trivial.txt",
' ',
'#',
&RawMaze{
Width: 5,
Height: 3,
Data: [][]byte{
{0b_00100_000},
{0b_01110_000},
{0b_00010_000},
},
},
{
"Trivial Bigger",
"../../assets/trivial-bigger.txt",
' ',
'#',
&maze.RawMaze{
PathChar: ' ',
WallChar: '#',
Data: []string{
"### ###",
"### ###",
"# #",
"##### #",
"##### #",
},
},
{
"Trivial Bigger",
"../../assets/trivial-bigger.txt",
' ',
'#',
&RawMaze{
Width: 7,
Height: 5,
Data: [][]byte{
{0b_0001000_0},
{0b_0001000_0},
{0b_0111110_0},
{0b_0000010_0},
{0b_0000010_0},
},
},
{
"Bigger Staggered",
"../../assets/trivial-bigger-staggered.txt",
' ',
'#',
&maze.RawMaze{
PathChar: ' ',
WallChar: '#',
Data: []string{
"### ###",
"### ###",
"# #",
"#### ##",
"#### ##",
},
},
{
"Bigger Staggered",
"../../assets/trivial-bigger-staggered.txt",
' ',
'#',
&RawMaze{
Width: 7,
Height: 5,
Data: [][]byte{
{0b_0001000_0},
{0b_0001000_0},
{0b_0111110_0},
{0b_0000100_0},
{0b_0000100_0},
},
},
{
"Normal",
"../../assets/normal.txt",
' ',
'#',
&maze.RawMaze{
PathChar: ' ',
WallChar: '#',
Data: []string{
"##### #####",
"# # #",
"##### ### #",
"# # #",
"# # ##### #",
"# # #",
"### ### # #",
"# # # #",
"# ####### #",
"# # #",
"##### #####",
},
},
{
"Normal",
"../../assets/normal.txt",
' ',
'#',
&RawMaze{
Width: 11,
Height: 11,
Data: [][]byte{
{0b_00000100, 0b000_00000},
{0b_01111101, 0b110_00000},
{0b_00000100, 0b010_00000},
{0b_01110111, 0b110_00000},
{0b_01010000, 0b010_00000},
{0b_01011111, 0b110_00000},
{0b_00010001, 0b010_00000},
{0b_01110111, 0b010_00000},
{0b_01000000, 0b010_00000},
{0b_01111101, 0b110_00000},
{0b_00000100, 0b000_00000},
},
},
},
}
for _, test := range tests {
reader := TextReader{
Filename: test.filename,
PathChar: test.pathChar,
WallChar: test.wallChar,
}
for _, test := range tests {
reader := TextReader{
Filename: test.filename,
PathChar: test.pathChar,
WallChar: test.wallChar,
}
got, err := reader.Read()
utils.Check(err, "Couldn't read file %q", reader.Filename)
got, err := reader.Read()
utils.Check(err, "Couldn't read file %q", reader.Filename)
if !reflect.DeepEqual(got, test.expected) {
t.Fatalf("%s: lexed mazes do not match\nGot: %v\nWant: %v", test.name, got, test.expected)
}
if !reflect.DeepEqual(got, test.expected) {
t.Fatalf("%s: lexed mazes do not match\nGot: %v\nWant: %v", test.name, got, test.expected)
}
*/
}
}