renderFlat_test.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package export
  2. import (
  3. "testing"
  4. "gitea.ligthert.net/golang/sudoku-funpark/controller"
  5. "gitea.ligthert.net/golang/sudoku-funpark/outputter"
  6. )
  7. // This function will test the renderFlat function.
  8. // Then it will execute the renderFlat function.
  9. // Check if the output is a string.
  10. func TestRenderFlat(t *testing.T) {
  11. // Create a new Export struct.
  12. export := Export{}
  13. // Create a new Controller struct.
  14. // Set output type to "human".
  15. outp := outputter.Outputter{}
  16. outp.OutputType = "short"
  17. controller := controller.Controller{Outputter: &outp}
  18. export.Controller = &controller
  19. controller.Solutions = append(controller.Solutions, []string{"123456789", "987654321", "123456789", "987654321", "123456789", "987654321", "123456789", "987654321", "123456789"})
  20. // Execute the renderFlat function.
  21. render := export.renderFlat()
  22. // Check if the output is a string and not empty.
  23. if render == "" {
  24. t.Error("Expected a non-empty string, got", render)
  25. }
  26. // Check if the output is a string.
  27. if render != "\nSolution #1:\n[123456789 987654321 123456789 987654321 123456789 987654321 123456789 987654321 123456789]\n" {
  28. t.Error("Expected a string, got", render)
  29. }
  30. }