textlinescanner_test.go 403 B

123456789101112131415161718192021222324
  1. package iox
  2. import (
  3. "strings"
  4. "testing"
  5. "github.com/stretchr/testify/assert"
  6. )
  7. func TestScanner(t *testing.T) {
  8. const val = `1
  9. 2
  10. 3
  11. 4`
  12. reader := strings.NewReader(val)
  13. scanner := NewTextLineScanner(reader)
  14. var lines []string
  15. for scanner.Scan() {
  16. line, err := scanner.Line()
  17. assert.Nil(t, err)
  18. lines = append(lines, line)
  19. }
  20. assert.EqualValues(t, []string{"1", "2", "3", "4"}, lines)
  21. }