| package token | |
| import "testing" | |
| func TestTypeString(t *testing.T) { | |
| tests := []struct { | |
| typ Type | |
| want string | |
| }{ | |
| {Number, "Number"}, | |
| {Plus, "+"}, | |
| {Minus, "-"}, | |
| {Star, "*"}, | |
| {Slash, "/"}, | |
| {LParen, "("}, | |
| {RParen, ")"}, | |
| {EOF, "EOF"}, | |
| {Type(99), "Unknown(99)"}, | |
| } | |
| for _, tc := range tests { | |
| if got := tc.typ.String(); got != tc.want { | |
| t.Errorf("Type(%d).String() = %q, want %q", int(tc.typ), got, tc.want) | |
| } | |
| } | |
| } |