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 933B

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