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 36 37 38 39 40 41 42
|
package kallsyms
import (
"bytes"
"testing"
"github.com/go-quicktest/qt"
)
func TestReader(t *testing.T) {
b := []byte(`
one two three
four
λέξη `)
r := newReader(bytes.NewReader(b))
qt.Assert(t, qt.IsTrue(r.Line()))
qt.Assert(t, qt.IsTrue(r.Word()))
qt.Assert(t, qt.Equals(r.Text(), "one"))
qt.Assert(t, qt.IsTrue(r.Word()))
qt.Assert(t, qt.Equals(r.Text(), "two"))
qt.Assert(t, qt.IsTrue(r.Word()))
qt.Assert(t, qt.Equals(r.Text(), "three"))
qt.Assert(t, qt.IsFalse(r.Word()))
qt.Assert(t, qt.IsTrue(r.Line()))
qt.Assert(t, qt.IsTrue(r.Word()))
qt.Assert(t, qt.Equals(r.Text(), "four"))
qt.Assert(t, qt.IsFalse(r.Word()))
qt.Assert(t, qt.IsTrue(r.Line()))
qt.Assert(t, qt.IsTrue(r.Word()))
qt.Assert(t, qt.Equals(r.Text(), "λέξη"))
qt.Assert(t, qt.IsFalse(r.Word()))
qt.Assert(t, qt.IsFalse(r.Line()))
qt.Assert(t, qt.IsNil(r.Err()))
}
|