forked from pion/sctp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparamtype_test.go
44 lines (37 loc) · 851 Bytes
/
paramtype_test.go
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
42
43
44
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT
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)
}
}
}