Merge pull request #27 from status-im/runway-test

add test for runways
This commit is contained in:
Jacek Sieka 2022-04-07 10:11:37 +02:00 • committed by GitHub
commit 5a5bfd3c09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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 # " -d:asyncBackend=asyncdispatch " & common_args & " " & path
task test, "Run all tests": 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:debug --threads:on", "tests/all_tests"
test "-d:release --threads:on", "tests/all_tests" test "-d:release --threads:on", "tests/all_tests"
test "-d:danger --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): if fileExists(randomBytesFileName):
removeFile 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