MCPcopy
hub / github.com/sirupsen/logrus / TestEscaping

Function TestEscaping

text_formatter_test.go:100–117  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

98}
99
100func TestEscaping(t *testing.T) {
101 tf := &TextFormatter{DisableColors: true}
102
103 testCases := []struct {
104 value string
105 expected string
106 }{
107 {`ba"r`, `ba\"r`},
108 {`ba'r`, `ba'r`},
109 }
110
111 for _, tc := range testCases {
112 b, _ := tf.Format(WithField("test", tc.value))
113 if !bytes.Contains(b, []byte(tc.expected)) {
114 t.Errorf("escaping expected for %q (result was %q instead of %q)", tc.value, string(b), tc.expected)
115 }
116 }
117}
118
119func TestEscaping_Interface(t *testing.T) {
120 tf := &TextFormatter{DisableColors: true}

Callers

nothing calls this directly

Calls 3

FormatMethod · 0.95
WithFieldFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected