-
-
Notifications
You must be signed in to change notification settings - Fork 233
/
util_test.go
49 lines (37 loc) · 1008 Bytes
/
util_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
48
49
package bun
import (
"testing"
"github.com/stretchr/testify/require"
)
func Test_appendComment(t *testing.T) {
t.Run("ordinary comment", func(t *testing.T) {
var res []byte
c := "comment"
s := appendComment(res, c)
require.Equal(t, "/* comment */ ", string(s))
})
t.Run("only open sequence", func(t *testing.T) {
var res []byte
c := "/* comment"
s := appendComment(res, c)
require.Equal(t, "/* /\\* comment */ ", string(s))
})
t.Run("only close sequence", func(t *testing.T) {
var res []byte
c := "comment */"
s := appendComment(res, c)
require.Equal(t, "/* comment *\\/ */ ", string(s))
})
t.Run("open and close sequences", func(t *testing.T) {
var res []byte
c := "/* comment */"
s := appendComment(res, c)
require.Equal(t, "/* /\\* comment *\\/ */ ", string(s))
})
t.Run("zero bytes", func(t *testing.T) {
var res []byte
c := string([]byte{'*', 0, 0, 0, 0, 0, '/'})
s := appendComment(res, c)
require.Equal(t, "/* *\\/ */ ", string(s))
})
}