()
| 2172 | /// Test that `auto_bounds(true)` fits the data exactly when the margin fraction is zero. |
| 2173 | #[test] |
| 2174 | fn auto_bounds_true() { |
| 2175 | crate::utils::init_test_logger(); |
| 2176 | |
| 2177 | const MIN: [f64; 2] = [-10.0, -10.0]; |
| 2178 | const MAX: [f64; 2] = [10.0, 10.0]; |
| 2179 | |
| 2180 | let harness = { |
| 2181 | let bounds = PlotBounds::from_min_max(MIN, MAX); |
| 2182 | Harness::new_ui_state( |
| 2183 | |ui, bounds| { |
| 2184 | let plot = Plot::new("test_plot") |
| 2185 | .auto_bounds(true) |
| 2186 | .set_margin_fraction(Vec2::splat(0.0)); |
| 2187 | |
| 2188 | plot.show(ui, |plot_ui| { |
| 2189 | let corners = vec![MIN, MAX]; |
| 2190 | plot_ui.points(Points::new("filler", corners)); |
| 2191 | *bounds = plot_ui.plot_bounds(); |
| 2192 | }); |
| 2193 | }, |
| 2194 | bounds, |
| 2195 | ) |
| 2196 | }; |
| 2197 | |
| 2198 | let final_bounds = harness.state(); |
| 2199 | assert!((final_bounds.min[0] - MIN[0]).abs() <= f64::EPSILON); |
| 2200 | assert!((final_bounds.min[1] - MIN[1]).abs() <= f64::EPSILON); |
| 2201 | assert!((final_bounds.max[0] - MAX[0]).abs() <= f64::EPSILON); |
| 2202 | assert!((final_bounds.max[1] - MAX[1]).abs() <= f64::EPSILON); |
| 2203 | } |
| 2204 | } |
nothing calls this directly
no test coverage detected