Re-enabled text_test.go

This commit is contained in:
Karma Riuk 2023-08-07 18:09:58 +02:00
parent 19f83899be
commit 36051b06f6

View File

@ -1,108 +1,105 @@
package reader package reader
import ( import (
// "maze-solver/maze" "maze-solver/utils"
// "maze-solver/utils" "reflect"
// "reflect"
"testing" "testing"
) )
func TestTextReadTrivial(t *testing.T) { func TestTextReadTrivial(t *testing.T) {
/* tests := []struct {
tests := []struct { name string
name string filename string
filename string pathChar byte
pathChar byte wallChar byte
wallChar byte expected *RawMaze
expected *maze.RawMaze }{
}{ {
{ "Trivial",
"Trivial", "../../assets/trivial.txt",
"../../assets/trivial.txt", ' ',
' ', '#',
'#', &RawMaze{
&maze.RawMaze{ Width: 5,
PathChar: ' ', Height: 3,
WallChar: '#', Data: [][]byte{
Data: []string{ {0b_00100_000},
"## ##", {0b_01110_000},
"# #", {0b_00010_000},
"### #",
},
}, },
}, },
{ },
"Trivial Bigger", {
"../../assets/trivial-bigger.txt", "Trivial Bigger",
' ', "../../assets/trivial-bigger.txt",
'#', ' ',
&maze.RawMaze{ '#',
PathChar: ' ', &RawMaze{
WallChar: '#', Width: 7,
Data: []string{ 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", "Bigger Staggered",
' ', "../../assets/trivial-bigger-staggered.txt",
'#', ' ',
&maze.RawMaze{ '#',
PathChar: ' ', &RawMaze{
WallChar: '#', Width: 7,
Data: []string{ Height: 5,
"### ###", Data: [][]byte{
"### ###", {0b_0001000_0},
"# #", {0b_0001000_0},
"#### ##", {0b_0111110_0},
"#### ##", {0b_0000100_0},
}, {0b_0000100_0},
}, },
}, },
{ },
"Normal", {
"../../assets/normal.txt", "Normal",
' ', "../../assets/normal.txt",
'#', ' ',
&maze.RawMaze{ '#',
PathChar: ' ', &RawMaze{
WallChar: '#', Width: 11,
Data: []string{ 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 { got, err := reader.Read()
reader := TextReader{ utils.Check(err, "Couldn't read file %q", reader.Filename)
Filename: test.filename,
PathChar: test.pathChar,
WallChar: test.wallChar,
}
got, err := reader.Read() if !reflect.DeepEqual(got, test.expected) {
utils.Check(err, "Couldn't read file %q", reader.Filename) 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)
}
} }
*/ }
} }