use crate::token::*; test!(pi_01, "", Token::PI("xslt", Some("ma"), 0..11)); test!( pi_02, "", Token::PI("xslt", Some("m"), 0..13) ); test!(pi_03, "", Token::PI("xslt", None, 0..8)); test!(pi_04, "", Token::PI("xslt", None, 0..9)); test!( pi_05, "", Token::PI("xml-stylesheet", None, 0..18) ); test!( pi_err_01, "", Token::Error("invalid processing instruction at 1:1 cause invalid name token".to_string()) ); test!( declaration_01, "", Token::Declaration("1.0", None, None, 0..21) ); test!( declaration_02, "", Token::Declaration("1.0", None, None, 0..21) ); test!( declaration_03, "", Token::Declaration("1.0", Some("UTF-8"), None, 0..38) ); test!( declaration_04, "", Token::Declaration("1.0", Some("UTF-8"), None, 0..38) ); test!( declaration_05, "", Token::Declaration("1.0", Some("utf-8"), None, 0..38) ); test!( declaration_06, "", Token::Declaration("1.0", Some("EUC-JP"), None, 0..39) ); test!( declaration_07, "", Token::Declaration("1.0", Some("UTF-8"), Some(true), 0..55) ); test!( declaration_08, "", Token::Declaration("1.0", Some("UTF-8"), Some(false), 0..54) ); test!( declaration_09, "", Token::Declaration("1.0", None, Some(false), 0..37) ); test!( declaration_10, "", Token::Declaration("1.0", None, Some(false), 0..38) ); // Declaration with an invalid order test!( declaration_err_01, "", Token::Error("invalid XML declaration at 1:1 cause expected 'version' at 1:7".to_string()) ); test!( declaration_err_02, "", Token::Error("invalid XML declaration at 1:1 cause expected '\'' not '*' at 1:31".to_string()) ); test!( declaration_err_03, "", Token::Error("invalid XML declaration at 1:1 cause expected '1.' at 1:16".to_string()) ); test!( declaration_err_04, "", Token::Error("invalid XML declaration at 1:1 cause expected 'yes', 'no' at 1:33".to_string()) ); test!( declaration_err_05, "", Token::Error("invalid XML declaration at 1:1 cause expected '?>' at 1:21".to_string()) ); test!( declaration_err_06, "", Token::Error("invalid XML declaration at 1:1 cause expected '?>' at 1:55".to_string()) ); test!( declaration_err_07, "\u{000a}' at 3:7".to_string()) ); test!( declaration_err_08, "", Token::Error("invalid XML declaration at 1:1 cause expected 'version' at 2:2".to_string()) ); test!( declaration_err_09, "", Token::Error("invalid XML declaration at 1:1 cause expected 'version' at 2:2".to_string()) ); // XML declaration allowed only at the start of the document. test!( declaration_err_10, " ", Token::Error("unknown token at 1:2".to_string()) ); // XML declaration allowed only at the start of the document. test!( declaration_err_11, "", Token::Comment(" comment ", 0..16), Token::Error("unknown token at 1:17".to_string()) ); // Duplicate. test!( declaration_err_12, "", Token::Declaration("1.0", None, None, 0..21), Token::Error("unknown token at 1:22".to_string()) ); test!( declaration_err_13, "", Token::Error( "invalid processing instruction at 1:1 cause a non-XML character '\\u{1}' found at 1:10" .to_string() ) ); test!( declaration_err_14, "", Token::Error("invalid XML declaration at 1:1 cause expected space not 'e' at 1:20".to_string()) ); test!( declaration_err_15, "", Token::Error("invalid XML declaration at 1:1 cause expected space not 's' at 1:37".to_string()) ); test!( declaration_err_16, "' at 1:20".to_string()) );