| Sketch🕴️ | d04f362 | 2026-02-28 19:09:06 +0400 | [diff] [blame] | 1 | package token |
| 2 | |||||
| 3 | import "testing" | ||||
| 4 | |||||
| 5 | func TestTypeString(t *testing.T) { | ||||
| 6 | tests := []struct { | ||||
| 7 | typ Type | ||||
| 8 | want string | ||||
| 9 | }{ | ||||
| 10 | {Number, "Number"}, | ||||
| 11 | {Plus, "+"}, | ||||
| 12 | {Minus, "-"}, | ||||
| 13 | {Star, "*"}, | ||||
| 14 | {Slash, "/"}, | ||||
| 15 | {LParen, "("}, | ||||
| 16 | {RParen, ")"}, | ||||
| 17 | {EOF, "EOF"}, | ||||
| 18 | {Type(99), "Unknown(99)"}, | ||||
| 19 | } | ||||
| 20 | for _, tc := range tests { | ||||
| 21 | if got := tc.typ.String(); got != tc.want { | ||||
| 22 | t.Errorf("Type(%d).String() = %q, want %q", int(tc.typ), got, tc.want) | ||||
| 23 | } | ||||
| 24 | } | ||||
| 25 | } | ||||