File: paramtype_test.go

package info (click to toggle)
golang-github-pion-sctp 1.8.6-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bookworm-backports, sid, trixie
  • size: 888 kB
  • sloc: makefile: 13
file content (41 lines) | stat: -rw-r--r-- 749 bytes parent folder | download
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
33
34
35
36
37
38
39
40
41
package sctp

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestParseParamType_Success(t *testing.T) {
	tt := []struct {
		binary   []byte
		expected paramType
	}{
		{[]byte{0x0, 0x1}, heartbeatInfo},
		{[]byte{0x0, 0xd}, outSSNResetReq},
	}

	for i, tc := range tt {
		pType, err := parseParamType(tc.binary)
		if err != nil {
			t.Fatalf("failed to parse paramType %d: %v", i, err)
		}
		assert.Equal(t, tc.expected, pType)
	}
}

func TestParseParamType_Failure(t *testing.T) {
	tt := []struct {
		name   string
		binary []byte
	}{
		{"empty packet", []byte{}},
	}

	for i, tc := range tt {
		_, err := parseParamType(tc.binary)
		if err == nil {
			t.Errorf("expected parseParamType #%d: '%s' to fail.", i, tc.name)
		}
	}
}