File: direction_test.go

package info (click to toggle)
golang-github-pion-sdp 3.0.10-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, sid, trixie
  • size: 304 kB
  • sloc: makefile: 2
file content (53 lines) | stat: -rw-r--r-- 1,119 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
42
43
44
45
46
47
48
49
50
51
52
53
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT

package sdp

import (
	"testing"

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

func TestNewDirection(t *testing.T) {
	passingtests := []struct {
		value    string
		expected Direction
	}{
		{"sendrecv", DirectionSendRecv},
		{"sendonly", DirectionSendOnly},
		{"recvonly", DirectionRecvOnly},
		{"inactive", DirectionInactive},
	}
	failingtests := []string{
		"",
		"notadirection",
	}

	for i, u := range passingtests {
		dir, err := NewDirection(u.value)
		assert.NoError(t, err)
		assert.Equal(t, u.expected, dir, "%d: %+v", i, u)
	}
	for _, u := range failingtests {
		_, err := NewDirection(u)
		assert.Error(t, err)
	}
}

func TestDirection_String(t *testing.T) {
	tests := []struct {
		actual   Direction
		expected string
	}{
		{Direction(unknown), directionUnknownStr},
		{DirectionSendRecv, "sendrecv"},
		{DirectionSendOnly, "sendonly"},
		{DirectionRecvOnly, "recvonly"},
		{DirectionInactive, "inactive"},
	}

	for i, u := range tests {
		assert.Equal(t, u.expected, u.actual.String(), "%d: %+v", i, u)
	}
}