mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-08 09:31:03 +00:00
Fix #5714: doc comments on the width profile tests
This commit is contained in:
@@ -395,6 +395,7 @@ pub struct SavedProfile {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// Widths and steps are found by search, at the ends, between points and at a step.
|
||||
#[test]
|
||||
fn width_profile_lookups_by_search() {
|
||||
let p = WidthProfile { points: vec![(0.0, 0.0, 0.0), (0.5, 1.0, 1.0), (0.5, 0.5, 0.25), (1.0, 0.0, 0.0)] };
|
||||
@@ -441,6 +442,7 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// Neither side of a profile goes wider or narrower than the two points of the span it is in.
|
||||
#[test]
|
||||
fn widths_never_pass_the_points_either_side() {
|
||||
for preset in WidthProfile::PRESETS {
|
||||
@@ -474,6 +476,7 @@ mod tests {
|
||||
assert!((p.at(0.25).0 - 2.0).abs() < 1e-12 && (p.at(0.75).0 - 1.5).abs() < 1e-12);
|
||||
}
|
||||
|
||||
/// `widest()` is at least the stroke's width anywhere along the profile, even where the sides peak apart.
|
||||
#[test]
|
||||
fn widest_covers_every_width_along_the_profile() {
|
||||
let profiles = [
|
||||
|
||||
@@ -192,6 +192,7 @@ fn strokes_without_pressure_round_trip_unchanged() {
|
||||
assert_eq!((st.pressure, st.tilt, st.bearing, st.rotation), (None, None, None, None));
|
||||
}
|
||||
|
||||
/// The Lens profile's widths at its middle, a quarter of the way along and past its end.
|
||||
#[test]
|
||||
fn profile_interp() {
|
||||
let p = WidthProfile::lens();
|
||||
|
||||
@@ -225,6 +225,7 @@ fn expand_stroke_region_of_a_round_line_stays_compact() {
|
||||
assert_eq!(dense_anchors, anchors, "colinear spine points should not add outline anchors");
|
||||
}
|
||||
|
||||
/// A line's outline takes its width profile, its dashes (each reading the profile where it sits) or neither.
|
||||
#[test]
|
||||
fn line_outline_uses_the_profile_dashes_or_a_plain_stroke() {
|
||||
let l = line(0.0, 100.0);
|
||||
|
||||
@@ -117,6 +117,7 @@ fn along_keeps_a_corners_colour_round_its_outside() {
|
||||
assert!((param(&sl, Point::new(95.0, 8.0)).unwrap() - 0.54).abs() < 1e-6);
|
||||
}
|
||||
|
||||
/// An Across stroke gradient runs from the stroke's left edge to its right edge, also where a width profile moves them.
|
||||
#[test]
|
||||
fn across_runs_from_the_left_edge_to_the_right() {
|
||||
let st = stroke(10.0, StrokeGradientMode::Across);
|
||||
@@ -163,6 +164,7 @@ fn an_aligned_stroke_spans_the_gradient_across_the_side_it_shows_on() {
|
||||
}
|
||||
}
|
||||
|
||||
/// The gradient slices cover every point the stroke paints, with each join, caps, arrowheads, a profile and dashes.
|
||||
#[test]
|
||||
fn slices_cover_everything_the_stroke_paints() {
|
||||
let zig = poly(&[(0.0, 0.0), (60.0, 40.0), (0.0, 80.0), (70.0, 90.0), (75.0, 20.0)], false);
|
||||
|
||||
@@ -423,6 +423,7 @@ mod tests {
|
||||
assert!((area(&width_outline(&line(), 10.0, &p, &capped(LineCap::Square), 0.01)) - 1100.0).abs() < 1e-6);
|
||||
}
|
||||
|
||||
/// The Lens outline swells on its curve, and a profile with one side at zero paints only the other side.
|
||||
#[test]
|
||||
fn lens_profile_swells_smoothly_and_one_sided_profiles_stay_on_their_side() {
|
||||
// Each half of the lens rises on a cubic from 0 to full width, flat at the middle: it
|
||||
|
||||
@@ -71,6 +71,7 @@ fn arrowheads_are_part_of_the_outline() {
|
||||
assert_eq!(path_of(&n).subpaths.len(), 1, "line and head are one shape");
|
||||
}
|
||||
|
||||
/// Outline Stroke of a Lens-profile line covers 7/12 of the full-width rectangle.
|
||||
#[test]
|
||||
fn a_lens_profile_outlines_to_seven_twelfths_of_the_rectangle() {
|
||||
let mut s = session();
|
||||
|
||||
@@ -214,6 +214,7 @@ fn new_width_point_without_adjoining_preserves_neighbours() {
|
||||
new_point_adjoining(false);
|
||||
}
|
||||
|
||||
/// A new width point with Adjust Adjoining scales only its nearest neighbours, by the widths sampled where it goes.
|
||||
#[test]
|
||||
fn new_width_point_adjust_adjoining_uses_sampled_widths() {
|
||||
for indexed in [false, true] {
|
||||
|
||||
Reference in New Issue
Block a user