scanner_test.go 642 B

12345678910111213141516171819202122232425262728
  1. package ftp
  2. import "testing"
  3. import "github.com/stretchr/testify/assert"
  4. func TestScanner(t *testing.T) {
  5. assert := assert.New(t)
  6. s := newScanner("foo bar x y")
  7. assert.Equal("foo", s.Next())
  8. assert.Equal(" bar x y", s.Remaining())
  9. assert.Equal("bar", s.Next())
  10. assert.Equal("x y", s.Remaining())
  11. assert.Equal("x", s.Next())
  12. assert.Equal(" y", s.Remaining())
  13. assert.Equal("y", s.Next())
  14. assert.Equal("", s.Next())
  15. assert.Equal("", s.Remaining())
  16. }
  17. func TestScannerEmpty(t *testing.T) {
  18. assert := assert.New(t)
  19. s := newScanner("")
  20. assert.Equal("", s.Next())
  21. assert.Equal("", s.Next())
  22. assert.Equal("", s.Remaining())
  23. }