Debian Codegraph @

internal/tables/assigned/assigned_test.go

raw
1 package assigned
2
3 import (
4 "reflect"
5 "testing"
6 "unicode"
7 )
8
9 func TestAssigned(t *testing.T) {
10 if Assigned(unicode.Version) == nil {
11 t.Fatal("missing assigned Unicode points for version:", unicode.Version)
12 }
13 }
14
15 func TestAssignedRunes(t *testing.T) {
16 want := func(version string) []rune {
17 var a []rune
18 visit(Assigned(version), func(r rune) {
19 a = append(a, r)
20 })
21 if len(a) == 0 {
22 t.Fatal("invalid Unicode version:", version)
23 }
24 return a
25 }
26 for _, version := range []string{
27 "13.0.0",
28 unicode.Version, // 15.0.0 unless testing with go1.19
29 } {
30 version := version
31 t.Run(version, func(t *testing.T) {
32 t.Parallel()
33 w := want(version)
34 a1 := AssignedRunes(version)
35 if !reflect.DeepEqual(a1, w) {
36 t.Error("AssignedRunes: invalid result") // don't print the massive slices
37 }
38 a2 := AssignedRunes(version)
39 if &a1[0] != &a2[0] {
40 t.Fatalf("AssignedRunes: result was not cached: %p == %p",
41 &a1[0], &a2[0])
42 }
43 })
44 }
45 }