mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-03 12:35:48 -05:00
Tests: graph default markers are checked as squares, plain column height pinned
The `sized` helper in the graph tests now also requires the path to be the four corners of its bounds, so a circle with the same 5 by 5 bounds no longer passes as a default square marker. The plain column drawn in place of a design past the budget is checked for its exact 140 point value height instead of a height above 8 points.
This commit is contained in:
1 parent
4f942e5ba6
commit
7f6cfef99c
1 file changed
+7
-3
@@ -6726,9 +6726,12 @@ fn designs_and_markers_survive_save_and_open() {
|
||||
assert_eq!(marks.iter().filter(|n| sized(n, 5.0)).count(), 1, "a default square at the one data point");
|
||||
}
|
||||
|
||||
/// Whether `n` is a square `side` points across (a default point marker is 5, a default legend swatch 8).
|
||||
/// Whether `n` is a square path `side` points across, drawn as the four corners of its bounds (a default point marker
|
||||
/// is 5, a default legend swatch 8).
|
||||
fn sized(n: &vectorcraft_doc::Node, side: f64) -> bool {
|
||||
n.geometric_bounds().is_some_and(|b| (b.width() - side).abs() < 1e-6 && (b.height() - side).abs() < 1e-6)
|
||||
let Some(b) = n.geometric_bounds() else { return false };
|
||||
let square = matches!(&n.kind, NodeKind::Path { path, .. } if *path == vectorcraft_geom::shapes::rectangle(b));
|
||||
square && (b.width() - side).abs() < 1e-6 && (b.height() - side).abs() < 1e-6
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -7174,7 +7177,8 @@ fn graph_column_params_are_checked_and_designs_too_big_are_drawn_plain() {
|
||||
assert_eq!(marks.iter().filter(|n| sized(n, 8.0)).count(), 1, "a default square as the legend swatch");
|
||||
let columns: Vec<_> = marks.iter().filter(|n| !sized(n, 8.0)).collect();
|
||||
assert_eq!(columns.len(), 1, "one plain column for the one value");
|
||||
assert!(columns[0].geometric_bounds().is_some_and(|b| b.height() > 8.0), "the column has the value's height");
|
||||
let height = columns[0].geometric_bounds().map(|b| b.height());
|
||||
assert!(height.is_some_and(|h| (h - 140.0).abs() < 1e-6), "the column has the value's height: {height:?}");
|
||||
// Columns of 0 on a value axis from 10,000 to 10,001 run 2,000,000 points from the clamped zero line: a copy each
|
||||
// 0.1 is past the budget too.
|
||||
let far = one_series(&mut s, "column", &[0.0, 0.0]);
|
||||
|
||||
Reference in new issue
Block a user