Fix fringe case (#130)
why: Merging [a,a] in to {[a+1,b]} caused assertion violation, doAssert condition was too strict.
This commit is contained in:
parent
8a9816ac02
commit
598246620d
|
@ -347,9 +347,9 @@ proc new[P,S](T: type Interval[P,S]; kvp: DataRef[P,S]): T =
|
|||
|
||||
proc overlapOrLeftJoin[P,S](ds: Desc[P,S]; l, r: P): Rc[P,S] =
|
||||
## Find and return
|
||||
## * either the rightmost `[l,r)` overlapping interval `[a,b)`
|
||||
## * either the rightmost interval `[a,b)` which overlaps `r`
|
||||
## * or `[a,b)` with `b==l`
|
||||
doAssert l < r
|
||||
doAssert l <= r
|
||||
let rc = ds.leftPos.le(r) # search for `max(a) <= r`
|
||||
if rc.isOk:
|
||||
# note that `b` is the first point outside right of `[a,b)`
|
||||
|
|
|
@ -195,6 +195,11 @@ suite "IntervalSet: Intervals of FancyPoint entries over FancyScalar":
|
|||
(ivVal, ivSet) = (iv, true)
|
||||
check ivVal == iv(uHigh,uHigh)
|
||||
|
||||
br.clear() # from blockchain sync crash
|
||||
check br.total == 0 and br.chunks == 0
|
||||
check br.merge(1477152,uHigh) == uHigh - 1477151
|
||||
check br.merge(1477151,1477151) == 1
|
||||
|
||||
test "Merge disjunct intervals on 1st set":
|
||||
br.clear()
|
||||
check br.merge( 0, 99) == 100
|
||||
|
|
Loading…
Reference in New Issue