@@ -0,0 +1,149 @@
6+ "github.com/stretchr/testify/require"
9+func TestPasteStringToPaths(t *testing.T) {
10+ t.Run("Windows", func(t *testing.T) {
18+ input: `"C:\path\my-screenshot-one.png"`,
19+ expected: []string{`C:\path\my-screenshot-one.png`},
22+ name: "multiple paths no spaces",
23+ input: `"C:\path\my-screenshot-one.png" "C:\path\my-screenshot-two.png" "C:\path\my-screenshot-three.png"`,
24+ expected: []string{`C:\path\my-screenshot-one.png`, `C:\path\my-screenshot-two.png`, `C:\path\my-screenshot-three.png`},
27+ name: "sigle with spaces",
28+ input: `"C:\path\my screenshot one.png"`,
29+ expected: []string{`C:\path\my screenshot one.png`},
32+ name: "multiple paths with spaces",
33+ input: `"C:\path\my screenshot one.png" "C:\path\my screenshot two.png" "C:\path\my screenshot three.png"`,
34+ expected: []string{`C:\path\my screenshot one.png`, `C:\path\my screenshot two.png`, `C:\path\my screenshot three.png`},
37+ name: "empty string",
42+ name: "unclosed quotes",
43+ input: `"C:\path\file.png`,
47+ name: "text outside quotes",
48+ input: `"C:\path\file.png" some random text "C:\path\file2.png"`,
49+ expected: []string{`C:\path\file.png`, `C:\path\file2.png`},
52+ name: "multiple spaces between paths",
53+ input: `"C:\path\file1.png" "C:\path\file2.png"`,
54+ expected: []string{`C:\path\file1.png`, `C:\path\file2.png`},
57+ name: "just whitespace",
62+ name: "consecutive quoted sections",
63+ input: `"C:\path1""C:\path2"`,
64+ expected: []string{`C:\path1`, `C:\path2`},
67+ for _, tt := range tests {
68+ t.Run(tt.name, func(t *testing.T) {
69+ result := windowsPasteStringToPaths(tt.input)
70+ require.Equal(t, tt.expected, result)
75+ t.Run("Unix", func(t *testing.T) {
83+ input: `/path/my-screenshot.png`,
84+ expected: []string{"/path/my-screenshot.png"},
87+ name: "multiple paths no spaces",
88+ input: `/path/screenshot-one.png /path/screenshot-two.png /path/screenshot-three.png`,
89+ expected: []string{"/path/screenshot-one.png", "/path/screenshot-two.png", "/path/screenshot-three.png"},
92+ name: "sigle with spaces",
93+ input: `/path/my\ screenshot\ one.png`,
94+ expected: []string{"/path/my screenshot one.png"},
97+ name: "multiple paths with spaces",
98+ input: `/path/my\ screenshot\ one.png /path/my\ screenshot\ two.png /path/my\ screenshot\ three.png`,
99+ expected: []string{"/path/my screenshot one.png", "/path/my screenshot two.png", "/path/my screenshot three.png"},
102+ name: "empty string",
107+ name: "double backslash escapes",
108+ input: `/path/my\\file.png`,
109+ expected: []string{"/path/my\\file.png"},
112+ name: "trailing backslash",
113+ input: `/path/file\`,
114+ expected: []string{`/path/file\`},
117+ name: "multiple consecutive escaped spaces",
118+ input: `/path/file\ \ with\ \ many\ \ spaces.png`,
119+ expected: []string{"/path/file with many spaces.png"},
122+ name: "multiple unescaped spaces",
123+ input: `/path/file1.png /path/file2.png`,
124+ expected: []string{"/path/file1.png", "/path/file2.png"},
127+ name: "just whitespace",
132+ name: "tab characters",
133+ input: "/path/file1.png\t/path/file2.png",
134+ expected: []string{"/path/file1.png\t/path/file2.png"},
137+ name: "newlines in input",
138+ input: "/path/file1.png\n/path/file2.png",
139+ expected: []string{"/path/file1.png\n/path/file2.png"},
142+ for _, tt := range tests {
143+ t.Run(tt.name, func(t *testing.T) {
144+ result := unixPasteStringToPaths(tt.input)
145+ require.Equal(t, tt.expected, result)