blob: da93533dda81615a9334bc83d7621dc2d7f3a4a2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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)
}
|