45 lines
857 B
Go
45 lines
857 B
Go
package q05
|
|
|
|
import (
|
|
"strconv"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/hhhapz/codequest/models"
|
|
"github.com/hhhapz/codequest/question"
|
|
)
|
|
|
|
func TestQ05(t *testing.T) {
|
|
u := &models.User{
|
|
ID: "123",
|
|
}
|
|
|
|
q := question.QuestionByID("fuel")
|
|
|
|
raw := q.Generate(u)
|
|
|
|
t.Logf("INPUT:\n\n%s\n\n", raw)
|
|
|
|
input := make([]int, 0, nums)
|
|
|
|
for _, num := range strings.Split(raw, "\n") {
|
|
n, _ := strconv.Atoi(num)
|
|
input = append(input, n)
|
|
}
|
|
|
|
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")
|
|
}
|
|
}
|