| 98 | } |
| 99 | |
| 100 | func 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 | |
| 119 | func TestEscaping_Interface(t *testing.T) { |
| 120 | tf := &TextFormatter{DisableColors: true} |