Skip to content

Commit

Permalink
fstream write
Browse files Browse the repository at this point in the history
  • Loading branch information
cryi committed Sep 18, 2024
1 parent b32d3e5 commit 66031f6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion deps/eli-stream-extra
18 changes: 18 additions & 0 deletions lib/tests/extensions/io.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local test = TEST or require"u-test"
local ok, exIo = pcall(require, "eli.extensions.io")
local fs = require"eli.fs"

if not ok then
test["eli.extensions.io available"] = function ()
Expand Down Expand Up @@ -64,6 +65,23 @@ test["file as stream - bytes"] = function ()
test.assert(refContent == streamContent, "content does not match")
end

test["file as stream - write"] = function ()
fs.remove"tmp/test-streamed.file"
fs.remove"tmp/test-write.file"

local content = "12345"
local stream = exIo.open_fstream("tmp/test-streamed.file", "w")
stream:write(content)
stream:close()
fs.write_file("tmp/test-write.file", content)

local hashOfStreamContent = fs.hash_file"tmp/test-streamed.file"
local hashOfWriteContent = fs.hash_file"tmp/test-write.file"

test.assert(hashOfStreamContent == hashOfWriteContent, "content does not match")
end


if not TEST then
test.summary()
end

0 comments on commit 66031f6

Please sign in to comment.