MCPcopy
hub / github.com/wavetermdev/waveterm / TestQuote

Function TestQuote

pkg/util/shellutil/shellquote_test.go:7–110  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

5import "testing"
6
7func 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",

Callers

nothing calls this directly

Calls 3

HardQuoteFunction · 0.85
SoftQuoteFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected