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>
This commit is contained in:
Michael Sokolnicki
2015-06-05 13:14:22 +02:00
committed by José Valim
parent 18a5d8affb
commit b4fc2b35fc
2 changed files with 10 additions and 0 deletions
+4
View File
@@ -0,0 +1,4 @@
LF
CR␍CRLF
LFCR
␍
+6
View File
@@ -22,6 +22,12 @@ defmodule IOTest do
assert File.close(file) == :ok
end
test :binread_all do
{:ok, file} = File.open(Path.expand('fixtures/file.bin', __DIR__))
assert "LF\nCR\rCRLF\r\nLFCR\n\r" == IO.binread(file, :all)
assert File.close(file) == :ok
end
test :getn do
{:ok, file} = File.open(Path.expand('fixtures/file.txt', __DIR__))
assert "F" == IO.getn(file, "")