Skip to content

Commit

Permalink
Merge pull request #67 from wmnsk/test-duration-ie
Browse files Browse the repository at this point in the history
Add tests for methods that return time.Duration values (and fix some IEs)
  • Loading branch information
wmnsk authored Oct 28, 2020
2 parents 61d925d + c7db18a commit 887eb52
Show file tree
Hide file tree
Showing 7 changed files with 444 additions and 29 deletions.
2 changes: 1 addition & 1 deletion ie/average-packet-delay.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (i *IE) AveragePacketDelay() (time.Duration, error) {
return 0, err
}
for _, x := range ies {
if x.Type == QoSInformationInGTPUPathQoSReport {
if x.Type == AveragePacketDelay {
return x.AveragePacketDelay()
}
}
Expand Down
25 changes: 12 additions & 13 deletions ie/dl-buffering-duration.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,26 +60,25 @@ func (i *IE) DLBufferingDuration() (time.Duration, error) {
switch i.Type {
case DLBufferingDuration:
var d time.Duration
switch i.Payload[0] | 0xe0 {
case 0xe0:
switch (i.Payload[0] & 0xe0) >> 5 {
case 0x07:
d = time.Duration(math.MaxInt64)
case 0x80:
d = time.Duration(i.Payload[0]|0x1f) * 10 * time.Hour
case 0x60:
d = time.Duration(i.Payload[0]|0x1f) * time.Hour
case 0x40:
d = time.Duration(i.Payload[0]|0x1f) * 10 * time.Minute
case 0x20:
d = time.Duration(i.Payload[0]|0x1f) * time.Minute
case 0x04:
d = time.Duration(i.Payload[0]&0x1f) * 10 * time.Hour
case 0x03:
d = time.Duration(i.Payload[0]&0x1f) * time.Hour
case 0x02:
d = time.Duration(i.Payload[0]&0x1f) * 10 * time.Minute
case 0x01:
d = time.Duration(i.Payload[0]&0x1f) * time.Minute
case 0x00:
d = time.Duration(i.Payload[0]|0x1f) * 2 * time.Second
d = time.Duration(i.Payload[0]&0x1f) * 2 * time.Second
default:
d = 0
}

return d, nil
case UpdateBARWithinSessionReportResponse:
ies, err := i.CreateBAR()
ies, err := i.UpdateBAR()
if err != nil {
return 0, err
}
Expand Down
22 changes: 11 additions & 11 deletions ie/graceful-release-period.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@ func (i *IE) GracefulReleasePeriod() (time.Duration, error) {
}

var d time.Duration
switch i.Payload[0] | 0xe0 {
case 0xe0:
switch (i.Payload[0] & 0xe0) >> 5 {
case 0x07:
d = time.Duration(math.MaxInt64)
case 0x80:
d = time.Duration(i.Payload[0]|0x1f) * 10 * time.Hour
case 0x60:
d = time.Duration(i.Payload[0]|0x1f) * time.Hour
case 0x40:
d = time.Duration(i.Payload[0]|0x1f) * 10 * time.Minute
case 0x20:
d = time.Duration(i.Payload[0]|0x1f) * time.Minute
case 0x04:
d = time.Duration(i.Payload[0]&0x1f) * 10 * time.Hour
case 0x03:
d = time.Duration(i.Payload[0]&0x1f) * time.Hour
case 0x02:
d = time.Duration(i.Payload[0]&0x1f) * 10 * time.Minute
case 0x01:
d = time.Duration(i.Payload[0]&0x1f) * time.Minute
case 0x00:
d = time.Duration(i.Payload[0]|0x1f) * 2 * time.Second
d = time.Duration(i.Payload[0]&0x1f) * 2 * time.Second
default:
d = 0
}
Expand Down
Loading

0 comments on commit 887eb52

Please sign in to comment.