@@ -6,6 +6,7 @@ package ice
6
6
import (
7
7
"net"
8
8
"strconv"
9
+ "strings"
9
10
"testing"
10
11
"time"
11
12
@@ -465,6 +466,18 @@ func TestCandidateMarshal(t *testing.T) {
465
466
" 1 udp 500 " + localhostIPStr + " 80 typ host" ,
466
467
false ,
467
468
},
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
+ },
468
481
{
469
482
mustCandidateHost (t , & CandidateHostConfig {
470
483
Network : NetworkTypeUDP4 .String (),
@@ -487,6 +500,17 @@ func TestCandidateMarshal(t *testing.T) {
487
500
"3359356140 1 tcp 1671430143 172.28.142.173 7686 typ host" ,
488
501
false ,
489
502
},
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
+ },
490
514
491
515
// Invalid candidates
492
516
{nil , "" , true },
@@ -562,7 +586,12 @@ func TestCandidateMarshal(t *testing.T) {
562
586
test .candidate .String (),
563
587
actualCandidate .String (),
564
588
)
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
+ }
566
595
})
567
596
}
568
597
}
0 commit comments