From 873b2ef0612c7a57c051fe3c9a3b3268d04b5bac Mon Sep 17 00:00:00 2001 From: Moises Macia Date: Wed, 5 Aug 2026 21:46:40 +0000 Subject: [PATCH] test the BOM mark --- test/feed_reader/streaming_test.exs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/feed_reader/streaming_test.exs b/test/feed_reader/streaming_test.exs index e3e4cb3..e1d3893 100644 --- a/test/feed_reader/streaming_test.exs +++ b/test/feed_reader/streaming_test.exs @@ -24,6 +24,23 @@ defmodule FeedReader.StreamingTest do assert File.read!(path) == @xml 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 xml = @xml <> "