| 5 | import "testing" |
| 6 | |
| 7 | func TestQuote(t *testing.T) { |
| 8 | tests := []struct { |
| 9 | name string |
| 10 | input string |
| 11 | wantHard string |
| 12 | wantSoft string |
| 13 | }{ |
| 14 | { |
| 15 | name: "simple strings", |
| 16 | input: "simple", |
| 17 | wantHard: "simple", |
| 18 | wantSoft: "simple", |
| 19 | }, |
| 20 | { |
| 21 | name: "safe path", |
| 22 | input: "path/to/file.txt", |
| 23 | wantHard: "path/to/file.txt", |
| 24 | wantSoft: "path/to/file.txt", |
| 25 | }, |
| 26 | { |
| 27 | name: "empty string", |
| 28 | input: "", |
| 29 | wantHard: `""`, |
| 30 | wantSoft: `""`, |
| 31 | }, |
| 32 | { |
| 33 | name: "tilde alone", |
| 34 | input: "~", |
| 35 | wantHard: `"~"`, |
| 36 | wantSoft: "~", |
| 37 | }, |
| 38 | { |
| 39 | name: "tilde with safe path", |
| 40 | input: "~/foo", |
| 41 | wantHard: `"~/foo"`, |
| 42 | wantSoft: "~/foo", |
| 43 | }, |
| 44 | { |
| 45 | name: "tilde with spaces", |
| 46 | input: "~/foo bar", |
| 47 | wantHard: `"~/foo bar"`, |
| 48 | wantSoft: `~"/foo bar"`, |
| 49 | }, |
| 50 | { |
| 51 | name: "tilde with variable", |
| 52 | input: "~/foo$bar", |
| 53 | wantHard: `"~/foo\$bar"`, |
| 54 | wantSoft: `~"/foo$bar"`, |
| 55 | }, |
| 56 | { |
| 57 | name: "invalid tilde path", |
| 58 | input: "~foo", |
| 59 | wantHard: `"~foo"`, |
| 60 | wantSoft: `"~foo"`, |
| 61 | }, |
| 62 | { |
| 63 | name: "variable at start", |
| 64 | input: "$HOME/.config", |