Skip to content

Commit

Permalink
test(randomised kruskal): length of walls
Browse files Browse the repository at this point in the history
  • Loading branch information
anhgelus committed May 31, 2023
1 parent 4c19d36 commit b92ab29
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Generators/randomised_kruskal_test.go
Original file line number Diff line number Diff line change
@@ -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))))
}
}
13 changes: 13 additions & 0 deletions utils/test.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit b92ab29

Please sign in to comment.