mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-29 01:51:43 +00:00
fixes #26088 in https://github.com/nim-lang/Nim/pull/25772, `beginStores` requires `newLen` to be passed for setting up the new length. So `streams.nim` must make the string length exactly newLen.
This commit is contained in:
@@ -87,6 +87,20 @@ block:
|
||||
ss.setPosition(0)
|
||||
doAssert(ss.peekStr(5) == "hello")
|
||||
|
||||
# bug #26088 - Overwriting a string stream must not truncate it
|
||||
block:
|
||||
var short = newStringStream("0123456789ABCDEF")
|
||||
short.setPosition(0)
|
||||
short.write("XX")
|
||||
doAssert short.data == "XX23456789ABCDEF"
|
||||
doAssert not short.atEnd
|
||||
|
||||
var long = newStringStream("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
||||
long.setPosition(0)
|
||||
long.write("XX")
|
||||
doAssert long.data == "XX23456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
doAssert not long.atEnd
|
||||
|
||||
# bug #19716
|
||||
static: # Ensure streams it doesnt break with nimscript on arc/orc #19716
|
||||
let s = newStringStream("a")
|
||||
|
||||
Reference in New Issue
Block a user