Added control to prevent invalid low/high ranges

This commit is contained in:
Daniel Gil
2018-05-29 17:51:41 +02:00
parent 6702d50231
commit 90c4e64922
6 changed files with 64 additions and 23 deletions

View File

@@ -1,5 +1,7 @@
package interval
import "fmt"
func (intvls *intervals) HasGaps() bool {
intvls.Gaps()
if intvls.GapsList != nil && len(intvls.GapsList) > 0 {
@@ -27,7 +29,11 @@ func (intvls *intervals) calculateGaps() []*Interval {
gapThreshold := intvls.MinLow
for _, intvl := range intvls.Intervals {
// convert if necessary exclusive low/high values into inclusive ones
low, high := intvls.getInclusives(intvl.Low, intvl.High)
low, high, err := intvls.getInclusives(intvl.Low, intvl.High)
if err != nil {
fmt.Printf("calculateGaps - unable to get inclusives: %v", err)
continue
}
// if the current Low is higher than the last maximal High, means that there is a gap so we add this gap to the list
if low > gapThreshold {