26 lines
722 B
Go
26 lines
722 B
Go
package parsekit
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestSetResult_AcceptsVariousTypesAsInput(t *testing.T) {
|
|
i := mkInput()
|
|
i.Result().SetRunes("string")
|
|
AssertEqual(t, "string", string(i.Result().String()), "i.Result() with string input")
|
|
i.Result().SetRunes([]rune("rune slice"))
|
|
AssertEqual(t, "rune slice", string(i.Result().String()), "i.Result() with rune slice input")
|
|
i.Result().SetRunes('X')
|
|
AssertEqual(t, "X", string(i.Result().String()), "i.Result() with rune input")
|
|
}
|
|
|
|
func TestSetResult_PanicsOnUnhandledInput(t *testing.T) {
|
|
AssertPanic(t, PanicT{
|
|
Function: func() {
|
|
i := mkInput()
|
|
i.Result().SetRunes(1234567)
|
|
},
|
|
Expect: "parsekit.TokenResult.SetRunes(): unsupported type 'int' used",
|
|
})
|
|
}
|