summaryrefslogtreecommitdiffstats
path: root/crates/mdman/tests/invalid.rs
blob: cc81d06c4271df1b06999585c0fe1d5a165c7388 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//! Tests for errors and invalid input.

use mdman::{Format, ManMap};
use pretty_assertions::assert_eq;
use std::path::PathBuf;

fn run(name: &str, expected_error: &str) {
    let input = PathBuf::from(format!("tests/invalid/{}", name));
    match mdman::convert(&input, Format::Man, None, ManMap::new()) {
        Ok(_) => {
            panic!("expected {} to fail", name);
        }
        Err(e) => {
            assert_eq!(expected_error, e.to_string());
        }
    }
}

macro_rules! test( ($name:ident, $file_name:expr, $error:expr) => (
    #[test]
    fn $name() { run($file_name, $error); }
) );

test!(
    nested,
    "nested.md",
    "Error rendering \"template\" line 4, col 1: options blocks cannot be nested"
);

test!(
    not_inside_options,
    "not-inside-options.md",
    "Error rendering \"template\" line 3, col 1: option must be in options block"
);