forked from TrenchBoot/u-root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
grub_test.go
47 lines (43 loc) · 915 Bytes
/
grub_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright 2017-2020 the u-root Authors. All rights reserved
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package grub
import (
"fmt"
"testing"
)
func TestCmdlineQuote(t *testing.T) {
for i, tt := range []struct {
desc string
in []string
want string
}{
{
desc: "nothing to do",
in: []string{"stuff"},
want: "stuff",
},
{
desc: "split",
in: []string{"stuff", "more", "stuff"},
want: "stuff more stuff",
},
{
desc: "escape",
in: []string{`escape\quote'double"`},
want: `escape\\quote\'double\"`,
},
{
desc: "quote spaced",
in: []string{`some stuff`},
want: `"some stuff"`,
},
} {
t.Run(fmt.Sprintf("Test [%02d] %s", i, tt.desc), func(t *testing.T) {
got := cmdlineQuote(tt.in)
if got != tt.want {
t.Errorf("cmdlineQuote = %#v, want %#v", got, tt.want)
}
})
}
}