add test for runways

This commit is contained in:
Jacek Sieka 2022-04-04 13:12:59 +02:00
parent c80701f7d2
commit cf9074b2f4
No known key found for this signature in database
GPG Key ID: A1B09461ABB656B8
2 changed files with 28 additions and 0 deletions

View File

@ -29,6 +29,9 @@ proc test(args, path: string) =
# " -d:asyncBackend=asyncdispatch " & common_args & " " & path
task test, "Run all tests":
test "-d:debug --threads:off", "tests/all_tests"
test "-d:release --threads:off", "tests/all_tests"
test "-d:danger --threads:off", "tests/all_tests"
test "-d:debug --threads:on", "tests/all_tests"
test "-d:release --threads:on", "tests/all_tests"
test "-d:danger --threads:on", "tests/all_tests"

View File

@ -400,3 +400,28 @@ suite "randomized tests":
if fileExists(randomBytesFileName):
removeFile randomBytesFileName
test "ensureRunway":
var output = memoryOutput()
const writes = 256
var buffer = newSeq[byte](writes)
let totalBytes = block:
var tmp = 0
for i in 0..<writes:
tmp += i
buffer[i] = byte(i)
tmp
output.ensureRunway(totalBytes)
for i in 0..<writes:
output.write(buffer.toOpenArray(0, i - 1))
output.flush()
let res = output.getOutput()
var j = 0
for i in 0..<writes:
check:
res[j..<j+i] == buffer[0..<i]
j += i