2014-01-01 08:49:38 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2014-01-11 08:27:08 -06:00
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
2014-01-01 08:49:38 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
type TestSource struct {
|
2014-01-11 08:27:08 -06:00
|
|
|
Inputs map[string]string
|
|
|
|
Expectation string
|
2014-01-01 08:49:38 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewTestSource(source string) *TestSource {
|
2014-01-11 08:27:08 -06:00
|
|
|
s := &TestSource{}
|
|
|
|
err := json.Unmarshal([]byte(source), s)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
2014-01-01 08:49:38 -06:00
|
|
|
|
2014-01-11 08:27:08 -06:00
|
|
|
return s
|
2014-01-01 08:49:38 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
type TestRunner struct {
|
2014-01-11 08:27:08 -06:00
|
|
|
source *TestSource
|
2014-01-01 08:49:38 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewTestRunner(t *testing.T) *TestRunner {
|
2014-01-11 08:27:08 -06:00
|
|
|
return &TestRunner{}
|
2014-01-01 08:49:38 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func (runner *TestRunner) RunFromString(input string, Cb func(*TestSource)) {
|
2014-01-11 08:27:08 -06:00
|
|
|
source := NewTestSource(input)
|
|
|
|
Cb(source)
|
2014-01-01 08:49:38 -06:00
|
|
|
}
|