@@ -6,6 +6,7 @@ package ice
66import (
77 "net"
88 "strconv"
9+ "strings"
910 "testing"
1011 "time"
1112
@@ -465,6 +466,18 @@ func TestCandidateMarshal(t *testing.T) {
465466 " 1 udp 500 " + localhostIPStr + " 80 typ host" ,
466467 false ,
467468 },
469+ // Missing Foundation
470+ {
471+ mustCandidateHost (t , & CandidateHostConfig {
472+ Network : NetworkTypeUDP4 .String (),
473+ Address : localhostIPStr ,
474+ Port : 80 ,
475+ Priority : 500 ,
476+ Foundation : " " ,
477+ }),
478+ "candidate: 1 udp 500 " + localhostIPStr + " 80 typ host" ,
479+ false ,
480+ },
468481 {
469482 mustCandidateHost (t , & CandidateHostConfig {
470483 Network : NetworkTypeUDP4 .String (),
@@ -487,6 +500,17 @@ func TestCandidateMarshal(t *testing.T) {
487500 "3359356140 1 tcp 1671430143 172.28.142.173 7686 typ host" ,
488501 false ,
489502 },
503+ {
504+ mustCandidateHost (t , & CandidateHostConfig {
505+ Network : NetworkTypeTCP4 .String (),
506+ Address : "172.28.142.173" ,
507+ Port : 7686 ,
508+ Priority : 1671430143 ,
509+ Foundation : "+/3713fhi" ,
510+ }),
511+ "candidate:3359356140 1 tcp 1671430143 172.28.142.173 7686 typ host" ,
512+ false ,
513+ },
490514
491515 // Invalid candidates
492516 {nil , "" , true },
@@ -562,7 +586,12 @@ func TestCandidateMarshal(t *testing.T) {
562586 test .candidate .String (),
563587 actualCandidate .String (),
564588 )
565- require .Equal (t , test .marshaled , actualCandidate .Marshal ())
589+
590+ if strings .HasPrefix (test .marshaled , "candidate:" ) {
591+ require .Equal (t , test .marshaled [len ("candidate:" ):], actualCandidate .Marshal ())
592+ } else {
593+ require .Equal (t , test .marshaled , actualCandidate .Marshal ())
594+ }
566595 })
567596 }
568597}
0 commit comments