47 lines
905 B
Go
47 lines
905 B
Go
|
|
package engine
|
||
|
|
|
||
|
|
import "testing"
|
||
|
|
|
||
|
|
func TestEscapePowerShell(t *testing.T) {
|
||
|
|
tests := []struct {
|
||
|
|
input string
|
||
|
|
want string
|
||
|
|
}{
|
||
|
|
{"hello", "hello"},
|
||
|
|
{"it's done", "it''s done"},
|
||
|
|
{"Tom's 'file'", "Tom''s ''file''"},
|
||
|
|
{"no quotes", "no quotes"},
|
||
|
|
{"", ""},
|
||
|
|
}
|
||
|
|
|
||
|
|
for _, tt := range tests {
|
||
|
|
t.Run(tt.input, func(t *testing.T) {
|
||
|
|
got := escapePowerShell(tt.input)
|
||
|
|
if got != tt.want {
|
||
|
|
t.Errorf("escapePowerShell(%q) = %q, want %q", tt.input, got, tt.want)
|
||
|
|
}
|
||
|
|
})
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func TestEscapeAppleScript(t *testing.T) {
|
||
|
|
tests := []struct {
|
||
|
|
input string
|
||
|
|
want string
|
||
|
|
}{
|
||
|
|
{"hello", "hello"},
|
||
|
|
{`say "hi"`, `say \"hi\"`},
|
||
|
|
{`back\slash`, `back\\slash`},
|
||
|
|
{"", ""},
|
||
|
|
}
|
||
|
|
|
||
|
|
for _, tt := range tests {
|
||
|
|
t.Run(tt.input, func(t *testing.T) {
|
||
|
|
got := escapeAppleScript(tt.input)
|
||
|
|
if got != tt.want {
|
||
|
|
t.Errorf("escapeAppleScript(%q) = %q, want %q", tt.input, got, tt.want)
|
||
|
|
}
|
||
|
|
})
|
||
|
|
}
|
||
|
|
}
|