aboutsummaryrefslogtreecommitdiff
path: root/protocol/sideband64k/decoder_malformed_pktline_test.go
blob: 9d4030f34e577bcc0acff37f0841d704656ea4ed (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package sideband64k_test

import (
	"errors"
	"strings"
	"testing"

	"codeberg.org/lindenii/furgit/protocol/pktline"
	"codeberg.org/lindenii/furgit/protocol/sideband64k"
)

func TestDecoderInvalid0003(t *testing.T) {
	t.Parallel()

	dec := sideband64k.NewDecoder(strings.NewReader("0003"), sideband64k.ReadOptions{})
	_, err := dec.ReadFrame()

	if _, ok := errors.AsType[*pktline.ProtocolError](err); !ok {
		t.Fatalf("got err %v, want pktline.ProtocolError", err)
	}
}

func TestDecoderRejectsOverMaximumLength(t *testing.T) {
	t.Parallel()

	dec := sideband64k.NewDecoder(strings.NewReader("fffe"), sideband64k.ReadOptions{})
	_, err := dec.ReadFrame()

	if _, ok := errors.AsType[*pktline.ProtocolError](err); !ok {
		t.Fatalf("got err %v, want pktline.ProtocolError", err)
	}
}