-
Notifications
You must be signed in to change notification settings - Fork 9
/
fmt_test.go
55 lines (50 loc) · 1.03 KB
/
fmt_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
50
51
52
53
54
55
package slog
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestCountFmtOperands(t *testing.T) {
cases := map[string]int{
`%%`: 0,
`%%s`: 0,
`%v`: 1,
`%#v`: 1,
`%T`: 1,
`%t`: 1,
`%c`: 1,
`%d`: 1,
`%o`: 1,
`%O`: 1,
`%U`: 1,
`%b`: 1,
`%e`: 1,
`%E`: 1,
`%f`: 1,
`%F`: 1,
`%g`: 1,
`%G`: 1,
`%s`: 1,
`%q`: 1,
`%x`: 1,
`%X`: 1,
`%p`: 1,
`%9f`: 1,
`%.2f`: 1,
`%9.2f`: 1,
`%9.f`: 1,
`% d`: 1,
`%09d`: 1,
`%%s %s %s`: 2,
`%6.2f`: 1,
`%d %d %#[1]x %#x`: 2,
`%d %d %d %[1]d %d %[3]x %d %d %x`: 6,
`%s %% %%s %s`: 2,
`%s %s`: 2,
`%s %s %d`: 3,
`%[2]d %[1]d`: 2,
`%[3]*.[2]*[1]f`: 3,
`%[3]*.[2]*[1]f %[3]*.[2]*[1]f %s`: 3}
for input, count := range cases {
assert.Equal(t, count, countFmtOperands(input), input)
}
}