mirror of
https://github.com/status-im/nim-ranges.git
synced 2025-01-12 05:44:11 +00:00
fix zero length concat
This commit is contained in:
parent
39f0a3cd03
commit
af939d8ac4
@ -155,7 +155,8 @@ template toRange*[T](a: Range[T]): Range[T] = a
|
||||
|
||||
template copyRange[T](E: typedesc, dest: seq[T], destOffset: int, src: Range[T]) =
|
||||
when supportsCopyMem(E):
|
||||
copyMem(dest[destOffset].unsafeAddr, src.start, sizeof(T) * src.len)
|
||||
if dest.len != 0 and src.len != 0:
|
||||
copyMem(dest[destOffset].unsafeAddr, src.start, sizeof(T) * src.len)
|
||||
else:
|
||||
for i in 0..<src.len:
|
||||
dest[i + destOffset] = src[i]
|
||||
|
@ -41,6 +41,11 @@ suite "Typed ranges":
|
||||
var z = concat(b, @[7,8,9])
|
||||
check z == f
|
||||
|
||||
let u = toRange(newSeq[int](0))
|
||||
let v = toRange(@[3])
|
||||
check concat(u, v) == @[3]
|
||||
check (v & u) == @[3]
|
||||
|
||||
test "complex types concat operation":
|
||||
type
|
||||
Jaeger = object
|
||||
|
Loading…
x
Reference in New Issue
Block a user