go-ethereum/test_runner.go

36 lines
547 B
Go
Raw Permalink Normal View History

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