44 lines
860 B
Go
44 lines
860 B
Go
package q04
|
|
|
|
import (
|
|
"strconv"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/hhhapz/codequest/models"
|
|
"github.com/hhhapz/codequest/question"
|
|
)
|
|
|
|
func TestQ04(t *testing.T) {
|
|
u := &models.User{
|
|
ID: "123",
|
|
}
|
|
|
|
q := question.QuestionByID("island")
|
|
|
|
raw := q.Generate(u)
|
|
|
|
t.Logf("INPUT:\n\n%s\n\n", raw)
|
|
|
|
input := make([][]rune, 0, rows)
|
|
|
|
for _, row := range strings.Split(raw, "\n") {
|
|
input = append(input, []rune(row))
|
|
}
|
|
|
|
// res := solveP1(input)
|
|
// t.Logf("part 1 result: %d", res)
|
|
// if !q.Validate(u, question.Part1, strconv.Itoa(res)) {
|
|
// t.Errorf("Expected question 1 part 1(%v) to be correct!", res)
|
|
// }
|
|
|
|
res := solveP2(input)
|
|
if !q.Validate(u, question.Part2, strconv.Itoa(res)) {
|
|
t.Errorf("Expected question 2 part 2(%v) to be correct!", res)
|
|
}
|
|
|
|
if q.Validate(u, question.Part1, "") {
|
|
t.Errorf("Expected bad input to be invalid")
|
|
}
|
|
}
|