diff options
author | José Valim <jose.valim@plataformatec.com.br> | 2012-11-16 09:42:35 +0100 |
---|---|---|
committer | José Valim <jose.valim@plataformatec.com.br> | 2012-11-16 09:42:35 +0100 |
commit | 7894ba0fc126404187b943daf0a811bd54549685 (patch) | |
tree | 32fdddb34cb17e5bc0a7682d39136aa3604f54b5 /lib/elixir/test/elixir/io_test.exs | |
parent | ad37d5f67a5682e8f4e07fc25993dbaf48f7e372 (diff) | |
download | elixir-7894ba0fc126404187b943daf0a811bd54549685.tar.gz |
Add IO.binread, IO.binwrite and friends, closes #645
Diffstat (limited to 'lib/elixir/test/elixir/io_test.exs')
-rw-r--r-- | lib/elixir/test/elixir/io_test.exs | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/elixir/test/elixir/io_test.exs b/lib/elixir/test/elixir/io_test.exs index 066ba0b7d..751a78949 100644 --- a/lib/elixir/test/elixir/io_test.exs +++ b/lib/elixir/test/elixir/io_test.exs @@ -10,11 +10,17 @@ defmodule IOTest do end test :read_with_utf8_and_binary do - { :ok, file } = File.open(File.expand_path('../fixtures/utf8.txt', __FILE__)) + { :ok, file } = File.open(File.expand_path('../fixtures/utf8.txt', __FILE__), [:utf8]) assert "Русский" == IO.read(file, 7) assert File.close(file) == :ok end + test :binread do + { :ok, file } = File.open(File.expand_path('../fixtures/utf8.txt', __FILE__)) + assert "Русский" == IO.binread(file, 14) + assert File.close(file) == :ok + end + test :getb do { :ok, file } = File.open(File.expand_path('../fixtures/foo.txt', __FILE__)) assert "F" == IO.getb(file, "") @@ -32,7 +38,7 @@ defmodule IOTest do end test :getb_with_utf8_and_binary do - { :ok, file } = File.open(File.expand_path('../fixtures/utf8.txt', __FILE__)) + { :ok, file } = File.open(File.expand_path('../fixtures/utf8.txt', __FILE__), [:utf8]) assert "Русский" == IO.getb(file, "", 7) assert File.close(file) == :ok end @@ -45,7 +51,7 @@ defmodule IOTest do end test :gets_with_utf8_and_binary do - { :ok, file } = File.open(File.expand_path('../fixtures/utf8.txt', __FILE__)) + { :ok, file } = File.open(File.expand_path('../fixtures/utf8.txt', __FILE__), [:utf8]) assert "Русский\n" == IO.gets(file, "") assert "日\n" == IO.gets(file, "") assert File.close(file) == :ok @@ -59,9 +65,16 @@ defmodule IOTest do end test :readline_with_utf8_and_binary do - { :ok, file } = File.open(File.expand_path('../fixtures/utf8.txt', __FILE__)) + { :ok, file } = File.open(File.expand_path('../fixtures/utf8.txt', __FILE__), [:utf8]) assert "Русский\n" == IO.readline(file) assert "日\n" == IO.readline(file) assert File.close(file) == :ok end + + test :binreadline do + { :ok, file } = File.open(File.expand_path('../fixtures/utf8.txt', __FILE__)) + assert "Русский\n" == IO.binreadline(file) + assert "日\n" == IO.binreadline(file) + assert File.close(file) == :ok + end end |