static FONT_BYTES: &[u8] = include_bytes!("../../../../oxitext/tests/fixtures/test-font.ttf");
#[test]
fn shape_hello_returns_glyphs() {
use oxiui_text::{TextPipeline, TextStyle};
let mut pipeline = TextPipeline::from_bytes(FONT_BYTES).expect("pipeline creation failed");
let style = TextStyle::default();
let result = pipeline.shape("Hello", &style).expect("shape failed");
let total_glyphs: usize = result.lines.iter().map(|l| l.len()).sum();
assert!(total_glyphs > 0, "expected at least 1 glyph for 'Hello'");
}
#[test]
fn shape_produces_nonzero_metrics() {
use oxiui_text::{TextPipeline, TextStyle};
let mut pipeline = TextPipeline::from_bytes(FONT_BYTES).expect("pipeline creation failed");
let style = TextStyle::default();
let result = pipeline.shape("Hello", &style).expect("shape failed");
assert!(
result.total_width > 0.0,
"shaped text must have nonzero width"
);
assert!(
result.total_height > 0.0,
"shaped text must have nonzero height"
);
}
#[test]
fn text_pipeline_error_maps_to_ui_error() {
use oxiui_text::{TextPipeline, TextStyle};
let mut pipeline = TextPipeline::from_bytes(FONT_BYTES).expect("pipeline creation failed");
let style = TextStyle::default();
let _result = pipeline.shape("", &style);
}
#[test]
fn render_hello_produces_bitmaps() {
use oxiui_text::{TextPipeline, TextStyle};
let mut pipeline = TextPipeline::from_bytes(FONT_BYTES).expect("pipeline creation failed");
let style = TextStyle::default();
let result = pipeline.render("Hello", &style).expect("render failed");
assert_eq!(
result.glyphs.len(),
result.bitmaps.len(),
"glyphs and bitmaps must have the same length"
);
assert!(
!result.glyphs.is_empty(),
"expected at least one positioned glyph"
);
}