diff options
author | Kishin Yagami <k.yagami.suou@gmail.com> | 2016-08-09 03:25:00 +0900 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-08-08 20:25:00 +0200 |
commit | 39df7724ad958cfaee631ea1cdc3c29343b63763 (patch) | |
tree | 393a08066420daa579c314fa6e7cbe38b5d7dbc0 /source/filesystem_test.go | |
parent | b33bfd40bed7af36faba18bed09efb6b95c58192 (diff) |
source: Normalize file name to NFC
Fixes #2203
Diffstat (limited to 'source/filesystem_test.go')
-rw-r--r-- | source/filesystem_test.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/source/filesystem_test.go b/source/filesystem_test.go index 9a6b9fa88..d2101991b 100644 --- a/source/filesystem_test.go +++ b/source/filesystem_test.go @@ -16,6 +16,8 @@ package source import ( "bytes" "path/filepath" + "runtime" + "strings" "testing" ) @@ -82,3 +84,28 @@ func TestAddFile(t *testing.T) { } } } + +func TestUnicodeNorm(t *testing.T) { + if runtime.GOOS != "darwin" { + // Normalization code is only for Mac OS, since it is not necessary for other OSes. + return + } + + paths := []struct { + NFC string + NFD string + }{ + {NFC: "å", NFD: "\x61\xcc\x8a"}, + {NFC: "é", NFD: "\x65\xcc\x81"}, + } + + for _, path := range paths { + src := new(Filesystem) + _ = src.add(path.NFD, strings.NewReader("")) + f := src.Files()[0] + if f.BaseFileName() != path.NFC { + t.Fatalf("file name in NFD form should be normalized (%s)", path.NFC) + } + } + +} |