(t *testing.T)
| 575 | } |
| 576 | |
| 577 | func TestLogLineGet(t *testing.T) { |
| 578 | t.Run("zero value + get", func(t *testing.T) { |
| 579 | ll := LogLine{FieldSeparator: ','} |
| 580 | |
| 581 | for i := FieldIndex(0); i < LogLineNumFields+NumFieldsBaker; i++ { |
| 582 | got := ll.Get(i) |
| 583 | if got != nil { |
| 584 | t.Errorf("ll.Get(%d) = %q, want nil", i, got) |
| 585 | } |
| 586 | } |
| 587 | }) |
| 588 | |
| 589 | t.Run("parse + get", func(t *testing.T) { |
| 590 | ll := LogLine{FieldSeparator: ','} |
| 591 | ll.Parse([]byte("value,value,value"), nil) |
| 592 | |
| 593 | for i := FieldIndex(3); i < LogLineNumFields+NumFieldsBaker; i++ { |
| 594 | got := ll.Get(i) |
| 595 | if len(got) != 0 { |
| 596 | t.Errorf("ll.Get(%d) = %q, want nil", i, got) |
| 597 | } |
| 598 | } |
| 599 | }) |
| 600 | |
| 601 | t.Run("3 x set + get", func(t *testing.T) { |
| 602 | ll := LogLine{FieldSeparator: ','} |
| 603 | ll.Set(FieldIndex(0), []byte("value")) |
| 604 | ll.Set(FieldIndex(1), []byte("value")) |
| 605 | ll.Set(FieldIndex(2), []byte("value")) |
| 606 | |
| 607 | for i := FieldIndex(3); i < LogLineNumFields+NumFieldsBaker; i++ { |
| 608 | got := ll.Get(i) |
| 609 | if len(got) != 0 { |
| 610 | t.Errorf("ll.Get(%d) = %q, want nil", i, got) |
| 611 | } |
| 612 | } |
| 613 | }) |
| 614 | |
| 615 | t.Run("out of range", func(t *testing.T) { |
| 616 | fidx := LogLineNumFields + NumFieldsBaker |
| 617 | |
| 618 | defer func() { |
| 619 | if r := recover(); r == nil { |
| 620 | t.Errorf("Get(%d) should panic", fidx) |
| 621 | } |
| 622 | }() |
| 623 | |
| 624 | ll := LogLine{FieldSeparator: ','} |
| 625 | ll.Get(fidx) |
| 626 | }) |
| 627 | } |
| 628 | |
| 629 | func TestLogLineSetPanic(t *testing.T) { |
| 630 | t.Run("index out of range", func(t *testing.T) { |
nothing calls this directly
no test coverage detected