You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ambiguous_gen_test.go 1005B

1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2022 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package charset
  5. import (
  6. "sort"
  7. "testing"
  8. "unicode"
  9. "github.com/stretchr/testify/assert"
  10. )
  11. func TestAmbiguousCharacters(t *testing.T) {
  12. for locale, ambiguous := range AmbiguousCharacters {
  13. assert.Equal(t, locale, ambiguous.Locale)
  14. assert.Equal(t, len(ambiguous.Confusable), len(ambiguous.With))
  15. assert.True(t, sort.SliceIsSorted(ambiguous.Confusable, func(i, j int) bool {
  16. return ambiguous.Confusable[i] < ambiguous.Confusable[j]
  17. }))
  18. for _, confusable := range ambiguous.Confusable {
  19. assert.True(t, unicode.Is(ambiguous.RangeTable, confusable))
  20. i := sort.Search(len(ambiguous.Confusable), func(j int) bool {
  21. return ambiguous.Confusable[j] >= confusable
  22. })
  23. found := i < len(ambiguous.Confusable) && ambiguous.Confusable[i] == confusable
  24. assert.True(t, found, "%c is not in %d", confusable, i)
  25. }
  26. }
  27. }