@@ -698,8 +698,20 @@ func TestCandidateExtensionsMarshal(t *testing.T) {
698
698
"1052353102 1 tcp 2128609279 192.168.0.196 0 typ host" ,
699
699
},
700
700
{
701
- []CandidateExtension {},
702
- "1052353102 1 tcp 2128609279 192.168.0.196 0 typ host" ,
701
+ []CandidateExtension {
702
+ {"tcptype" , "active" },
703
+ {"empty-value-1" , "" },
704
+ {"empty-value-2" , "" },
705
+ },
706
+ "1052353102 1 tcp 2128609279 192.168.0.196 0 typ host tcptype active empty-value-1 empty-value-2" ,
707
+ },
708
+ {
709
+ []CandidateExtension {
710
+ {"tcptype" , "active" },
711
+ {"empty-value-1" , "" },
712
+ {"empty-value-2" , "" },
713
+ },
714
+ "1052353102 1 tcp 2128609279 192.168.0.196 0 typ host tcptype active empty-value-1 empty-value-2 " ,
703
715
},
704
716
}
705
717
@@ -967,16 +979,10 @@ func TestUnmarshalCandidateExtensions(t *testing.T) {
967
979
},
968
980
fail : false ,
969
981
},
970
- {
971
- name : "invalid extension string" ,
972
- value : "invalid" ,
973
- expected : []CandidateExtension {},
974
- fail : true ,
975
- },
976
982
{
977
983
name : "invalid extension" ,
978
- value : " a b" ,
979
- expected : []CandidateExtension {{"a " , "b " }, {"c " , "d" }},
984
+ value : " a b d " ,
985
+ expected : []CandidateExtension {{"" , "a " }, {"b " , "d" }},
980
986
fail : true ,
981
987
},
982
988
}
@@ -1357,6 +1363,27 @@ func TestCandidateAddExtension(t *testing.T) {
1357
1363
1358
1364
require .Error (t , candidate .AddExtension (CandidateExtension {"tcptype" , "INVALID" }))
1359
1365
})
1366
+
1367
+ t .Run ("Add empty extension" , func (t * testing.T ) {
1368
+ candidate , err := NewCandidateHost (& CandidateHostConfig {
1369
+ Network : NetworkTypeUDP4 .String (),
1370
+ Address : "fcd9:e3b8:12ce:9fc5:74a5:c6bb:d8b:e08a" ,
1371
+ Port : 53987 ,
1372
+ Priority : 500 ,
1373
+ Foundation : "750" ,
1374
+ })
1375
+ if err != nil {
1376
+ t .Error (err )
1377
+ }
1378
+
1379
+ require .Error (t , candidate .AddExtension (CandidateExtension {"" , "" }))
1380
+
1381
+ require .NoError (t , candidate .AddExtension (CandidateExtension {"a" , "" }))
1382
+
1383
+ extensions := candidate .Extensions ()
1384
+
1385
+ require .Equal (t , []CandidateExtension {{"a" , "" }}, extensions )
1386
+ })
1360
1387
}
1361
1388
1362
1389
func TestCandidateRemoveExtension (t * testing.T ) {
0 commit comments