-
Notifications
You must be signed in to change notification settings - Fork 0
/
candidatepair_test.go
115 lines (110 loc) · 2.19 KB
/
candidatepair_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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package ice
import "testing"
var (
hostCandidate = &CandidateHost{
candidateBase: candidateBase{
candidateType: CandidateTypeHost,
component: ComponentRTP,
},
}
prflxCandidate = &CandidatePeerReflexive{
candidateBase: candidateBase{
candidateType: CandidateTypePeerReflexive,
component: ComponentRTP,
},
}
srflxCandidate = &CandidateServerReflexive{
candidateBase: candidateBase{
candidateType: CandidateTypeServerReflexive,
component: ComponentRTP,
},
}
relayCandidate = &CandidateRelay{
candidateBase: candidateBase{
candidateType: CandidateTypeRelay,
component: ComponentRTP,
},
}
)
func TestCandidatePairPriority(t *testing.T) {
for _, test := range []struct {
Pair *candidatePair
WantPriority uint64
}{
{
Pair: newCandidatePair(
hostCandidate,
hostCandidate,
false,
),
WantPriority: 9151314440652587007,
},
{
Pair: newCandidatePair(
hostCandidate,
hostCandidate,
true,
),
WantPriority: 9151314440652587007,
},
{
Pair: newCandidatePair(
hostCandidate,
prflxCandidate,
true,
),
WantPriority: 7998392936314175488,
},
{
Pair: newCandidatePair(
hostCandidate,
prflxCandidate,
false,
),
WantPriority: 7998392936314175487,
},
{
Pair: newCandidatePair(
hostCandidate,
srflxCandidate,
true,
),
WantPriority: 7277816996102668288,
},
{
Pair: newCandidatePair(
hostCandidate,
srflxCandidate,
false,
),
WantPriority: 7277816996102668287,
},
{
Pair: newCandidatePair(
hostCandidate,
relayCandidate,
true,
),
WantPriority: 72057593987596288,
},
{
Pair: newCandidatePair(
hostCandidate,
relayCandidate,
false,
),
WantPriority: 72057593987596287,
},
} {
if got, want := test.Pair.Priority(), test.WantPriority; got != want {
t.Fatalf("CandidatePair(%v).Priority() = %d, want %d", test.Pair, got, want)
}
}
}
func TestCandidatePairEquality(t *testing.T) {
pairA := newCandidatePair(hostCandidate, srflxCandidate, true)
pairB := newCandidatePair(hostCandidate, srflxCandidate, false)
if !pairA.Equal(pairB) {
t.Fatalf("Expected %v to equal %v", pairA, pairB)
}
}