41 lines
1.2 KiB
Go
41 lines
1.2 KiB
Go
package solver
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gitea.ligthert.net/golang/sudoku-funpark/controller"
|
|
"gitea.ligthert.net/golang/sudoku-funpark/outputter"
|
|
)
|
|
|
|
// This function will test the loadBlocks function.
|
|
// Starts off by creating a new Solver struct.
|
|
// Then it will execute the loadBlocks function.
|
|
// Check if there are 9! blocks loaded.
|
|
// Check if the first block is "123456789".
|
|
// check if the last block is "987654321".
|
|
func TestLoadBlocks(t *testing.T) {
|
|
|
|
// Do all the necesarry steps to initialize the solver.
|
|
solver := Solver{}
|
|
outp := outputter.Outputter{}
|
|
outp.OutputType = "short"
|
|
solver.Outp = &outp
|
|
controller := controller.Controller{}
|
|
solver.Controller = &controller
|
|
solver.LoadBlocks()
|
|
|
|
// Check if there are 9! blocks loaded.
|
|
if len(solver.Controller.Blocks) != 362880 {
|
|
t.Error("Expected 362880, got", len(solver.Controller.Blocks))
|
|
}
|
|
// Check if the first block is "123456789".
|
|
if solver.Controller.Blocks[0] != "123456789" {
|
|
t.Error("Expected 123456789, got", solver.Controller.Blocks[0])
|
|
}
|
|
// Check if the last block is "987654321".
|
|
if solver.Controller.Blocks[362879] != "987654321" {
|
|
t.Error("Expected 987654321, got", solver.Controller.Blocks[362879])
|
|
}
|
|
|
|
}
|