mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-13 04:03:16 +02:00
Start work on porting unicode input kitten to Go
This commit is contained in:
35
tools/unicode_names/query_test.go
Normal file
35
tools/unicode_names/query_test.go
Normal file
@@ -0,0 +1,35 @@
|
||||
// License: GPLv3 Copyright: 2023, Kovid Goyal, <kovid at kovidgoyal.net>
|
||||
|
||||
package unicode_names
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"kitty/tools/utils"
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
var _ = fmt.Print
|
||||
|
||||
func TestUnicodeInputQueries(t *testing.T) {
|
||||
ts := func(query string, expected ...rune) {
|
||||
if expected == nil {
|
||||
expected = make([]rune, 0)
|
||||
}
|
||||
expected = utils.Sort(expected, func(a, b rune) bool { return a < b })
|
||||
actual := CodePointsForQuery(query)
|
||||
actual = utils.Sort(actual, func(a, b rune) bool { return a < b })
|
||||
diff := cmp.Diff(expected, actual)
|
||||
if diff != "" {
|
||||
t.Fatalf("Failed query: %#v\n%s", query, diff)
|
||||
}
|
||||
}
|
||||
ts("horiz ell", 0x2026, 0x22ef, 0x2b2c, 0x2b2d, 0xfe19)
|
||||
ts("horizontal ell", 0x2026, 0x22ef, 0x2b2c, 0x2b2d, 0xfe19)
|
||||
ts("kfjhgkjdsfhgkjds")
|
||||
if slices.Index(CodePointsForQuery("bee"), 0x1f41d) < 0 {
|
||||
t.Fatalf("The query bee did not match the codepoint: 0x1f41d")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user