Skip to content

Commit 9e9cf49

Browse files
author
FrankHB
committed
Added a test.
Signed-off-by: FrankHB <frankhb1989@gmail.com>
1 parent 780fb97 commit 9e9cf49

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/book/book.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,29 @@ And here is some \
397397
assert_eq!(got, should_be);
398398
}
399399

400+
#[test]
401+
fn load_a_single_chapter_with_utf8_bom_from_disk() {
402+
let temp_dir = TempFileBuilder::new().prefix("book").tempdir().unwrap();
403+
404+
let chapter_path = temp_dir.path().join("chapter_1.md");
405+
File::create(&chapter_path)
406+
.unwrap()
407+
.write_all(("\u{feff}".to_owned() + DUMMY_SRC).as_bytes())
408+
.unwrap();
409+
410+
let link = Link::new("Chapter 1", chapter_path);
411+
412+
let should_be = Chapter::new(
413+
"Chapter 1",
414+
DUMMY_SRC.to_string(),
415+
"chapter_1.md",
416+
Vec::new(),
417+
);
418+
419+
let got = load_chapter(&link, temp_dir.path(), Vec::new()).unwrap();
420+
assert_eq!(got, should_be);
421+
}
422+
400423
#[test]
401424
fn cant_load_a_nonexistent_chapter() {
402425
let link = Link::new("Chapter 1", "/foo/bar/baz.md");

0 commit comments

Comments
 (0)