lichtung-plot 0.3.0

Strongly typed scientific plotting with deterministic SVG and PNG output
Documentation
use super::*;

#[test]
fn root_padding_keeps_fractional_edges_until_the_complete_hard_boundary() {
    use crate::layout::canvas::RootFramePlan;
    let mut theme = super::super::Theme::publication().resolve().unwrap();
    let third = RelativeSpacing::ratio(1, 17 * 3072).unwrap();

    theme.composition = theme
        .composition
        .clone()
        .root_padding(
            Insets::zero()
                .left(Length::Em(third.clone()))
                .right(Length::Em(third)),
        )
        .unwrap();
    let text = crate::text::TextService::default();
    let theme = crate::text::TextRequestContext::new(&theme, &text);
    let measure = |hard| {
        RootFramePlan::measure(
            (1.0, 1.0),
            &theme,
            [None; 3],
            crate::decorations::title_block::plan::RootAlignments::resolve(
                &theme, [None; 3], [None; 2],
            ),
            (hard, 1.0 / 1024.0),
        )
    };
    assert!(measure(1023.0 / 1024.0).is_ok());
    assert!(matches!(
        measure(1.0),
        Err(crate::layout::fit::PlanError::Fit(_))
    ));

    assert_eq!(
        theme
            .root_padding_lengths()
            .unwrap()
            .horizontal()
            .round(SpatialRounding::Ceil)
            .unwrap()
            .quanta(),
        1
    );
}