33 lines
661 B
Go
33 lines
661 B
Go
|
package parser
|
||
|
|
||
|
import "io"
|
||
|
import "fmt"
|
||
|
import "testing"
|
||
|
import "strings"
|
||
|
|
||
|
func testString (test *testing.T, correct, input string) {
|
||
|
testReader(test, correct, strings.NewReader(input))
|
||
|
}
|
||
|
|
||
|
func testReader (test *testing.T, correct string, inputs ...io.Reader) {
|
||
|
tree := Tree { }
|
||
|
for index, stream := range inputs {
|
||
|
err := tree.Parse(fmt.Sprintf("stream%d.fspl", index), stream)
|
||
|
if err != nil {
|
||
|
test.Error("parser returned error: ", err)
|
||
|
return
|
||
|
}
|
||
|
}
|
||
|
|
||
|
got := tree.String()
|
||
|
if got != correct {
|
||
|
test.Log("strings do not match")
|
||
|
test.Log("tree.String():")
|
||
|
test.Log(got)
|
||
|
test.Log("correct:")
|
||
|
test.Log(correct)
|
||
|
test.Fail()
|
||
|
return
|
||
|
}
|
||
|
}
|