|
| 1 | +use core::unicode::unicode_data; |
| 2 | + |
| 3 | +mod test_data; |
| 4 | + |
1 | 5 | #[test] |
2 | 6 | pub fn version() { |
3 | 7 | let (major, _minor, _update) = core::char::UNICODE_VERSION; |
4 | 8 | assert!(major >= 10); |
5 | 9 | } |
| 10 | + |
| 11 | +#[test] |
| 12 | +#[cfg_attr(miri, ignore)] |
| 13 | +fn alphabetic_true() { |
| 14 | + for range in test_data::ALPHABETIC_TRUE { |
| 15 | + for c in range.clone() { |
| 16 | + assert!(unicode_data::alphabetic::lookup(c), "{c:?}"); |
| 17 | + } |
| 18 | + } |
| 19 | +} |
| 20 | + |
| 21 | +#[test] |
| 22 | +#[cfg_attr(miri, ignore)] |
| 23 | +fn alphabetic_false() { |
| 24 | + for range in test_data::ALPHABETIC_FALSE { |
| 25 | + for c in range.clone() { |
| 26 | + assert!(!unicode_data::alphabetic::lookup(c), "{c:?}"); |
| 27 | + } |
| 28 | + } |
| 29 | +} |
| 30 | + |
| 31 | +#[test] |
| 32 | +#[cfg_attr(miri, ignore)] |
| 33 | +fn case_ignorable_true() { |
| 34 | + for range in test_data::CASE_IGNORABLE_TRUE { |
| 35 | + for c in range.clone() { |
| 36 | + assert!(unicode_data::case_ignorable::lookup(c), "{c:?}"); |
| 37 | + } |
| 38 | + } |
| 39 | +} |
| 40 | + |
| 41 | +#[test] |
| 42 | +#[cfg_attr(miri, ignore)] |
| 43 | +fn case_ignorable_false() { |
| 44 | + for range in test_data::CASE_IGNORABLE_FALSE { |
| 45 | + for c in range.clone() { |
| 46 | + assert!(!unicode_data::case_ignorable::lookup(c), "{c:?}"); |
| 47 | + } |
| 48 | + } |
| 49 | +} |
| 50 | + |
| 51 | +#[test] |
| 52 | +#[cfg_attr(miri, ignore)] |
| 53 | +fn cased_true() { |
| 54 | + for range in test_data::CASED_TRUE { |
| 55 | + for c in range.clone() { |
| 56 | + assert!(unicode_data::cased::lookup(c), "{c:?}"); |
| 57 | + } |
| 58 | + } |
| 59 | +} |
| 60 | + |
| 61 | +#[test] |
| 62 | +#[cfg_attr(miri, ignore)] |
| 63 | +fn cased_false() { |
| 64 | + for range in test_data::CASED_FALSE { |
| 65 | + for c in range.clone() { |
| 66 | + assert!(!unicode_data::cased::lookup(c), "{c:?}"); |
| 67 | + } |
| 68 | + } |
| 69 | +} |
| 70 | + |
| 71 | +#[test] |
| 72 | +#[cfg_attr(miri, ignore)] |
| 73 | +fn grapheme_extend_true() { |
| 74 | + for range in test_data::GRAPHEME_EXTEND_TRUE { |
| 75 | + for c in range.clone() { |
| 76 | + assert!(unicode_data::grapheme_extend::lookup(c), "{c:?}"); |
| 77 | + } |
| 78 | + } |
| 79 | +} |
| 80 | + |
| 81 | +#[test] |
| 82 | +#[cfg_attr(miri, ignore)] |
| 83 | +fn grapheme_extend_false() { |
| 84 | + for range in test_data::GRAPHEME_EXTEND_FALSE { |
| 85 | + for c in range.clone() { |
| 86 | + assert!(!unicode_data::grapheme_extend::lookup(c), "{c:?}"); |
| 87 | + } |
| 88 | + } |
| 89 | +} |
| 90 | + |
| 91 | +#[test] |
| 92 | +#[cfg_attr(miri, ignore)] |
| 93 | +fn lowercase_true() { |
| 94 | + for range in test_data::LOWERCASE_TRUE { |
| 95 | + for c in range.clone() { |
| 96 | + assert!(unicode_data::lowercase::lookup(c), "{c:?}"); |
| 97 | + } |
| 98 | + } |
| 99 | +} |
| 100 | + |
| 101 | +#[test] |
| 102 | +#[cfg_attr(miri, ignore)] |
| 103 | +fn lowercase_false() { |
| 104 | + for range in test_data::LOWERCASE_FALSE { |
| 105 | + for c in range.clone() { |
| 106 | + assert!(!unicode_data::lowercase::lookup(c), "{c:?}"); |
| 107 | + } |
| 108 | + } |
| 109 | +} |
| 110 | + |
| 111 | +#[test] |
| 112 | +#[cfg_attr(miri, ignore)] |
| 113 | +fn n_true() { |
| 114 | + for range in test_data::N_TRUE { |
| 115 | + for c in range.clone() { |
| 116 | + assert!(unicode_data::n::lookup(c), "{c:?}"); |
| 117 | + } |
| 118 | + } |
| 119 | +} |
| 120 | + |
| 121 | +#[test] |
| 122 | +#[cfg_attr(miri, ignore)] |
| 123 | +fn n_false() { |
| 124 | + for range in test_data::N_FALSE { |
| 125 | + for c in range.clone() { |
| 126 | + assert!(!unicode_data::n::lookup(c), "{c:?}"); |
| 127 | + } |
| 128 | + } |
| 129 | +} |
| 130 | + |
| 131 | +#[test] |
| 132 | +#[cfg_attr(miri, ignore)] |
| 133 | +fn uppercase_true() { |
| 134 | + for range in test_data::UPPERCASE_TRUE { |
| 135 | + for c in range.clone() { |
| 136 | + assert!(unicode_data::uppercase::lookup(c), "{c:?}"); |
| 137 | + } |
| 138 | + } |
| 139 | +} |
| 140 | + |
| 141 | +#[test] |
| 142 | +#[cfg_attr(miri, ignore)] |
| 143 | +fn uppercase_false() { |
| 144 | + for range in test_data::UPPERCASE_FALSE { |
| 145 | + for c in range.clone() { |
| 146 | + assert!(!unicode_data::uppercase::lookup(c), "{c:?}"); |
| 147 | + } |
| 148 | + } |
| 149 | +} |
| 150 | + |
| 151 | +#[test] |
| 152 | +#[cfg_attr(miri, ignore)] |
| 153 | +fn white_space_true() { |
| 154 | + for range in test_data::WHITE_SPACE_TRUE { |
| 155 | + for c in range.clone() { |
| 156 | + assert!(unicode_data::white_space::lookup(c), "{c:?}"); |
| 157 | + } |
| 158 | + } |
| 159 | +} |
| 160 | + |
| 161 | +#[test] |
| 162 | +#[cfg_attr(miri, ignore)] |
| 163 | +fn white_space_false() { |
| 164 | + for range in test_data::WHITE_SPACE_FALSE { |
| 165 | + for c in range.clone() { |
| 166 | + assert!(!unicode_data::white_space::lookup(c), "{c:?}"); |
| 167 | + } |
| 168 | + } |
| 169 | +} |
| 170 | + |
| 171 | +#[test] |
| 172 | +#[cfg_attr(miri, ignore)] |
| 173 | +fn to_lower_mapped() { |
| 174 | + for (c, chars) in test_data::TO_LOWER_MAPPED { |
| 175 | + assert_eq!(unicode_data::conversions::to_lower(*c), *chars, "{c:?}"); |
| 176 | + } |
| 177 | +} |
| 178 | + |
| 179 | +#[test] |
| 180 | +#[cfg_attr(miri, ignore)] |
| 181 | +fn to_lower_unmapped() { |
| 182 | + for range in test_data::TO_LOWER_UNMAPPED { |
| 183 | + for c in range.clone() { |
| 184 | + assert_eq!(unicode_data::conversions::to_lower(c), [c, '\0', '\0'], "{c:?}"); |
| 185 | + } |
| 186 | + } |
| 187 | +} |
| 188 | + |
| 189 | +#[test] |
| 190 | +#[cfg_attr(miri, ignore)] |
| 191 | +fn to_upper_mapped() { |
| 192 | + for (c, chars) in test_data::TO_UPPER_MAPPED { |
| 193 | + assert_eq!(unicode_data::conversions::to_upper(*c), *chars, "{c:?}"); |
| 194 | + } |
| 195 | +} |
| 196 | + |
| 197 | +#[test] |
| 198 | +#[cfg_attr(miri, ignore)] |
| 199 | +fn to_upper_unmapped() { |
| 200 | + for range in test_data::TO_UPPER_UNMAPPED { |
| 201 | + for c in range.clone() { |
| 202 | + assert_eq!(unicode_data::conversions::to_upper(c), [c, '\0', '\0'], "{c:?}"); |
| 203 | + } |
| 204 | + } |
| 205 | +} |
0 commit comments