(t *testing.T)
| 297 | } |
| 298 | |
| 299 | func TestNewlineBehavior(t *testing.T) { |
| 300 | tf := &TextFormatter{ForceColors: true} |
| 301 | |
| 302 | // Ensure a single new line is removed as per stdlib log |
| 303 | e := NewEntry(StandardLogger()) |
| 304 | e.Message = "test message\n" |
| 305 | b, _ := tf.Format(e) |
| 306 | if bytes.Contains(b, []byte("test message\n")) { |
| 307 | t.Error("first newline at end of Entry.Message resulted in unexpected 2 newlines in output. Expected newline to be removed.") |
| 308 | } |
| 309 | |
| 310 | // Ensure a double new line is reduced to a single new line |
| 311 | e = NewEntry(StandardLogger()) |
| 312 | e.Message = "test message\n\n" |
| 313 | b, _ = tf.Format(e) |
| 314 | if bytes.Contains(b, []byte("test message\n\n")) { |
| 315 | t.Error("Double newline at end of Entry.Message resulted in unexpected 2 newlines in output. Expected single newline") |
| 316 | } |
| 317 | if !bytes.Contains(b, []byte("test message\n")) { |
| 318 | t.Error("Double newline at end of Entry.Message did not result in a single newline after formatting") |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | func TestTextFormatterFieldMap(t *testing.T) { |
| 323 | formatter := &TextFormatter{ |
nothing calls this directly
no test coverage detected