Skip to content

Commit b4fc2b3

Browse files
sokolnickimJosé Valim
authored andcommitted
Add unit test for IO.binread with :all option
Unit test checks correct handling of 0x0D0A (CR+LF) when reading entire binary file Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
1 parent 18a5d8a commit b4fc2b3

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/elixir/test/elixir/fixtures/file.bin

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
LF
2+
CRCRLF
3+
LFCR
4+

lib/elixir/test/elixir/io_test.exs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ defmodule IOTest do
2222
assert File.close(file) == :ok
2323
end
2424

25+
test :binread_all do
26+
{:ok, file} = File.open(Path.expand('fixtures/file.bin', __DIR__))
27+
assert "LF\nCR\rCRLF\r\nLFCR\n\r" == IO.binread(file, :all)
28+
assert File.close(file) == :ok
29+
end
30+
2531
test :getn do
2632
{:ok, file} = File.open(Path.expand('fixtures/file.txt', __DIR__))
2733
assert "F" == IO.getn(file, "")

0 commit comments

Comments
 (0)