mirror of
https://github.com/pion/ice.git
synced 2025-10-22 23:19:35 +08:00
73 lines
1.6 KiB
Go
73 lines
1.6 KiB
Go
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)
|
|
}
|