File: reader_test.go

package info (click to toggle)
golang-github-cilium-ebpf 0.17.3%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 4,684 kB
  • sloc: ansic: 1,259; makefile: 127; python: 113; awk: 29; sh: 24
file content (42 lines) | stat: -rw-r--r-- 889 bytes parent folder | download
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()))
}