package solver

import (
	"testing"

	"gitea.ligthert.net/golang/sudoku-funpark/controller"
	"gitea.ligthert.net/golang/sudoku-funpark/outputter"
)

// Test the splitWorkload function.
func TestSplitWorkload(t *testing.T) {
	// Create a new Solver struct.
	solver := Solver{}

	// Create outputter struct.
	outp := outputter.Outputter{}

	// Set the output type to human.
	outp.OutputType = "human"

	// Set the outputter of the solver to the outputter.
	solver.Outp = &outp

	// Create a controller struct.
	controller := controller.Controller{}

	// Set the controller of the solver to the controller.
	solver.Controller = &controller

	// Execute the loadBlocks function.
	solver.LoadBlocks()

	// Provide controller.row1 with a value.
	// This is the row that will be used in the findBlocks function.
	controller.Row1 = "769104802"

	// Call the findBlocks function with the row and the slice of rows.
	solver.findBlocks(&controller.Row1, &solver.row1s)

	// Divide the work between two agents.
	solver.Controller.Split = 2

	// Call the splitWorkload function.
	agents := solver.splitWorkload()

	// Check if the agents slice is as expected.
	if agents[0] != 1 || agents[1] != 1 {
		t.Errorf("Expected [1, 1], got %v", agents)
	}

}
