use pretty_assertions::assert_eq; use crate::parser::parse; use super::html::render_html; fn check_renders_to(rst: &str, expected: &str) { println!("Rendering:\n{}\n---", rst); let doc = parse(rst).expect("Cannot parse"); let mut result_data: Vec = vec![]; render_html(&doc, &mut result_data, false).expect("Render error"); let result = String::from_utf8(result_data).expect("Could not decode"); assert_eq!(result.as_str().trim(), expected); } #[test] fn test_simple_string() { check_renders_to( "Simple String", "

Simple String

", ); } #[test] fn test_simple_string_with_markup() { check_renders_to( "Simple String with *emph* and **strong**", "

Simple String with emph and strong

", ); } #[test] fn test_check_inline_literal() { check_renders_to( "Simple String with an even simpler ``inline literal``", "

Simple String with an even simpler inline literal

", ); } /* #[test] fn test_reference_anonymous() { check_renders_to("\ A simple `anonymous reference`__ __ http://www.test.com/test_url ", "\

A simple anonymous reference

\ "); } */ #[test] fn test_two_paragraphs() { check_renders_to( "One paragraph.\n\nTwo paragraphs.", "

One paragraph.

\n

Two paragraphs.

", ); } #[test] fn test_named_reference() { check_renders_to("\ A simple `named reference`_ with stuff in between the reference and the target. .. _`named reference`: http://www.test.com/test_url ", "\

A simple named reference with stuff in between the \ reference and the target.

\ "); } #[test] fn test_substitution() { check_renders_to("\ A |subst|. .. |subst| replace:: text substitution ", "

A text substitution.

"); } /* #[test] fn test_section_hierarchy() { check_renders_to("\ +++++ Title +++++ Subtitle ======== Some stuff Section ------- Some more stuff Another Section ............... And even more stuff ", "\

Some stuff

Section

Some more stuff

Another Section

And even more stuff

\ "); } #[test] fn test_docinfo_title() { check_renders_to("\ +++++ Title +++++ :author: me Some stuff ", "\

Title

Author

me

Some stuff

\ "); } */ #[test] fn test_section_hierarchy() { check_renders_to("\ +++++ Title +++++ Not A Subtitle ============== Some stuff Section ------- Some more stuff Another Section ............... And even more stuff ", "\

Title

Not A Subtitle

Some stuff

Section

Some more stuff

Another Section

And even more stuff

\ "); } #[test] fn test_bullet_list() { check_renders_to("\ * bullet * list ", "\ \ "); } /* #[test] fn test_table() { check_renders_to("\ .. table:: :align: right +-----+-----+ | 1 | 2 | +-----+-----+ | 3 | 4 | +-----+-----+ ", "\

1

2

3

4

\ "); } */ /* #[test] fn test_field_list() { check_renders_to("\ Not a docinfo. :This: .. _target: is :a: :simple: :field: list ", "\

Not a docinfo.

This

is

a

simple

field

list

\ "); } */ /* #[test] fn test_field_list_long() { check_renders_to("\ Not a docinfo. :This is: a :simple field list with loooong field: names ", "\

Not a docinfo.

This is

a

simple field list with loooong field

names

\ "); } */