Switch test case expected types to strings
This commit is contained in:
parent
624ca0b6e1
commit
87a29072ef
2 changed files with 14 additions and 16 deletions
|
@ -14,8 +14,8 @@ type Info struct {
|
|||
}
|
||||
|
||||
type TestCase struct {
|
||||
Input string `json:"input"`
|
||||
Expected interface{} `json:"expected"`
|
||||
Input string `json:"input"`
|
||||
Expected string `json:"expected"`
|
||||
}
|
||||
|
||||
func LoadChallengeInfo(fname string) (*Info, error) {
|
||||
|
|
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/codemicro/adventOfCode/runtime/challenge"
|
||||
"github.com/codemicro/adventOfCode/runtime/runners"
|
||||
au "github.com/logrusorgru/aurora"
|
||||
|
@ -10,8 +11,8 @@ import (
|
|||
type taskLookupTable map[string]func(*runners.Result)
|
||||
|
||||
var (
|
||||
passLabel = au.BrightGreen("pass").String()
|
||||
failLabel = au.BrightRed("fail").String()
|
||||
passLabel = au.BrightGreen("pass").String()
|
||||
failLabel = au.BrightRed("fail").String()
|
||||
incompleteLabel = au.BgBrightRed("did not complete").String()
|
||||
)
|
||||
|
||||
|
@ -27,15 +28,13 @@ func setupTestTasks(info *challenge.Info, runner runners.Runner, table *taskLook
|
|||
id := fmt.Sprintf("test.%d.%d", part, i)
|
||||
runner.Queue(&runners.Task{
|
||||
TaskID: id,
|
||||
Part: part,
|
||||
Input: testCase.Input,
|
||||
Part: part,
|
||||
Input: testCase.Input,
|
||||
})
|
||||
|
||||
(*table)[id] = func(r *runners.Result) {
|
||||
|
||||
expected := fmt.Sprintf("%v", testCase.Expected)
|
||||
|
||||
passed := r.Output == expected
|
||||
passed := r.Output == testCase.Expected
|
||||
|
||||
fmt.Print(au.Bold(fmt.Sprintf("Test %s: ",
|
||||
au.BrightBlue(fmt.Sprintf("%d.%d", part, i)),
|
||||
|
@ -57,16 +56,15 @@ func setupTestTasks(info *challenge.Info, runner runners.Runner, table *taskLook
|
|||
}
|
||||
|
||||
fmt.Print(status)
|
||||
fmt.Println(au.Gray(10, " " + followUpText))
|
||||
fmt.Println(au.Gray(10, " "+followUpText))
|
||||
|
||||
if !passed && r.Ok {
|
||||
fmt.Printf(" └ Expected %s, got %s\n", au.BrightBlue(expected), au.BrightBlue(r.Output))
|
||||
fmt.Printf(" └ Expected %s, got %s\n", au.BrightBlue(testCase.Expected), au.BrightBlue(r.Output))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
st(runners.PartOne, info.TestCases.One, runner, table)
|
||||
st(runners.PartTwo, info.TestCases.Two, runner, table)
|
||||
}
|
||||
|
@ -81,8 +79,8 @@ func setupMainTasks(input string, runner runners.Runner, table *taskLookupTable)
|
|||
id := fmt.Sprintf("main.%d", part)
|
||||
runner.Queue(&runners.Task{
|
||||
TaskID: id,
|
||||
Part: part,
|
||||
Input: input,
|
||||
Part: part,
|
||||
Input: input,
|
||||
})
|
||||
|
||||
(*table)[id] = func(r *runners.Result) {
|
||||
|
@ -91,7 +89,7 @@ func setupMainTasks(input string, runner runners.Runner, table *taskLookupTable)
|
|||
|
||||
if !r.Ok {
|
||||
fmt.Print(incompleteLabel)
|
||||
fmt.Println(au.Gray(10, " saying \"" + r.Output + "\""))
|
||||
fmt.Println(au.Gray(10, " saying \""+r.Output+"\""))
|
||||
} else {
|
||||
fmt.Print(au.BrightBlue(r.Output))
|
||||
fmt.Println(au.Gray(10, fmt.Sprintf(" in %.4f seconds", r.Duration)))
|
||||
|
@ -100,4 +98,4 @@ func setupMainTasks(input string, runner runners.Runner, table *taskLookupTable)
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue