github.com/lingyao2333/mo-zero@v1.4.1/core/iox/textlinescanner_test.go (about)

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