(t *testing.T)
| 627 | } |
| 628 | |
| 629 | func TestLogLineSetPanic(t *testing.T) { |
| 630 | t.Run("index out of range", func(t *testing.T) { |
| 631 | fidx := LogLineNumFields + NumFieldsBaker |
| 632 | |
| 633 | defer func() { |
| 634 | if r := recover(); r == nil { |
| 635 | t.Errorf("Set(%d) should panic", fidx) |
| 636 | } |
| 637 | }() |
| 638 | |
| 639 | ll := LogLine{FieldSeparator: ','} |
| 640 | ll.Set(fidx, []byte("value")) |
| 641 | }) |
| 642 | |
| 643 | t.Run("max fields written", func(t *testing.T) { |
| 644 | var fidx FieldIndex |
| 645 | |
| 646 | defer func() { |
| 647 | if r := recover(); r != nil { |
| 648 | t.Errorf("Set(%d) should not panic: %q", fidx, r) |
| 649 | } |
| 650 | }() |
| 651 | |
| 652 | ll := LogLine{FieldSeparator: ','} |
| 653 | // Maximum of 254 changed fields. |
| 654 | for i := 0; i < 255; i++ { |
| 655 | fidx = FieldIndex(i) |
| 656 | ll.Set(fidx, []byte("value")) |
| 657 | } |
| 658 | }) |
| 659 | |
| 660 | t.Run("too many field written", func(t *testing.T) { |
| 661 | defer func() { |
| 662 | if r := recover(); r == nil { |
| 663 | t.Errorf("Set(%d) should panic", 1000) |
| 664 | } |
| 665 | }() |
| 666 | |
| 667 | ll := LogLine{FieldSeparator: ','} |
| 668 | // Maximum of 254 changed fields. |
| 669 | for i := 0; i < 255; i++ { |
| 670 | ll.Set(FieldIndex(i), []byte("value")) |
| 671 | } |
| 672 | // One more. |
| 673 | ll.Set(FieldIndex(1000), []byte("value")) |
| 674 | }) |
| 675 | } |
| 676 | |
| 677 | func TestLogLineCopy(t *testing.T) { |
| 678 | t.Run("nil", func(t *testing.T) { |
nothing calls this directly
no test coverage detected