Harmonize the APIs and the coding practices in input_stream and output_stream

This commit is contained in:
Zahary Karadjov 2020-04-10 15:30:58 +03:00
commit 3efad6f7f2
No known key found for this signature in database
GPG key ID: C8936F8A3073D609
4 changed files with 186 additions and 155 deletions

View file

@ -5,7 +5,7 @@ import
suite "input stream":
test "string input":
var input = repeat("1234 5678 90AB CDEF\n", 1000)
var stream = memoryStream(input)
var stream = memoryInput(input)
check:
(stream.readBytes(4) == "1234".toOpenArrayByte(0, 3))

View file

@ -21,14 +21,14 @@ proc randomBytes(n: int): seq[byte] =
suite "output stream":
setup:
var memStream = OutputStream.init
var memStream = memoryOutput()
var altOutput: seq[byte] = @[]
var tempFilePath = getTempDir() / "faststreams_testfile"
var fileStream = OutputStream.init tempFilePath
var fileStream = fileOutput(tempFilePath)
const bufferSize = 1000000
var buffer = alloc(bufferSize)
var existingBufferStream = OutputStream.init(buffer, bufferSize)
var existingBufferStream = memoryOutput(buffer, bufferSize)
teardown:
removeFile tempFilePath