package solver import ( "testing" "gitea.ligthert.net/golang/sudoku-funpark/controller" "gitea.ligthert.net/golang/sudoku-funpark/outputter" ) // This function will test the validator function. // It will create all the structs, and set required values // Load the blocks, populate the blocks, and then run the validator func TestValidator(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() // Fill the slices of solver.rows with the following values: // [769154832 154832769 832769154 671945328 945328671 328671945 597416283 416283597 283597416] solver.row1s = []string{"769154832"} solver.row2s = []string{"154832769"} solver.row3s = []string{"832769154"} solver.row4s = []string{"671945328"} solver.row5s = []string{"945328671"} solver.row6s = []string{"328671945"} solver.row7s = []string{"597416283"} solver.row8s = []string{"416283597"} solver.row9s = []string{"283597416"} // Set the rows to validate rows1Index := 0 rows2Index := 0 rows3Index := 0 rows4Index := 0 rows5Index := 0 rows6Index := 0 rows7Index := 0 rows8Index := 0 rows9Index := 0 // Run the validator solver.validator(rows1Index, rows2Index, rows3Index, rows4Index, rows5Index, rows6Index, rows7Index, rows8Index, rows9Index) // Check the number of solutions if len(controller.Solutions) != 1 { t.Errorf("Expected 1 solution, got %d", len(controller.Solutions)) } }