Debian Codegraph @

autoversion/textseg/version_specific_test.go

raw
1 package textseg
2
3 // Note that due to the nature of this package this will only test with the
4 // go-textseg version that matches with the current Go runtime.
5
6 import (
7 "testing"
8 )
9
10 func TestScanGraphemeClusters(t *testing.T) {
11 // Our goal here is only to test that we're really calling into an
12 // upstream ScanGraphemeClusters function and not, say, a different scanner
13 // function by mistake. It's not intended to be a deep test and should
14 // hopefully remain valid in future Unicode versions.
15 t.Logf("testing with implementation for Unicode major version %d", UnicodeMajorVersion)
16
17 const input = `whelp 🤦🏽‍♂️`
18 got, err := TokenCount([]byte(input), ScanGraphemeClusters)
19 want := 7
20 if err != nil {
21 t.Fatalf("unexpected error: %s", err)
22 }
23 if got != want {
24 t.Errorf("wrong number of tokens\ninput: %s\ngot: %d\nwant: %d", input, got, want)
25 }
26 }