@@ -18,6 +18,7 @@ package bgp
18
18
import (
19
19
"bytes"
20
20
"encoding/binary"
21
+ "math"
21
22
"net"
22
23
"os"
23
24
"path/filepath"
@@ -443,6 +444,28 @@ func Test_FlowSpecNlri(t *testing.T) {
443
444
assert .Equal (n1 , n2 )
444
445
}
445
446
447
+ func Test_NewFlowSpecComponentItemLength (t * testing.T ) {
448
+ item := NewFlowSpecComponentItem (0 , 0 )
449
+ assert .Equal (t , 1 , item .Len ())
450
+ item = NewFlowSpecComponentItem (0 , math .MaxUint8 )
451
+ assert .Equal (t , 1 , item .Len ())
452
+
453
+ item = NewFlowSpecComponentItem (0 , math .MaxUint8 + 1 )
454
+ assert .Equal (t , 2 , item .Len ())
455
+ item = NewFlowSpecComponentItem (0 , math .MaxUint16 )
456
+ assert .Equal (t , 2 , item .Len ())
457
+
458
+ item = NewFlowSpecComponentItem (0 , math .MaxUint16 + 1 )
459
+ assert .Equal (t , 4 , item .Len ())
460
+ item = NewFlowSpecComponentItem (0 , math .MaxUint32 )
461
+ assert .Equal (t , 4 , item .Len ())
462
+
463
+ item = NewFlowSpecComponentItem (0 , math .MaxUint32 + 1 )
464
+ assert .Equal (t , 8 , item .Len ())
465
+ item = NewFlowSpecComponentItem (0 , math .MaxUint64 )
466
+ assert .Equal (t , 8 , item .Len ())
467
+ }
468
+
446
469
func Test_LinkBandwidthExtended (t * testing.T ) {
447
470
assert := assert .New (t )
448
471
exts := make ([]ExtendedCommunityInterface , 0 )
0 commit comments