23 lines
402 B
Go
23 lines
402 B
Go
package main
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestScan(t *testing.T) {
|
|
for _, test := range gTests {
|
|
s := newScanner(strings.NewReader(test.inp))
|
|
|
|
for _, tok := range test.toks {
|
|
if s.scan(); s.tok != tok {
|
|
t.Errorf("at input '%s' expected '%s' but scanned '%s'", test.inp, tok, s.tok)
|
|
}
|
|
}
|
|
|
|
if s.scan() {
|
|
t.Errorf("at input '%s' unexpected '%s'", test.inp, s.tok)
|
|
}
|
|
}
|
|
}
|