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