diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-06-15 13:08:29 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-06-15 13:08:29 +0200 |
commit | 70afc162071250ccf1a855a5131154599b58034d (patch) | |
tree | eb4716c0a2d2f1ff294cdcc6d20febe3fcc3708d /src/constant.rs | |
parent | 1cd34ef54f7a62998eb87c41cd794d3a426d6324 (diff) | |
download | markdown-rs-70afc162071250ccf1a855a5131154599b58034d.tar.gz markdown-rs-70afc162071250ccf1a855a5131154599b58034d.tar.bz2 markdown-rs-70afc162071250ccf1a855a5131154599b58034d.zip |
Add tests for constants
Diffstat (limited to 'src/constant.rs')
-rw-r--r-- | src/constant.rs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/constant.rs b/src/constant.rs index c98c24d..d2fb238 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -2576,3 +2576,49 @@ pub const CHARACTER_REFERENCE_VALUES: [&str; 2222] = [ "⟶", "𝓍", "⨆", "⨄", "△", "⋁", "⋀", "ý", "ý", "я", "ŷ", "ы", "¥", "¥", "𝔶", "ї", "𝕪", "𝓎", "ю", "ÿ", "ÿ", "ź", "ž", "з", "ż", "ℨ", "ζ", "𝔷", "ж", "⇝", "𝕫", "𝓏", "", "", ]; + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn constants() { + assert_eq!( + CHARACTER_REFERENCE_DECIMAL_SIZE_MAX, + format!("{}", 0x10ffff).len(), + "`CHARACTER_REFERENCE_DECIMAL_SIZE_MAX`" + ); + + assert_eq!( + CHARACTER_REFERENCE_HEXADECIMAL_SIZE_MAX, + format!("{:x}", 0x10ffff).len(), + "`CHARACTER_REFERENCE_HEXADECIMAL_SIZE_MAX`" + ); + + assert_eq!( + CHARACTER_REFERENCE_NAMED_SIZE_MAX, + longest(&CHARACTER_REFERENCE_NAMES).unwrap().len(), + "`CHARACTER_REFERENCE_NAMED_SIZE_MAX`" + ); + + assert_eq!( + HTML_RAW_SIZE_MAX, + longest(&HTML_RAW_NAMES).unwrap().len(), + "`HTML_RAW_SIZE_MAX`" + ); + } + + fn longest<'a>(list: &[&'a str]) -> Option<&'a str> { + let mut max = 0; + let mut result = None; + for name in list.iter() { + let len = name.len(); + if len > max { + max = len; + result = Some(*name); + } + } + + result + } +} |