Work in progress external test runner

This commit is contained in:
obscuren
2014-01-01 15:49:38 +01:00
parent 61d67f2ae9
commit 5b3d4fae6e
3 changed files with 75 additions and 3 deletions

35
test_runner.go Normal file
View File

@ -0,0 +1,35 @@
package main
import (
"fmt"
"testing"
"encoding/json"
)
type TestSource struct {
Inputs map[string]string
Expectation string
}
func NewTestSource(source string) *TestSource {
s := &TestSource{}
err := json.Unmarshal([]byte(source), s)
if err != nil {
fmt.Println(err)
}
return s
}
type TestRunner struct {
source *TestSource
}
func NewTestRunner(t *testing.T) *TestRunner {
return &TestRunner{}
}
func (runner *TestRunner) RunFromString(input string, Cb func(*TestSource)) {
source := NewTestSource(input)
Cb(source)
}