use proptest::prelude::*;
use crate::platform::PlatformTextSystem;
use crate::{FontFeature, FontId, FontRun, NoopTextSystem};
fn arbitrary_tag_strategy() -> impl Strategy<Value = [u8; 4]> {
prop::array::uniform4(any::<u8>())
}
fn arbitrary_value_strategy() -> impl Strategy<Value = u32> {
any::<u32>()
}
proptest! {
#![proptest_config(ProptestConfig::with_cases(100))]
#[test]
fn opentype_feature_tag_tolerance(
tag in arbitrary_tag_strategy(),
value in arbitrary_value_strategy(),
) {
let text_system = NoopTextSystem;
let text = "Hello, world!";
let font_size = crate::px(16.0);
let runs = vec![FontRun {
len: text.len(),
font_id: FontId(0),
}];
let features = vec![FontFeature::new(tag, value)];
let layout = text_system.layout_line_with_features(text, font_size, &runs, &features);
prop_assert!(
layout.width.0 >= 0.0,
"layout width must be non-negative, got {}",
layout.width.0
);
prop_assert_eq!(
layout.len,
text.len(),
"layout len must equal input text byte length"
);
}
}