MCPcopy
hub / github.com/caddyserver/caddy / TestReplacer

Function TestReplacer

replacer_test.go:26–179  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24)
25
26func TestReplacer(t *testing.T) {
27 type testCase struct {
28 input, expect, empty string
29 }
30
31 rep := testReplacer()
32
33 // ReplaceAll
34 for i, tc := range []testCase{
35 {
36 input: "{",
37 expect: "{",
38 },
39 {
40 input: `\{`,
41 expect: `{`,
42 },
43 {
44 input: "foo{",
45 expect: "foo{",
46 },
47 {
48 input: `foo\{`,
49 expect: `foo{`,
50 },
51 {
52 input: "foo{bar",
53 expect: "foo{bar",
54 },
55 {
56 input: `foo\{bar`,
57 expect: `foo{bar`,
58 },
59 {
60 input: "foo{bar}",
61 expect: "foo",
62 },
63 {
64 input: `foo\{bar\}`,
65 expect: `foo{bar}`,
66 },
67 {
68 input: "}",
69 expect: "}",
70 },
71 {
72 input: `\}`,
73 expect: `}`,
74 },
75 {
76 input: "{}",
77 expect: "",
78 },
79 {
80 input: `\{\}`,
81 expect: `{}`,
82 },
83 {

Callers

nothing calls this directly

Calls 2

testReplacerFunction · 0.85
ReplaceAllMethod · 0.80

Tested by

no test coverage detected