aboutsummaryrefslogtreecommitdiff
path: root/internal/nametransform/nfc_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/nametransform/nfc_test.go')
-rw-r--r--internal/nametransform/nfc_test.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/internal/nametransform/nfc_test.go b/internal/nametransform/nfc_test.go
new file mode 100644
index 0000000..aad1d7d
--- /dev/null
+++ b/internal/nametransform/nfc_test.go
@@ -0,0 +1,29 @@
+package nametransform
+
+import (
+ "strconv"
+ "testing"
+
+ "golang.org/x/text/unicode/norm"
+)
+
+func TestNFD2NFC(t *testing.T) {
+ n := newLognamesTestInstance(NameMax)
+ n.nfd2nfc = true
+ iv := make([]byte, DirIVLen)
+ srcNFC := "Österreich Café"
+ srcNFD := norm.NFD.String(srcNFC)
+
+ // cipherName should get normalized to NFC
+ cipherName, _ := n.EncryptName(srcNFD, iv)
+ // Decrypt without changing normalization
+ decryptedRaw, _ := n.decryptName(cipherName, iv)
+ if srcNFC != decryptedRaw {
+ t.Errorf("want %s have %s", strconv.QuoteToASCII(srcNFC), strconv.QuoteToASCII(decryptedRaw))
+ }
+ // Decrypt with normalizing to NFD
+ decrypted, _ := n.DecryptName(cipherName, iv)
+ if srcNFD != decrypted {
+ t.Errorf("want %s have %s", strconv.QuoteToASCII(srcNFD), strconv.QuoteToASCII(decrypted))
+ }
+}