| 117 | } |
| 118 | |
| 119 | func TestEscaping_Interface(t *testing.T) { |
| 120 | tf := &TextFormatter{DisableColors: true} |
| 121 | |
| 122 | ts := time.Now() |
| 123 | |
| 124 | testCases := []struct { |
| 125 | value interface{} |
| 126 | expected string |
| 127 | }{ |
| 128 | {ts, fmt.Sprintf("\"%s\"", ts.String())}, |
| 129 | {errors.New("error: something went wrong"), "\"error: something went wrong\""}, |
| 130 | } |
| 131 | |
| 132 | for _, tc := range testCases { |
| 133 | b, _ := tf.Format(WithField("test", tc.value)) |
| 134 | if !bytes.Contains(b, []byte(tc.expected)) { |
| 135 | t.Errorf("escaping expected for %q (result was %q instead of %q)", tc.value, string(b), tc.expected) |
| 136 | } |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | func TestTimestampFormat(t *testing.T) { |
| 141 | checkTimeStr := func(format string) { |