func TestConsume(t *testing.T) { s := "package นี้" l := new(compiler.Lexer).Init(s) if l.GetInput() != "package นี้" { t.Fatalf("l.input failed") } str := utf8.NewString(s) for i := 0; i < str.RuneCount(); i++ { if l.GetOffset() != i+1 { t.Fatalf("l.readOffset failed != " + strconv.Itoa(i+1)) } if l.GetCh() != str.At(i) { t.Fatalf("ch " + strconv.Itoa(l.GetCh()) + " != at " + strconv.Itoa(str.At(i))) } l.Consume() } if l.GetCh() != compiler.EOF { t.Fatalf("EOF not found") } }