test the BOM mark
This commit is contained in:
1 parent
32616be8bc
commit
873b2ef061
1 file changed
+17
@@ -24,6 +24,23 @@ defmodule FeedReader.StreamingTest do
|
|||||||
assert File.read!(path) == @xml
|
assert File.read!(path) == @xml
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "ignores a UTF-8 BOM split across input chunks" do
|
||||||
|
xml = <<0xEF, 0xBB, 0xBF>> <> @xml
|
||||||
|
path = write_temp(xml)
|
||||||
|
|
||||||
|
on_exit(fn -> File.rm(path) end)
|
||||||
|
|
||||||
|
assert {:ok, %{events: events}} = FeedReader.stream_file(path, chunk_size: 1)
|
||||||
|
|
||||||
|
assert [
|
||||||
|
{:feed, %Feed{title: "Example"}},
|
||||||
|
{:item, %Item{uuid: "one"}},
|
||||||
|
{:item, %Item{uuid: "two"}}
|
||||||
|
] = Enum.to_list(events)
|
||||||
|
|
||||||
|
assert File.read!(path) == xml
|
||||||
|
end
|
||||||
|
|
||||||
test "stops at the root and ignores trailing content" do
|
test "stops at the root and ignores trailing content" do
|
||||||
xml = @xml <> "<broken"
|
xml = @xml <> "<broken"
|
||||||
path = write_temp(xml)
|
path = write_temp(xml)
|
||||||
|
|||||||
Reference in new issue
Block a user