css_ast/rules/media/features/
device_height.rs

1use super::prelude::*;
2use crate::units::Length;
3
4ranged_feature!(
5	#[derive(ToCursors, ToSpan, SemanticEq, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
6	#[cfg_attr(feature = "serde", derive(serde::Serialize), serde())]
7	#[cfg_attr(feature = "visitable", derive(csskit_derives::Visitable))]
8	pub enum DeviceHeightMediaFeature{CssAtomSet::DeviceHeight | CssAtomSet::MinDeviceHeight | CssAtomSet::MaxDeviceHeight, Length}
9);
10
11#[cfg(test)]
12mod tests {
13	use super::*;
14	use crate::CssAtomSet;
15	use css_parse::{assert_parse, assert_parse_error};
16
17	#[test]
18	fn size_test() {
19		assert_eq!(std::mem::size_of::<DeviceHeightMediaFeature>(), 124);
20	}
21
22	#[test]
23	fn test_writes() {
24		assert_parse!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(device-height:360px)");
25		assert_parse!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(device-height:35rem)");
26		assert_parse!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(min-device-height:35rem)");
27		assert_parse!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(max-device-height:35rem)");
28		assert_parse!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(device-height<=800px)");
29		assert_parse!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(device-height>=1400px)");
30		assert_parse!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(device-height>=1400px)");
31		assert_parse!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(device-height=1400px)");
32		assert_parse!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(1400px=device-height)");
33		assert_parse!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(100px<=device-height)");
34		assert_parse!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(100px<device-height<1400px)");
35		assert_parse!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(100px>device-height<1400px)");
36		assert_parse!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(100px>=device-height<=1400px)");
37		assert_parse!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(100px<=device-height>1400px)");
38	}
39
40	#[test]
41	fn test_errors() {
42		assert_parse_error!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(device-height:)");
43		assert_parse_error!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(device-height: > 10px)");
44		assert_parse_error!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(max-device-height > 10px)");
45		assert_parse_error!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(min-device-height > 10px)");
46		assert_parse_error!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(device-height: 1%)");
47		assert_parse_error!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(device-height: 1%)");
48		assert_parse_error!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(pointer: 1px)");
49	}
50}