// Copyright 2018 Fredrik Portström // This is free software distributed under the terms specified in // the file LICENSE at the top-level directory of this distribution. #[path = "test_cases.rs"] mod test_cases; use test_cases::TEST_CASES; use text_wrapper::Text; pub async fn run_test(configuration: &async_parse_wiki_text::Configuration) { let mut output = concat!( "Parse Wiki Text test cases", "", "
" ).to_owned(); if let Some(window) = TEST_CASES .windows(2) .find(|window| window[0].0 >= window[1].0) { panic!("Sort: {:#?}", (window[0].0, window[1].0)); } for (title, test_cases) in TEST_CASES { if let Some(window) = test_cases.windows(2).find(|window| window[0] >= window[1]) { panic!("Sort: {:#?}", window); } output += &format!("", title.replace(" ", "_")); output += title; output += &format!(" {}", test_cases.len()); } output += "
"; for (title, test_cases) in TEST_CASES { output += &format!("

", title.replace(" ", "_")); output += title; output += "

"; for wiki_text in *test_cases { output += "
";
            output += &wiki_text
                .replace("&", "&")
                .replace("<", "<")
                .replace("\t", "")
                .replace("\n", "\n")
                .replace(" ", "·")
                .replace("", "");
            match ::std::panic::catch_unwind(|| configuration.parse(Text::new(wiki_text))) {
                Err(_) => {
                    eprintln!("Panic with wiki text {:?}", wiki_text);
                    output += "

panic
"; } Ok(result) => { output += "
";
                    output += &format!("{:#?}", result.await)
                        .replace("&", "&")
                        .replace("<", "<");
                    output += "
"; } } } } output += ""; if let Err(error) = ::std::fs::write("report.html", output) { eprintln!("Failed to write report: {}", error); ::std::process::exit(1); } }