1
0
Fork 0
mirror of https://github.com/Luzifer/ansible-role-version.git synced 2024-12-23 19:11:20 +00:00
ansible-role-version/vendor/gopkg.in/src-d/go-git.v4/internal/revision/scanner_test.go
Knut Ahlers 209b813c5b
Update dependencies
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2018-03-19 18:16:10 +01:00

194 lines
4.6 KiB
Go
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package revision
import (
"bytes"
"testing"
. "gopkg.in/check.v1"
)
func Test(t *testing.T) { TestingT(t) }
type ScannerSuite struct{}
var _ = Suite(&ScannerSuite{})
func (s *ScannerSuite) TestReadColon(c *C) {
scanner := newScanner(bytes.NewBufferString(":"))
tok, data, err := scanner.scan()
c.Assert(err, Equals, nil)
c.Assert(data, Equals, ":")
c.Assert(tok, Equals, colon)
}
func (s *ScannerSuite) TestReadTilde(c *C) {
scanner := newScanner(bytes.NewBufferString("~"))
tok, data, err := scanner.scan()
c.Assert(err, Equals, nil)
c.Assert(data, Equals, "~")
c.Assert(tok, Equals, tilde)
}
func (s *ScannerSuite) TestReadCaret(c *C) {
scanner := newScanner(bytes.NewBufferString("^"))
tok, data, err := scanner.scan()
c.Assert(err, Equals, nil)
c.Assert(data, Equals, "^")
c.Assert(tok, Equals, caret)
}
func (s *ScannerSuite) TestReadDot(c *C) {
scanner := newScanner(bytes.NewBufferString("."))
tok, data, err := scanner.scan()
c.Assert(err, Equals, nil)
c.Assert(data, Equals, ".")
c.Assert(tok, Equals, dot)
}
func (s *ScannerSuite) TestReadSlash(c *C) {
scanner := newScanner(bytes.NewBufferString("/"))
tok, data, err := scanner.scan()
c.Assert(err, Equals, nil)
c.Assert(data, Equals, "/")
c.Assert(tok, Equals, slash)
}
func (s *ScannerSuite) TestReadEOF(c *C) {
scanner := newScanner(bytes.NewBufferString(string(rune(0))))
tok, data, err := scanner.scan()
c.Assert(err, Equals, nil)
c.Assert(data, Equals, "")
c.Assert(tok, Equals, eof)
}
func (s *ScannerSuite) TestReadNumber(c *C) {
scanner := newScanner(bytes.NewBufferString("1234"))
tok, data, err := scanner.scan()
c.Assert(err, Equals, nil)
c.Assert(data, Equals, "1234")
c.Assert(tok, Equals, number)
}
func (s *ScannerSuite) TestReadSpace(c *C) {
scanner := newScanner(bytes.NewBufferString(" "))
tok, data, err := scanner.scan()
c.Assert(err, Equals, nil)
c.Assert(data, Equals, " ")
c.Assert(tok, Equals, space)
}
func (s *ScannerSuite) TestReadControl(c *C) {
scanner := newScanner(bytes.NewBufferString(""))
tok, data, err := scanner.scan()
c.Assert(err, Equals, nil)
c.Assert(data, Equals, "\x01")
c.Assert(tok, Equals, control)
}
func (s *ScannerSuite) TestReadOpenBrace(c *C) {
scanner := newScanner(bytes.NewBufferString("{"))
tok, data, err := scanner.scan()
c.Assert(err, Equals, nil)
c.Assert(data, Equals, "{")
c.Assert(tok, Equals, obrace)
}
func (s *ScannerSuite) TestReadCloseBrace(c *C) {
scanner := newScanner(bytes.NewBufferString("}"))
tok, data, err := scanner.scan()
c.Assert(err, Equals, nil)
c.Assert(data, Equals, "}")
c.Assert(tok, Equals, cbrace)
}
func (s *ScannerSuite) TestReadMinus(c *C) {
scanner := newScanner(bytes.NewBufferString("-"))
tok, data, err := scanner.scan()
c.Assert(err, Equals, nil)
c.Assert(data, Equals, "-")
c.Assert(tok, Equals, minus)
}
func (s *ScannerSuite) TestReadAt(c *C) {
scanner := newScanner(bytes.NewBufferString("@"))
tok, data, err := scanner.scan()
c.Assert(err, Equals, nil)
c.Assert(data, Equals, "@")
c.Assert(tok, Equals, at)
}
func (s *ScannerSuite) TestReadAntislash(c *C) {
scanner := newScanner(bytes.NewBufferString("\\"))
tok, data, err := scanner.scan()
c.Assert(err, Equals, nil)
c.Assert(data, Equals, "\\")
c.Assert(tok, Equals, aslash)
}
func (s *ScannerSuite) TestReadQuestionMark(c *C) {
scanner := newScanner(bytes.NewBufferString("?"))
tok, data, err := scanner.scan()
c.Assert(err, Equals, nil)
c.Assert(data, Equals, "?")
c.Assert(tok, Equals, qmark)
}
func (s *ScannerSuite) TestReadAsterisk(c *C) {
scanner := newScanner(bytes.NewBufferString("*"))
tok, data, err := scanner.scan()
c.Assert(err, Equals, nil)
c.Assert(data, Equals, "*")
c.Assert(tok, Equals, asterisk)
}
func (s *ScannerSuite) TestReadOpenBracket(c *C) {
scanner := newScanner(bytes.NewBufferString("["))
tok, data, err := scanner.scan()
c.Assert(err, Equals, nil)
c.Assert(data, Equals, "[")
c.Assert(tok, Equals, obracket)
}
func (s *ScannerSuite) TestReadExclamationMark(c *C) {
scanner := newScanner(bytes.NewBufferString("!"))
tok, data, err := scanner.scan()
c.Assert(err, Equals, nil)
c.Assert(data, Equals, "!")
c.Assert(tok, Equals, emark)
}
func (s *ScannerSuite) TestReadWord(c *C) {
scanner := newScanner(bytes.NewBufferString("abcde"))
tok, data, err := scanner.scan()
c.Assert(err, Equals, nil)
c.Assert(data, Equals, "abcde")
c.Assert(tok, Equals, word)
}
func (s *ScannerSuite) TestReadTokenError(c *C) {
scanner := newScanner(bytes.NewBufferString("`"))
tok, data, err := scanner.scan()
c.Assert(err, Equals, nil)
c.Assert(data, Equals, "`")
c.Assert(tok, Equals, tokenError)
}