diff --git a/packages/mdbook-rust/tests/integration.rs b/packages/mdbook-rust/tests/integration.rs index b5381f4..03e2705 100644 --- a/packages/mdbook-rust/tests/integration.rs +++ b/packages/mdbook-rust/tests/integration.rs @@ -5,6 +5,20 @@ fn check(source: &str, expected: &str) { assert_eq!(write_module(source).unwrap(), Some(expected.to_string())); } +#[test] +fn empty() { + assert!(write_module("").unwrap().is_none()); +} + +#[test] +fn ignored() { + assert!(write_module(indoc! {" + fn ingnore_me() {} + "}) + .unwrap() + .is_none()); +} + #[test] fn basic() { check( @@ -27,3 +41,98 @@ fn basic() { "}, ) } + +#[test] +fn empty_body() { + check("fn body() {}", "\n") +} + +#[test] +fn line_comment_indent() { + check( + indoc! {" + fn body() { + //# No space after comment marker + // + // - Item 1 + //- Item 2 with no space after comment marker + // - Sub-item + } + "}, + indoc! {" + # No space after comment marker + + - Item 1 + - Item 2 with no space after comment marker + - Sub-item + "}, + ) +} + +#[test] +fn block_comment_indent() { + check( + indoc! {" + fn body() { + /* + # Heading + + - Item 1 + - Item 2 + - Sub-item + */ + } + "}, + indoc! {" + + # Heading + + - Item 1 + - Item 2 + - Sub-item + + "}, + ) +} + +#[test] +fn code_only() { + check( + indoc! {" + fn body() { + let x = 1; + let y = 1; + } + "}, + indoc! {" + + + ```rust + let x = 1; + let y = 1; + ``` + "}, + ) +} + +#[test] +fn code_spacing() { + check( + indoc! {" + fn body() { + let x = 1; + + let y = 1; + } + "}, + indoc! {" + + + ```rust + let x = 1; + + let y = 1; + ``` + "}, + ) +}