forked from pion/ice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
candidate_test.go
72 lines (67 loc) · 1.59 KB
/
candidate_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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package ice
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestCandidatePriority(t *testing.T) {
for _, test := range []struct {
Candidate Candidate
WantPriority uint32
}{
{
Candidate: &CandidateHost{
candidateBase: candidateBase{
candidateType: CandidateTypeHost,
component: ComponentRTP,
},
},
WantPriority: 2130706431,
},
{
Candidate: &CandidatePeerReflexive{
candidateBase: candidateBase{
candidateType: CandidateTypePeerReflexive,
component: ComponentRTP,
},
},
WantPriority: 1862270975,
},
{
Candidate: &CandidateServerReflexive{
candidateBase: candidateBase{
candidateType: CandidateTypeServerReflexive,
component: ComponentRTP,
},
},
WantPriority: 1694498815,
},
{
Candidate: &CandidateRelay{
candidateBase: candidateBase{
candidateType: CandidateTypeRelay,
component: ComponentRTP,
},
},
WantPriority: 16777215,
},
} {
if got, want := test.Candidate.Priority(), test.WantPriority; got != want {
t.Fatalf("Candidate(%v).Priority() = %d, want %d", test.Candidate, got, want)
}
}
}
func TestCandidateLastSent(t *testing.T) {
candidate := candidateBase{}
assert.Equal(t, candidate.LastSent(), time.Time{})
now := time.Now()
candidate.setLastSent(now)
assert.Equal(t, candidate.LastSent(), now)
}
func TestCandidateLastReceived(t *testing.T) {
candidate := candidateBase{}
assert.Equal(t, candidate.LastReceived(), time.Time{})
now := time.Now()
candidate.setLastReceived(now)
assert.Equal(t, candidate.LastReceived(), now)
}