Updates per code reviews

Use ICECandidateType instead of string
Combine two methods to one SetNAT1To1IPs
Resolves #835
This commit is contained in:
Yutaka Takeda
2019-09-26 00:08:00 -07:00
parent ed185037fa
commit d4053a8b71
5 changed files with 62 additions and 39 deletions

View File

@@ -61,3 +61,23 @@ func TestDetachDataChannels(t *testing.T) {
t.Fatalf("Failed to enable detached data channels.")
}
}
func TestSetNAT1To1IPs(t *testing.T) {
s := SettingEngine{}
if s.candidates.NAT1To1IPs != nil {
t.Errorf("Invalid default value")
}
if s.candidates.NAT1To1IPCandidateType != 0 {
t.Errorf("Invalid default value")
}
ips := []string{"1.2.3.4"}
typ := ICECandidateTypeHost
s.SetNAT1To1IPs(ips, typ)
if len(s.candidates.NAT1To1IPs) != 1 || s.candidates.NAT1To1IPs[0] != "1.2.3.4" {
t.Fatalf("Failed to set NAT1To1IPs")
}
if s.candidates.NAT1To1IPCandidateType != typ {
t.Fatalf("Failed to set NAT1To1IPCandidateType")
}
}