40 lines
1.2 KiB
Go
40 lines
1.2 KiB
Go
package export
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gitea.ligthert.net/golang/sudoku-funpark/controller"
|
|
"gitea.ligthert.net/golang/sudoku-funpark/outputter"
|
|
)
|
|
|
|
// This function will test the renderFlat function.
|
|
// Then it will execute the renderFlat function.
|
|
// Check if the output is a string.
|
|
func TestRenderFlat(t *testing.T) {
|
|
|
|
// Create a new Export struct.
|
|
export := Export{}
|
|
|
|
// Create a new Controller struct.
|
|
// Set output type to "human".
|
|
outp := outputter.Outputter{}
|
|
outp.OutputType = "short"
|
|
controller := controller.Controller{Outputter: &outp}
|
|
export.Controller = &controller
|
|
controller.Solutions = append(controller.Solutions, []string{"123456789", "987654321", "123456789", "987654321", "123456789", "987654321", "123456789", "987654321", "123456789"})
|
|
|
|
// Execute the renderFlat function.
|
|
render := export.renderFlat()
|
|
|
|
// Check if the output is a string and not empty.
|
|
if render == "" {
|
|
t.Error("Expected a non-empty string, got", render)
|
|
}
|
|
|
|
// Check if the output is a string.
|
|
if render != "\nSolution #1:\n[123456789 987654321 123456789 987654321 123456789 987654321 123456789 987654321 123456789]\n" {
|
|
t.Error("Expected a string, got", render)
|
|
}
|
|
|
|
}
|