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	pub enum DeviceHeightMediaFeature{CssAtomSet::DeviceHeight | CssAtomSet::MinDeviceHeight | CssAtomSet::MaxDeviceHeight, Length}
8);
9
10#[cfg(test)]
11mod tests {
12	use super::*;
13	use crate::CssAtomSet;
14	use css_parse::{assert_parse, assert_parse_error};
15
16	#[test]
17	fn size_test() {
18		assert_eq!(std::mem::size_of::<DeviceHeightMediaFeature>(), 124);
19	}
20
21	#[test]
22	fn test_writes() {
23		assert_parse!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(device-height:360px)");
24		assert_parse!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(device-height:35rem)");
25		assert_parse!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(min-device-height:35rem)");
26		assert_parse!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(max-device-height:35rem)");
27		assert_parse!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(device-height<=800px)");
28		assert_parse!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(device-height>=1400px)");
29		assert_parse!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(device-height>=1400px)");
30		assert_parse!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(device-height=1400px)");
31		assert_parse!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(1400px=device-height)");
32		assert_parse!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(100px<=device-height)");
33		assert_parse!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(100px<device-height<1400px)");
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	}
38
39	#[test]
40	fn test_errors() {
41		assert_parse_error!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(device-height:)");
42		assert_parse_error!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(device-height: > 10px)");
43		assert_parse_error!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(max-device-height > 10px)");
44		assert_parse_error!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(min-device-height > 10px)");
45		assert_parse_error!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(device-height: 1%)");
46		assert_parse_error!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(device-height: 1%)");
47		assert_parse_error!(CssAtomSet::ATOMS, DeviceHeightMediaFeature, "(pointer: 1px)");
48	}
49}