Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bio-rd
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
danet
bio-rd
Commits
bb722649
Commit
bb722649
authored
6 years ago
by
Oliver Herms
Browse files
Options
Downloads
Patches
Plain Diff
More tests
parent
10ed7528
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
protocols/isis/packet/tlv_area_addresses.go
+6
-5
6 additions, 5 deletions
protocols/isis/packet/tlv_area_addresses.go
protocols/isis/packet/tlv_area_addresses_test.go
+99
-0
99 additions, 0 deletions
protocols/isis/packet/tlv_area_addresses_test.go
with
105 additions
and
5 deletions
protocols/isis/packet/tlv_area_addresses.go
+
6
−
5
View file @
bb722649
...
@@ -7,10 +7,10 @@ import (
...
@@ -7,10 +7,10 @@ import (
"github.com/bio-routing/bio-rd/protocols/isis/types"
"github.com/bio-routing/bio-rd/protocols/isis/types"
)
)
// AreaAddressTLVType is the type value of an area address TLV
// AreaAddress
es
TLVType is the type value of an area address TLV
const
AreaAddressesTLVType
=
1
const
AreaAddressesTLVType
=
1
// AreaAddressTLV represents an area address TLV
// AreaAddress
es
TLV represents an area address TLV
type
AreaAddressesTLV
struct
{
type
AreaAddressesTLV
struct
{
TLVType
uint8
TLVType
uint8
TLVLength
uint8
TLVLength
uint8
...
@@ -47,11 +47,12 @@ func readAreaAddressesTLV(buf *bytes.Buffer, tlvType uint8, tlvLength uint8) (*A
...
@@ -47,11 +47,12 @@ func readAreaAddressesTLV(buf *bytes.Buffer, tlvType uint8, tlvLength uint8) (*A
return
pdu
,
nil
return
pdu
,
nil
}
}
func
NewAreaAddressTLV
(
areas
[]
types
.
AreaID
)
*
AreaAddressesTLV
{
// NewAreaAddressesTLV creates a new area addresses TLV
func
NewAreaAddressesTLV
(
areas
[]
types
.
AreaID
)
*
AreaAddressesTLV
{
a
:=
&
AreaAddressesTLV
{
a
:=
&
AreaAddressesTLV
{
TLVType
:
AreaAddressesTLVType
,
TLVType
:
AreaAddressesTLVType
,
TLVLength
:
0
,
TLVLength
:
0
,
AreaIDs
:
make
([]
types
.
AreaID
,
len
(
areas
)),
AreaIDs
:
make
([]
types
.
AreaID
,
len
(
areas
)),
}
}
for
i
,
area
:=
range
areas
{
for
i
,
area
:=
range
areas
{
...
...
This diff is collapsed.
Click to expand it.
protocols/isis/packet/tlv_area_addresses_test.go
0 → 100644
+
99
−
0
View file @
bb722649
package
packet
import
(
"bytes"
"testing"
"github.com/bio-routing/bio-rd/protocols/isis/types"
"github.com/stretchr/testify/assert"
)
func
TestNewAreaAddressesTLV
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
name
string
input
[]
types
.
AreaID
expected
*
AreaAddressesTLV
}{
{
name
:
"Without Areas"
,
input
:
[]
types
.
AreaID
{},
expected
:
&
AreaAddressesTLV
{
TLVType
:
1
,
TLVLength
:
0
,
AreaIDs
:
[]
types
.
AreaID
{},
},
},
{
name
:
"With Areas"
,
input
:
[]
types
.
AreaID
{
{
1
,
2
,
3
,
},
},
expected
:
&
AreaAddressesTLV
{
TLVType
:
1
,
TLVLength
:
4
,
AreaIDs
:
[]
types
.
AreaID
{
{
1
,
2
,
3
,
},
},
},
},
}
for
_
,
test
:=
range
tests
{
tlv
:=
NewAreaAddressesTLV
(
test
.
input
)
assert
.
Equalf
(
t
,
test
.
expected
,
tlv
,
"Test %q"
,
test
.
name
)
}
}
func
TestAreaAddressesTLV
(
t
*
testing
.
T
)
{
tlv
:=
NewAreaAddressesTLV
([]
types
.
AreaID
{})
assert
.
Equal
(
t
,
uint8
(
1
),
tlv
.
Type
())
assert
.
Equal
(
t
,
uint8
(
0
),
tlv
.
Length
())
assert
.
Equal
(
t
,
AreaAddressesTLV
{
TLVType
:
1
,
TLVLength
:
0
,
AreaIDs
:
[]
types
.
AreaID
{},
},
tlv
.
Value
())
}
func
TestAreaAddressesTLVSerialize
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
name
string
input
*
AreaAddressesTLV
expected
[]
byte
}{
{
name
:
"Full"
,
input
:
&
AreaAddressesTLV
{
TLVType
:
1
,
TLVLength
:
0
,
AreaIDs
:
[]
types
.
AreaID
{},
},
expected
:
[]
byte
{
1
,
0
},
},
{
name
:
"Full"
,
input
:
&
AreaAddressesTLV
{
TLVType
:
8
,
TLVLength
:
4
,
AreaIDs
:
[]
types
.
AreaID
{
{
1
,
2
,
3
,
},
},
},
expected
:
[]
byte
{
8
,
4
,
3
,
1
,
2
,
3
},
},
}
for
_
,
test
:=
range
tests
{
buf
:=
bytes
.
NewBuffer
(
nil
)
test
.
input
.
Serialize
(
buf
)
assert
.
Equalf
(
t
,
test
.
expected
,
buf
.
Bytes
(),
"Test %q"
,
test
.
name
)
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment