diff options
| author | 2026-03-10 13:28:59 +0800 | |
|---|---|---|
| committer | 2026-03-10 13:28:59 +0800 | |
| commit | af08c84539f9353718604988ba27ae3c466860fc (patch) | |
| tree | 0f1f2536f57af69b55ae06e78efbe26a7a0b3633 /protocol/pktline/parse_length_header_test.go | |
| parent | forgejo, github: Update issue templates (diff) | |
| signature | No signature | |
*: Move sideband64k and pktline to protocol/
Diffstat (limited to 'protocol/pktline/parse_length_header_test.go')
| -rw-r--r-- | protocol/pktline/parse_length_header_test.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/protocol/pktline/parse_length_header_test.go b/protocol/pktline/parse_length_header_test.go new file mode 100644 index 00000000..4bc743dd --- /dev/null +++ b/protocol/pktline/parse_length_header_test.go @@ -0,0 +1,26 @@ +package pktline_test + +import ( + "errors" + "testing" + + "codeberg.org/lindenii/furgit/protocol/pktline" +) + +func TestParseLengthHeader(t *testing.T) { + t.Parallel() + + n, err := pktline.ParseLengthHeader([4]byte{'0', '0', '0', '4'}) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + if n != 4 { + t.Fatalf("got %d, want 4", n) + } + + _, err = pktline.ParseLengthHeader([4]byte{'0', '0', '0', 'x'}) + if !errors.Is(err, pktline.ErrInvalidLength) { + t.Fatalf("got err %v, want ErrInvalidLength", err) + } +} |
