Files
ice/candidate_test.go
T
Michael MacDonald ad7c8697fd Candidate priority is incorrectly calculated
Some constants were being incorrectly generated using 2^N (XOR)
instead of 1 << N. This resulted in incorrect candidate priorities
being used to evaluate candidate pairs.

Resolves #14.
2019-04-11 13:40:39 -04:00

48 lines
1.1 KiB
Go

package ice
import "testing"
func TestCandidatePriority(t *testing.T) {
for _, test := range []struct {
Candidate *Candidate
WantPriority uint32
}{
{
Candidate: &Candidate{
Type: CandidateTypeHost,
LocalPreference: defaultLocalPreference,
Component: ComponentRTP,
},
WantPriority: 2130706431,
},
{
Candidate: &Candidate{
Type: CandidateTypePeerReflexive,
LocalPreference: defaultLocalPreference,
Component: ComponentRTP,
},
WantPriority: 1862270975,
},
{
Candidate: &Candidate{
Type: CandidateTypeServerReflexive,
LocalPreference: defaultLocalPreference,
Component: ComponentRTP,
},
WantPriority: 1694498815,
},
{
Candidate: &Candidate{
Type: CandidateTypeRelay,
LocalPreference: defaultLocalPreference,
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)
}
}
}