diff --git a/Generators/randomised_kruskal_test.go b/Generators/randomised_kruskal_test.go new file mode 100644 index 0000000..46faab7 --- /dev/null +++ b/Generators/randomised_kruskal_test.go @@ -0,0 +1,19 @@ +package Generators + +import ( + "github.com/msmp-core/maze-generator-cli/utils" + "strconv" + "testing" +) + +func TestWallsRandomisedKruskal(t *testing.T) { + maze, err := GenerateNewMaze(5, 5, NewRandomisedKruskal) + if err != nil { + t.Error(err.Error()) + return + } + if len(maze.Walls) != 45 { + t.Error(utils.FormatTestError("bad length of total walls", strconv.Itoa(45), + strconv.Itoa(len(maze.Walls)))) + } +} diff --git a/utils/test.go b/utils/test.go new file mode 100644 index 0000000..1d526a9 --- /dev/null +++ b/utils/test.go @@ -0,0 +1,13 @@ +package utils + +import "fmt" + +// FormatTestError format for you your test error messages. +// +// excepted is the value excepted. +// got is the value got. +// +// Return the formatted string +func FormatTestError(msg string, excepted string, got string) string { + return fmt.Sprintf("%s\nexcepted: %s\ngot %s\n", msg, excepted, got) +}