mirror of
https://github.com/rust-lang/mdBook
synced 2024-12-13 22:32:35 +00:00
Added a test.
Signed-off-by: FrankHB <frankhb1989@gmail.com>
This commit is contained in:
parent
780fb979a0
commit
9e9cf49c50
1 changed files with 23 additions and 0 deletions
|
@ -397,6 +397,29 @@ And here is some \
|
||||||
assert_eq!(got, should_be);
|
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]
|
#[test]
|
||||||
fn cant_load_a_nonexistent_chapter() {
|
fn cant_load_a_nonexistent_chapter() {
|
||||||
let link = Link::new("Chapter 1", "/foo/bar/baz.md");
|
let link = Link::new("Chapter 1", "/foo/bar/baz.md");
|
||||||
|
|
Loading…
Reference in a new issue