跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

rooted_fold_test.go

48 行 · 1.5 KB历史下载
1//go:build linux || darwin || windows
2
3package reversesshfs
4
5import (
6 "testing"
7)
8
9func TestFoldNameIgnorables(t *testing.T) {
10 // Spellings that a casefold ext4, f2fs or tmpfs, or HFS+, takes as ".git".
11 for _, r := range []rune{
12 0x200b, 0x200c, 0x200d, 0x200e, 0x200f, 0x202a, 0x202e, 0x2060, 0x2061, 0x2064, 0x206a, 0x206f, 0xfeff,
13 0xad, 0x34f, 0x61c, 0x115f, 0x1160, 0x17b4, 0x17b5, 0x180b, 0x180e, 0x180f, 0x3164, 0xfe00, 0xfe0f, 0xffa0,
14 0xfff0, 0xe0001, 0xe0020, 0xe0100, 0xe01ef,
15 } {
16 s := string(r)
17 for _, name := range []string{".g" + s + "it", ".gi" + s + "t", ".git" + s, s + ".git", ".GIT" + s} {
18 if !sameName(name, ".git") {
19 t.Errorf("%+q should match .git", name)
20 }
21 }
22 }
23 // Dotless i is "i" in NTFS's upcase table; long s folds to s.
24 if !sameName(".gıt", ".git") || !sameName("ſrc", "src") {
25 t.Error("dotless i or long s")
26 }
27 for _, name := range []string{".gt", ".gitt", ".gi.t", ".ǵit", ".g it"} {
28 if sameName(name, ".git") {
29 t.Errorf("%+q should not match .git", name)
30 }
31 }
32}
33
34func FuzzFoldIgnorables(f *testing.F) {
35 for _, s := range []string{".git", ".g​it", "Aㅤb", "é", "é"} {
36 f.Add(s, uint8(1))
37 }
38 f.Fuzz(func(t *testing.T, s string, at uint8) {
39 // An ignorable code point anywhere changes nothing.
40 i := int(at) % (len(s) + 1)
41 for i > 0 && i < len(s) && s[i]&0xc0 == 0x80 {
42 i--
43 }
44 if got, want := FoldName(s[:i]+"​️ㅤ"+s[i:]), FoldName(s); got != want {
45 t.Errorf("FoldName(%q with ignorables at %d) = %q, want %q", s, i, got, want)
46 }
47 })
48}