Skip to content

Commit

Permalink
Added a test.
Browse files Browse the repository at this point in the history
Signed-off-by: FrankHB <frankhb1989@gmail.com>
  • Loading branch information
FrankHB committed Oct 7, 2020
1 parent 780fb97 commit 9e9cf49
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/book/book.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,29 @@ And here is some \
assert_eq!(got, should_be);
}

#[test]
fn load_a_single_chapter_with_utf8_bom_from_disk() {
let temp_dir = TempFileBuilder::new().prefix("book").tempdir().unwrap();

let chapter_path = temp_dir.path().join("chapter_1.md");
File::create(&chapter_path)
.unwrap()
.write_all(("\u{feff}".to_owned() + DUMMY_SRC).as_bytes())
.unwrap();

let link = Link::new("Chapter 1", chapter_path);

let should_be = Chapter::new(
"Chapter 1",
DUMMY_SRC.to_string(),
"chapter_1.md",
Vec::new(),
);

let got = load_chapter(&link, temp_dir.path(), Vec::new()).unwrap();
assert_eq!(got, should_be);
}

#[test]
fn cant_load_a_nonexistent_chapter() {
let link = Link::new("Chapter 1", "/foo/bar/baz.md");
Expand Down

0 comments on commit 9e9cf49

Please sign in to comment.