2021-07-06 18:39:56 -07:00
|
|
|
|
// +build use_icu_normalization
|
|
|
|
|
|
2021-08-18 21:18:01 -04:00
|
|
|
|
package normalization
|
2021-07-06 18:39:56 -07:00
|
|
|
|
|
|
|
|
|
import (
|
2021-08-19 16:40:37 -04:00
|
|
|
|
"encoding/hex"
|
2021-07-06 18:39:56 -07:00
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
"testing"
|
2021-08-19 16:40:37 -04:00
|
|
|
|
"unicode/utf8"
|
2021-07-06 18:39:56 -07:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestNormalizationICU(t *testing.T) {
|
|
|
|
|
testNormalization(t, normalizeICU)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func BenchmarkNormalizeICU(b *testing.B) {
|
|
|
|
|
benchmarkNormalize(b, normalizeICU)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestBlock760150(t *testing.T) {
|
2021-08-19 16:40:37 -04:00
|
|
|
|
test, _ := hex.DecodeString("43efbfbd")
|
|
|
|
|
assert.True(t, utf8.Valid(test))
|
|
|
|
|
a := normalizeGo(test)
|
|
|
|
|
b := normalizeICU(test)
|
|
|
|
|
assert.Equal(t, a, b)
|
|
|
|
|
|
|
|
|
|
test2 := "Ꮖ-Ꮩ-Ꭺ-N--------Ꭺ-N-Ꮹ-Ꭼ-Ꮮ-Ꭺ-on-Instagram_-“Our-next-destination-is-East-and-Southeast-Asia--selfie--asia”"
|
|
|
|
|
a = normalizeGo([]byte(test2))
|
|
|
|
|
b = normalizeICU([]byte(test2))
|
2021-07-06 18:39:56 -07:00
|
|
|
|
assert.Equal(t, a, b)
|
|
|
|
|
}
|