| 1 | package emoji |
| 2 | |
| 3 | import "testing" |
| 4 | |
| 5 | // LOOK3's list half: RGI sequences are icons, in their fully-qualified |
| 6 | // form; anything else is not. |
| 7 | func TestCanonical(t *testing.T) { |
| 8 | cases := map[string]string{ |
| 9 | "๐": "๐", |
| 10 | "โบ": "โบ๏ธ", |
| 11 | "โบ๏ธ": "โบ๏ธ", |
| 12 | "๐๐ฝ": "๐๐ฝ", |
| 13 | "๐ฎ๐ช": "๐ฎ๐ช", |
| 14 | "#๏ธโฃ": "#๏ธโฃ", |
| 15 | "๐จโ๐ฉโ๐งโ๐ฆ": "๐จโ๐ฉโ๐งโ๐ฆ", |
| 16 | "โค๏ธโ๐ฅ": "โค๏ธโ๐ฅ", |
| 17 | } |
| 18 | for in, want := range cases { |
| 19 | got, ok := Canonical(in) |
| 20 | if !ok || got != want { |
| 21 | t.Errorf("Canonical(%q) = %q, %v; want %q", in, got, ok, want) |
| 22 | } |
| 23 | } |
| 24 | for _, in := range []string{"", "a", "๐๐", "๐ฝ", "๎", "๐ ", |
| 25 | "rocket", "\U0001FAE9x"} { |
| 26 | if got, ok := Canonical(in); ok { |
| 27 | t.Errorf("Canonical(%q) = %q, accepted", in, got) |
| 28 | } |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | func TestTheListIsVersion16(t *testing.T) { |
| 33 | if Count() != 3781-9 && Count() < 3700 { |
| 34 | t.Fatalf("Count() = %d", Count()) |
| 35 | } |
| 36 | if len(Groups) != 9 { |
| 37 | t.Fatalf("groups %v", Groups) |
| 38 | } |
| 39 | if _, ok := Canonical("๐ซฉ"); !ok { // face with bags under eyes, 16.0 |
| 40 | t.Fatal("a 16.0 emoji is missing") |
| 41 | } |
| 42 | } |
| 43 | |